Skip to content

saddle-points: Add tests for non-square matrices (NxM) #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions exercises/saddle-points/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"exercise": "saddle-points",
"version": "1.2.0",
"version": "1.3.0",
"comments": [
"Matrix rows and columns are 0-indexed."
],
Expand Down Expand Up @@ -117,6 +117,67 @@
"column": 2
}
]
},
{
"description": "Can identify saddle points in a non square matrix",
"property": "saddlePoints",
"input": {
"matrix": [
[3, 1, 3],
[3, 2, 4]
]
},
"expected": [
{
"row": 0,
"column": 2
},
{
"row": 0,
"column": 0
}
]
},
{
"description": "Can identify that saddle points in a single column matrix are those with the minimum value",
"property": "saddlePoints",
"input": {
"matrix": [
[2],
[1],
[4],
[1]
]
},
"expected": [
{
"row": 1,
"column": 0
},
{
"row": 3,
"column": 0
}
]
},
{
"description": "Can identify that saddle points in a single row matrix are those with the maximum value",
"property": "saddlePoints",
"input": {
"matrix": [
[2, 5, 3, 5]
]
},
"expected": [
{
"row": 0,
"column": 1
},
{
"row": 0,
"column": 3
}
]
}
]
}
}
2 changes: 2 additions & 0 deletions exercises/saddle-points/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ A matrix may have zero or more saddle points.
Your code should be able to provide the (possibly empty) list of all the
saddle points for any given matrix.

The matrix can have a different number of rows and columns (Non square).

Note that you may find other definitions of matrix saddle points online,
but the tests for this exercise follow the above unambiguous definition.