Print me a Tower Block
Mathematica, 301 288 258 bytes
" "~(s=If[#2==0,"",#~StringRepeat~#2]&)~3<>{"="~s~21,"
",s[" ",12-#]<>{")","v "~s~#,"v(
"}&/@9~Range~12,"~"~s~27,"
",s[(x=(u=": ")~s~13<>":
")<>{y=u<>{z=": ### ",v=u~s~5,w=z<>": :
"},y,y,x},#-1],v,"_"~s~7," ",v,"
",m=u<>{z,u,n="I I ",w},m,m,v,n,w}&
Pure function which takes a positive integer and outputs a string. The output string won't look right because Mathematica apparently doesn't display monospace fonts as monospace:
For reasons I don't quite understand, it does format as monospace if you Print
the string:
Edit: Saved several bytes by not including " "
at the beginning of each line. Changed the definition of s
to handle the case where there is only one floor (StringRepeat
doesn't like repeating a string 0
times).
Edit 2: Thanks to LegionMammal978 and the fact that StringJoin
is Listable
, this is now an incomprehensible nightmare of nested lists and also 30 bytes shorter.
V, 72 bytes
13iV r(É)3ñįlxñÄ21r=GÙÒ~Ù14R: ÙÄ2w3r#7w.3ÄkdGÀpG4k5w7r_bêojrIÎfIl5r
Try it online!
Here is a hexdump, since this contains unprintable characters:
00000000: 3133 6956 201b 7228 c929 33f1 c4af 6c78 13iV .r(.)3...lx
00000010: f1c4 3231 723d 47d9 d27e d931 3452 3a20 ..21r=G..~.14R:
00000020: 1bd9 c432 7733 7223 3777 2e33 c46b 6447 ...2w3r#7w.3.kdG
00000030: c070 4734 6b35 7737 725f 1662 ea6f 6a72 .pG4k5w7r_.b.ojr
00000040: 49ce 6649 6c35 7220 I.fIl5r
I ran into a strange bug. The section in the middle: dGÀpG
should have been: ÀäGG
, but this does not work for inputs of 1, and I have no idea why. ¯\_(ツ)_/¯
Python 2, 275 270 262 246 240 236 bytes
Saved a couple with a hint from @Flp.Tkc and by changing the first for loop.
16 saved with more help from @Flp.Tkc
a,h,b,c,w=' ',"I ",": "," :","#"*3;d,e,j=b*2+w+a+b+h,b*5+h,[b*14]
print'\n'.join([a*3+'='*21]+[a*(4-x)+')'+'V '*(x+8)+'V('for x in 1,2,3,4]+['-'*27]+(j+[b*2+w+c*6+a+w+c*2]*3+j)*(input()-1)+[b*5+"_"*7+c*5]+[d+a+d[::-1]]*3+[e+a+e[::-1]])
Try it online!
Just builds each line of the tower as a string and adds it to an array them prints the array at the end. If anyone wants a full explanation I'll grudgingly give if I can remember how it works ☺