Skip to content

Commit 9f25653

Browse files
elyssonmrNathan Parsons
authored and
Nathan Parsons
committed
saddle-points: Update the tests following the canonical data (#1048)
* saddle-points: Update the tests following the canonical data
1 parent 0ced099 commit 9f25653

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

exercises/saddle-points/saddle_points_test.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,31 @@
1010
from saddle_points import saddle_points
1111

1212

13+
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
14+
1315
class SaddlePointTest(unittest.TestCase):
1416
def test_one_saddle(self):
1517
inp = [[9, 8, 7], [5, 3, 2], [6, 6, 7]]
1618
self.assertEqual(saddle_points(inp), set([(1, 0)]))
1719

20+
def test_empty_matrix(self):
21+
self.assertEqual(saddle_points([]), set())
22+
1823
def test_no_saddle(self):
19-
self.assertEqual(saddle_points([[2, 1], [1, 2]]), set())
24+
inp = [[1, 2, 3], [3, 1, 2], [2, 3, 1]]
25+
self.assertEqual(saddle_points(inp), set())
2026

2127
def test_mult_saddle(self):
22-
inp = [[5, 3, 5, 4], [6, 4, 7, 3], [5, 1, 5, 3]]
23-
ans = set([(0, 0), (0, 2), (2, 0), (2, 2)])
28+
inp = [[4, 5, 4], [3, 5, 5], [1, 5, 4]]
29+
ans = set([(0, 1), (1, 1), (2, 1)])
2430
self.assertEqual(saddle_points(inp), ans)
2531

26-
def test_empty_matrix(self):
27-
self.assertEqual(saddle_points([]), set())
32+
def test_indentify_saddle_bottom_right_corner(self):
33+
inp = [[8, 7, 9], [6, 7, 6], [3, 2, 5]]
34+
ans = set([(2, 2)])
35+
self.assertEqual(saddle_points(inp), ans)
36+
37+
# Additional tests for this track
2838

2939
def test_irregular_matrix(self):
3040
inp = [[3, 2, 1], [0, 1], [2, 1, 0]]

0 commit comments

Comments
 (0)