예제 #1
0
 def test_case_8(self):
     matrix = [
         [1, 2, 3, 4],
         [10, 11, 12, 5],
         [9, 8, 7, 6],
     ]
     expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
     self.assertEqual(program.spiralTraverse(matrix), expected)
예제 #2
0
 def test_case_7(self):
     matrix = [
         [1, 2, 3, 4],
         [22, 23, 24, 5],
         [21, 36, 25, 6],
         [20, 35, 26, 7],
         [19, 34, 27, 8],
         [18, 33, 28, 9],
         [17, 32, 29, 10],
         [16, 31, 30, 11],
         [15, 14, 13, 12],
     ]
     expected = [
         1,
         2,
         3,
         4,
         5,
         6,
         7,
         8,
         9,
         10,
         11,
         12,
         13,
         14,
         15,
         16,
         17,
         18,
         19,
         20,
         21,
         22,
         23,
         24,
         25,
         26,
         27,
         28,
         29,
         30,
         31,
         32,
         33,
         34,
         35,
         36,
     ]
     self.assertEqual(program.spiralTraverse(matrix), expected)
예제 #3
0
 def test_case_1(self):
     matrix = [[1]]
     expected = [1]
     self.assertEqual(program.spiralTraverse(matrix), expected)
예제 #4
0
 def test_case_4(self):
     matrix = [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6],
               [10, 9, 8, 7]]
     expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
     self.assertEqual(program.spiralTraverse(matrix), expected)
예제 #5
0
 def test_case_3(self):
     matrix = [[1, 2, 3], [8, 9, 4], [7, 6, 5]]
     expected = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     self.assertEqual(program.spiralTraverse(matrix), expected)
예제 #6
0
 def test_case_2(self):
     matrix = [[1, 2], [4, 3]]
     expected = [1, 2, 3, 4]
     self.assertEqual(program.spiralTraverse(matrix), expected)