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