fork(5) download
  1. input = [[4,3,2,1], [5,6,7,8], [12,11,10,9], [13,14,15,16]]
  2.  
  3. def f(a,x)a[0]?(x%2==0?a.shift.reverse: a.shift)+f(a,x+1):[]end
  4.  
  5. p f(input,0)
  6.  
Success #stdin #stdout 0s 28216KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]