Skip to content

Commit 2452725

Browse files
committed
saddle-points: Add tests for non-square matrices
There's no indication in the description that non square matrices (NxM) are not covered in the provided saddle points definition. Now the tests reflect that.
1 parent dc9a5af commit 2452725

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

exercises/saddle-points/canonical-data.json

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"exercise": "saddle-points",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"comments": [
55
"Matrix rows and columns are 0-indexed."
66
],
@@ -117,6 +117,68 @@
117117
"column": 2
118118
}
119119
]
120+
},
121+
{
122+
"description": "Can identify saddle points in a non square matrix",
123+
"property": "saddlePoints",
124+
"input": {
125+
"matrix": [
126+
[3, 1, 3],
127+
[3, 2, 4]
128+
]
129+
},
130+
"expected": [
131+
{
132+
"row": 0,
133+
"column": 2
134+
},
135+
{
136+
"row": 0,
137+
"column": 0
138+
}
139+
]
140+
},
141+
{
142+
"description": "Can identify that saddle points in a single column matrix are those with the minimum value",
143+
"property": "saddlePoints",
144+
"input": {
145+
"matrix": [
146+
[2],
147+
[1],
148+
[4],
149+
[1]
150+
]
151+
},
152+
"expected": [
153+
{
154+
"row": 1,
155+
"column": 0
156+
},
157+
{
158+
"row": 3,
159+
"column": 0
160+
}
161+
]
162+
},
163+
{
164+
"description": "Can identify that saddle points in a single row matrix are those with the maximum value",
165+
"property": "saddlePoints",
166+
"input": {
167+
"matrix": [
168+
[2, 5, 3, 5]
169+
]
170+
},
171+
"expected": [
172+
{
173+
"row": 0,
174+
"column": 1
175+
},
176+
{
177+
"row": 0,
178+
"column": 3
179+
}
180+
]
120181
}
182+
121183
]
122-
}
184+
}

0 commit comments

Comments
 (0)