fork(1) download
  1. f = ->w,h{s="%d%d"%[w,h]*q=w+h;a=[s[0,w]];(h-2).times{|i|a<<(s[2*q-5-i].ljust(w-1)+s[w+i,1])[-w,w]};puts a,h>1?(s[q-2,w].reverse):p}
  2.  
  3. f.call(4,4)
  4. f.call(10,3)
  5. f.call(1,1)
  6. f.call(23,1)
  7. f.call(1,17)
Success #stdin #stdout 0.02s 9776KB
stdin
Standard input is empty
stdout
4444
4  4
4  4
4444
1031031031
1        0
3013013013
1

23123123123123123123123

1
1
7
1
1
7
1
1
7
1
1
7
1
1
7
1
1