Pizza, Pizza, Deep Dish Pizza!
JavaScript (ES6), 136 bytes
f=
n=>"/\\"+(r=s=>s[0][0].repeat(n-1)+s)`_`+r`_`+r`___/\\
`+r` `.replace(/ /g,"$`\\ \\$` $'$'$'/ /\n")+r` \\ \\`+r`_/ /
`+r` \\`+r`___/`
<input type=number min=1 oninput=o.textContent=f(this.value)><pre id=o>
The whole pizza is very repetitious so the r
function (designed as a tagged template literal) repeats the first character of its input n
times. This handles the top and bottom two lines of the pizza. The middle is repeated by replacing a string of blanks; the $`
and $'
subsitutions automatically correspond to increasing and decreasing numbers of blanks thus positioning the \ \
and / /
appropriately.
JavaScript (ES6), 205 bytes
This is my first ascii-art post!
Add a f=
at the beginning and invoke like f(arg)
.
n=>{a=[];w=" ";u="_";t=`/\\${u.repeat(n*3+2)}/\\
`;for(i=0;i<n+1;i++){c=i==n?u:w;a.push(`${w.repeat(i)}\\ \\${c.repeat((n+1-i*2)+n+(n-1))}/ /
`)};return [t,...a,`${w.repeat(i)}\\${u.repeat(n+2)}/`].join``}
Note: All line breaks are necessary!
f=n=>{a=[];w=" ";u="_";t=`/\\${u.repeat(n*3+2)}/\\
`;for(i=0;i<n+1;i++){c=i==n?u:w;a.push(`${w.repeat(i)}\\ \\${c.repeat((n+1-i*2)+n+(n-1))}/ /
`)};return [t,...a,`${w.repeat(i)}\\${u.repeat(n+2)}/`].join``}
document.querySelector("#elem").innerHTML = f(+prompt("Enter a Number"));
<pre id="elem">
Explanation
The code first declares an Array a
. It then declares w
and u
having the value of whitespace and underscore respectively. Then, it declares a String variable to hold the value of the crust (which can be computed by /\+(n*3+2 underscores)+/\
, as mentioned in the Challenge). After that, with a for
loop and a Template Literal
, the middle of the pizza is created (with each layer having i
whitespaces at the starting and (n+1-i*2)+n+(n-1)
whitespaces between \ \
and / /
, where i
represents the index of for
loop). At the last, the bottom most part of the pizza is created ((i whitespaces)+\+(n+2 underscores)+/
). All parts are joined together and output(ted).
If for some reason the snippet does not display the ASCII art correctly, have a look here.
Happy Deep Dish Pizza Day to everyone!
Python 2, 153 151 bytes
Try it online
n=input()
a=' '*n
b='_'*n
print'/\\__'+b*3+'/\\'
i=0
exec"print' '*i+'\ \\\\'+' '*(3*n-2*i)+'/ /';i+=1;"*n
print a+'\ \\'+b+'/ /'
print a+' \\_'+b+'_/'
-2 bytes by substituting repeated values with variables thanks to @KoishoreRoy