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)
̶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
. \$\endgroup\$