17
2
Because it's Saturday (UTC) and I'm hungry, I would like a slice of pizza. I will give you an order and I would like a nice hot ascii-art pizza. Up to the challenge?
The Drive-Thru
I'll place my order wherever your drive-thru is, whether it is STDIN, a function parameter, a command-line argument, but I'm not going to put it in a variable for you. (JS function expressions must be assigned to a variable.)
The order
My order will have 2 parts. The first will be a positive, non-zero integer from 3
to 6
. This is the size of my pizza. For instance, a size 6
pizza with no toppings would look like:
/=====\
/ \
| |
| |
\ /
\=====/
A size 5
:
/====\
/ \
| |
\ /
\====/
A size 4
:
/===\
| |
| |
\===/
A size 3
/==\
| |
\==/
The toppings
My toppings will be a string of UPPERCASE letters. Here are the possible values:
P - Pepperoni S - Sausage N - piNeapple J - Jalapenos B - Banana peppers C - baCon
You must fit them on the pizza somewhere. If I order a size 4 and PSPCJ
, then this is a valid output:
/===\
|PSPCJ|
| |
\===/
So is this:
/===\
|P P J|
| S C |
\===/
And this:
/===\
| |
|PSPCJ|
\===/
I am not really picky about where my toppings are on the pizza, as long as they aren't on the crust or on top of each other.
The pick-up window
I will go to a lot of places to pick up my pizza, including STDOUT, a file, the return value of a function, but not a variable.
Extra stuff
- Standard loopholes forbidden
- This is tagged code-golf so the shortest answer in bytes wins!
- Don't worry about invalid input (toppings > pizza space, etc.)
- See my answer (JS ES6) below for an example (I hope you can do better)
3Umm, So you can also pick your pizza up on a Drive-thru? – Matthew Roh – 2017-04-01T01:37:21.723
1Are you picky about me filling the top right and bottom right corners of the pizza box with whitespace? ;) – DLosc – 2017-04-01T04:42:31.527
1@DLosc no, any trailing whitespace at the end of any line (including a trailing newline at the end of output) is optional but not required. – programmer5000 – 2017-04-01T11:49:09.317
1C̶a̶n̶ ̶t̶h̶e̶ ̶p̶i̶z̶z̶a̶ ̶h̶a̶v̶e̶ ̶m̶o̶r̶e̶ ̶t̶h̶a̶n̶ ̶o̶n̶e̶ ̶f̶o̶r̶ ̶o̶n̶e̶ ̶o̶f̶ ̶t̶h̶e̶ ̶t̶o̶p̶p̶i̶n̶g̶s̶?̶ ̶S̶o̶ ̶i̶f̶ ̶y̶o̶u̶ ̶l̶i̶k̶e̶ ̶p̶i̶n̶e̶a̶p̶p̶l̶e̶:̶ ̶
̶5̶,̶ ̶N̶N̶N̶
̶ ̶i̶s̶ ̶a̶l̶s̶o̶ ̶a̶ ̶v̶a̶l̶i̶d̶ ̶i̶n̶p̶u̶t̶ ̶(̶o̶r̶ ̶s̶h̶o̶u̶l̶d̶ ̶i̶t̶ ̶b̶e̶ ̶̶5̶,̶ ̶N̶
̶ ̶i̶n̶s̶t̶e̶a̶d̶)̶?̶ Also, where are the mushrooms?.. :( EDIT: Nevermind about the first question, I see your test cases has 2xP
. – Kevin Cruijssen – 2017-04-05T07:53:57.673Can I post an orderup link? xD
– FantaC – 2017-12-28T19:35:48.127