Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test_4 = [[1,2,3,4],[11,12,13,14],[21,22,23,24],[31,32,33,34]]
- test_3 = [[1,2,3],[4,5,6],[7,8,9]]
- test_result = [[1, 5, 9], [2, 6],[4,8], [3],[7]]
- def diags(a)
- ret = []
- size = a.size
- size.times{|z|
- x = []
- w = []
- (size-z).times{|y|
- x << a[y+z][y]
- w << a[z-y][z-y+1]
- }
- if z != 0
- ret << w
- end
- ret << x
- }
- return ret
- end
- puts "#{diags c}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement