예제 #1
0
 def test_spiral_traversal(self):
     self.assertEqual(spiral_traversal.spiral_traversal(
         [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [1, 2, 3, 6, 9, 8, 7, 4, 5])
예제 #2
0
 def test_spiral_traversal(self):
     self.assertEqual(spiral_traversal.spiral_traversal(
         [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [1, 2, 3, 6, 9, 8, 7, 4, 5])
예제 #3
0
"""
Given a matrix of m x n elements (m rows, n columns),
return all elements of the matrix in spiral order.
For example,
Given the following matrix:
[
 [ 1, 2, 3 ],
 [ 4, 5, 6 ],
 [ 7, 8, 9 ]
]
You should return [1,2,3,6,9,8,7,4,5].
"""
from algorithms.matrix.spiral_traversal import spiral_traversal


a=[
    [ 1, 2, 3 ],
    [ 4, 5, 6 ],
    [ 7, 8, 9 ]
]


print(spiral_traversal(a))