Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6) 272 277 271

JavaScript (ES6) 272 277 271

Edit bug fix

Edit 2 saved 6 bytes thx @L.Serné

Edit 3 bug fix again

(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(a='|_   _| (_) ';--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(a='|_   _| (_) ';--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=2 oninput='update()' type=number min=2>
H<input id=H value=2 oninput='update()' type=number min=2>
<pre id=O></pre>

#JavaScript (ES6) 272 277 271

Edit bug fix

Edit 2 saved 6 bytes thx @L.Serné

Edit 3 bug fix again

(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(a='|_   _| (_) ';--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(a='|_   _| (_) ';--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=2 oninput='update()' type=number min=2>
H<input id=H value=2 oninput='update()' type=number min=2>
<pre id=O></pre>

JavaScript (ES6) 272 277 271

Edit bug fix

Edit 2 saved 6 bytes thx @L.Serné

Edit 3 bug fix again

(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(a='|_   _| (_) ';--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(a='|_   _| (_) ';--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=2 oninput='update()' type=number min=2>
H<input id=H value=2 oninput='update()' type=number min=2>
<pre id=O></pre>

added 26 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6) 271272 277 271

Edit bug fix

Edit 2 saved 6 bytes thx @L.Serné

Edit 3 bug fix again

(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='|_   _| (_) '';--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='|_   _| (_) '';--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(+ww,+hh)
}

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

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

#JavaScript (ES6) 272 277 271

Edit bug fix

Edit 2 saved 6 bytes thx @L.Serné

Edit 3 bug fix again

(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(a='|_   _| (_) ';--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(a='|_   _| (_) ';--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=2 oninput='update()' type=number min=2>
H<input id=H value=2 oninput='update()' type=number min=2>
<pre id=O></pre>

added 32 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6) 277271 271277 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),a='|_   _| (_) ',b=' _) (_   _  ',c='|_   _|_( )_')=>eval("t=z(' _____',0,0)+z('|_   _|     ',2,--h)+z(bb=' _) (_   _  ')+z(cc='|_   _|_( )_',0);for(;--h;)t+=z(aa='|_   _| (_) ',2)+z(b)+z(c,0)")+z(a,2)+z(' _) (_      ')+z('|_____',1)
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),a='|_   _| (_) ',b=' _) (_   _  ',c='|_   _|_( )_')=>eval("t=z(' _____',0,0)+z('|_   _|     ',2,--h)+z(bb=' _) (_   _  ')+z(cc='|_   _|_( )_',0);for(;--h;)t+=z(aa='|_   _| (_) ',2)+z(b)+z(c,0)")+z(a,2)+z(' _) (_      ')+z('|_____',1)

function update() {
  var i=Iw=+W.value.match(/\d+/g)
  if (i)
  { 
    [w,h]=i
    if (+w>1 & +h>1)h=+H.value
      O.textContent=F(+w,+h)
  }
}

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

#JavaScript (ES6) 277 271

Edit bug fix

(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),a='|_   _| (_) ',b=' _) (_   _  ',c='|_   _|_( )_')=>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)
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),a='|_   _| (_) ',b=' _) (_   _  ',c='|_   _|_( )_')=>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 i=I.value.match(/\d+/g)
  if (i)
  { 
    [w,h]=i
    if (+w>1 & +h>1)
      O.textContent=F(+w,+h)
  }
}

update()
<input id=I value='3 4' oninput='update()'>
<pre id=O></pre>

#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)
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>
added 47 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading
added 44 characters in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90
Loading