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 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:

|     |

So is this:

|P P J|
| S C |

And this:

|     |

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 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)
  • 3
    \$\begingroup\$ Umm, So you can also pick your pizza up on a Drive-thru? \$\endgroup\$ Commented Apr 1, 2017 at 1:37
  • 1
    \$\begingroup\$ Are you picky about me filling the top right and bottom right corners of the pizza box with whitespace? ;) \$\endgroup\$
    – DLosc
    Commented Apr 1, 2017 at 4:42
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – user58826
    Commented Apr 1, 2017 at 11:49
  • 1
    \$\begingroup\$ C̶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 2x P. \$\endgroup\$ Commented Apr 5, 2017 at 7:53
  • \$\begingroup\$ Can I post an orderup link? xD \$\endgroup\$
    – qqq
    Commented Dec 28, 2017 at 19:35

6 Answers 6


Python 2, 202,198,190,177,162,157,146 bytes

s=' '
l=' /'+'='*(n-1)+'\\ '+('','\n/'+s*y+'\\')[n>4]+'\n|'
print l+t[:y].center(y,s)+('','|\n|'+t[y:].center(y,s))[y%2]+l[::-1]

Try it online!

  • \$\begingroup\$ Hey, can you assign '\\', '|', and '/ to variables to golf off a few bytes? That's how I shaved a lot off my JS answer. \$\endgroup\$
    – user58826
    Commented Apr 1, 2017 at 11:52
  • \$\begingroup\$ I'm just working on that!!!! \$\endgroup\$ Commented Apr 1, 2017 at 11:54
  • 1
    \$\begingroup\$ Also, can you replace the first (n-1) with (--n), the n>4s withn>3, (n+1) with (n+2), and the final (n-1) with n to shave off 4 bytes? \$\endgroup\$
    – user58826
    Commented Apr 1, 2017 at 12:00
  • 2
    \$\begingroup\$ python doesnt support -- operator ! \$\endgroup\$ Commented Apr 1, 2017 at 12:03
  • \$\begingroup\$ 136 bytes \$\endgroup\$
    – FlipTack
    Commented Dec 28, 2017 at 16:34

Python 3, 224 213 195 bytes

f,s,e,b,p="/ =\\|"
if n>4:y(f+t[:k]+b);i+=k
if n>4:y(b+t[i:i+k]+f);i+=k

Try it online!


Charcoal, 37 bytes

Nθ /==×=⸿/›θ⁴⸿|‖BO↓﹪θ²‖BO⊕﹪θ²J¹¦¹⪪S⊕θ

Try it online! Link is to verbose version of code. Explanation:


Input the size of the pizza.


Start printing the top of the pizza.


If the pizza is one of the larger sizes, add extra to the top and side.


Print more of the side of the pizza.


Complete the left half of the pizza by reflection with possible overlap.


Complete the pizza by reflection with variable overlap.


Input the toppings and split them into pieces so they will fit inside the pizza.


Pip, 87 81 75 bytes

74 bytes of code, +1 for -l flag.


Takes input as command-line arguments. Try it online!


e is the top row, such as /=====\. If you reverse it, it's also the bottom row.

y is the left border, such as ["/" "|" "|" "\"]. If you reverse it, it's also the right border.

We then construct the middle by taking b, the toppings, padding it with spaces to length (a+1)*(a-2) (where a is the size), and grouping it into a list of rows.

Finally, we print the top row with a leading space; concatenate the middle between y on the left and RVy on the right, and print that; and print the bottom row with a leading space.

  • \$\begingroup\$ Does this work with a cheese (no toppings) pizza? \$\endgroup\$
    – user58826
    Commented Apr 1, 2017 at 11:53
  • \$\begingroup\$ @programmer5000 Yes--in that case the second cmdline arg should be an empty string (if you're running it from an actual command-line, you'll have to quote it). \$\endgroup\$
    – DLosc
    Commented Apr 1, 2017 at 21:02

JS (ES6), 257 255 249 248 246 244 bytes

m=s=>t=>(r="/",k="\\",p=" ",f="\n",x="|",c=f+x,q="",t=p+t,z=(s>2?p:q)+r+"=".repeat(s-1)+k+(s>4?f+r+p.repeat(++s)+k:q)+c+p.repeat(s)+x+(!s?c+p.repeat(s)+x:q)+p+(s>5?f+k+p.repeat(s)+r:q)+f+p+k+"=".repeat(s-2)+r,i=-1,z.replace(/ /g, x=>t[++i]||p))

Call it like m(4)("PS") for 1 pepperoni and 1 sausage. Probably can be golfed more.

  • 1
    \$\begingroup\$ Jeez, give some other people time to answer :P \$\endgroup\$
    – Pavel
    Commented Mar 31, 2017 at 17:16
  • 1
    \$\begingroup\$ @Григорий Перельман I just wanted to provide an example, I hope this doesn't win. \$\endgroup\$
    – user58826
    Commented Mar 31, 2017 at 17:18

JavaScript (ES6), 170 161 bytes

(n,t,a=[1,,n%2||2,,1])=>` /=\\
 \\=/`[r=`replace`](/.+/g,s=>s.repeat(a.pop()||n>4))[r](/=|_\b/g,`$&`.repeat(n-1))[r](/_/g,_=>t[i++]||` `,i=0)

Starts by taking a misshapen pizza of width 2 and height 5 and stretches it horizontally and adjusts it vertically as appropriate, then replaces the interior with toppings or spaces once they run out.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.