Skip to content

Commit 8d6f2d3

Browse files
Alexhansrpottsoh
authored andcommitted
saddle-points: Add tests for non-square matrices (NxM) (#1288)
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 8d6f2d3

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

exercises/saddle-points/canonical-data.json

Lines changed: 63 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,67 @@
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
}
121182
]
122-
}
183+
}

exercises/saddle-points/description.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ A matrix may have zero or more saddle points.
2121
Your code should be able to provide the (possibly empty) list of all the
2222
saddle points for any given matrix.
2323

24+
The matrix can have a different number of rows and columns (Non square).
25+
2426
Note that you may find other definitions of matrix saddle points online,
2527
but the tests for this exercise follow the above unambiguous definition.

0 commit comments

Comments
 (0)