Skip to main content
4 of 6
added 32 characters in body
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6) 271 277 271

Edit bug fix

Edit 2 saved 6 bytes thx @L.Serné

(w,h,z=(s,q=3,i=h)=>'|  '.slice(0,q)+s.repeat(w).substr(i%2*6+q,w*6-q-~-q)+`  |
`.slice(~q))=>eval("t=z(' _____',0,0)+z('|_   _|     ',2,--h)+z(b=' _) (_   _  ')+z(c='|_   _|_( )_',0);for(;--h;)t+=z(a='|_   _| (_) ',2)+z(b)+z(c,0)")+z(a,2)+z(' _) (_      ')+z('|_____',1)

Less golfed

(w,h,
  z=(s,q=3,i=h)=>'|  '.slice(0,q)+s.repeat(w).substr(i%2*6+q,w*6-q-~-q)+'  |\n'.slice(~q),
  a='|_   _| (_) ',
  b=' _) (_   _  ',
  c='|_   _|_( )_',
  t=z(' _____',0,0)+z('|_   _|     ',2,--h)+z(b)+z(c,0)
)=>{
  for(;--h;)
    t+=z(a,2)+z(b)+z(c,0);
  return t+z(a,2)+z(' _) (_      ')+z('|_____',1)
}

Test

F=
(w,h,z=(s,q=3,i=h)=>'|  '.slice(0,q)+s.repeat(w).substr(i%2*6+q,w*6-q-~-q)+`  |
`.slice(~q))=>eval("t=z(' _____',0,0)+z('|_   _|     ',2,--h)+z(b=' _) (_   _  ')+z(c='|_   _|_( )_',0);for(;--h;)t+=z(a='|_   _| (_) ',2)+z(b)+z(c,0)")+z(a,2)+z(' _) (_      ')+z('|_____',1)

function update() {
  var w=+W.value,h=+H.value
  O.textContent=F(+w,+h)
}

update()
W<input id=W value=3 oninput='update()' type=number min=2>
H<input id=H value=4 oninput='update()' type=number min=2>
<pre id=O></pre>

edc65
  • 32.2k
  • 3
  • 36
  • 90