-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refactor exercises to match canonical data #1762
Description
There are a number of exercises that fall into one of the following cases:
Function names that differ from those specified in the canonical data
armstrong-numbers uses is_armstrong instead of is_armstrong_number:
python/exercises/armstrong-numbers/example.py
Lines 1 to 2 in 222c029
| def is_armstrong(number): | |
| return sum(pow(int(d), len(str(number))) for d in str(number)) == number |
From the canonical-data:
{
"description": "Zero is an Armstrong number",
"property": "isArmstrongNumber",
"input": {
"number": 0
},
"expected": true
},
*Note: in these cases, the camelCase names used in the canonical data should be converted to snake_case names in the tests, example solution, and solution stub.
Test input format differs from canonical data
tournament passes a multiline string instead of a list of single-line strings.
python/exercises/tournament/tournament_test.py
Lines 51 to 57 in 222c029
| def test_there_can_be_more_than_one_winner(self): | |
| results = ('Allegoric Alaskans;Blithering Badgers;loss\n' | |
| 'Allegoric Alaskans;Blithering Badgers;win') | |
| table = ('Team | MP | W | D | L | P\n' | |
| 'Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n' | |
| 'Blithering Badgers | 2 | 1 | 0 | 1 | 3') | |
| self.assertEqual(tally(results), table) |
From the canonical-data:
{
"description": "There can be more than one winner",
"property": "tally",
"input": {
"rows": [
"Allegoric Alaskans;Blithering Badgers;loss",
"Allegoric Alaskans;Blithering Badgers;win"
]
},
"expected": [
"Team | MP | W | D | L | P",
"Allegoric Alaskans | 2 | 1 | 0 | 1 | 3",
"Blithering Badgers | 2 | 1 | 0 | 1 | 3"
]
},
Test output format differs from canonical data
saddle-points expects a set of tuples instead of a list of dict objects
python/exercises/saddle-points/saddle_points_test.py
Lines 16 to 18 in 222c029
| def test_identify_single_saddle_point(self): | |
| matrix = [[9, 8, 7], [5, 3, 2], [6, 6, 7]] | |
| self.assertEqual(saddle_points(matrix), set([(2, 1)])) |
From the canonical-data:
{
"description": "Can identify single saddle point",
"comments": [
"This is the README example."
],
"property": "saddlePoints",
"input": {
"matrix": [
[9, 8, 7],
[5, 3, 2],
[6, 6, 7]
]
},
"expected": [
{
"row": 2,
"column": 1
}
]
},
Test input order differs from canonical data
change uses the order target, coins instead of coins, target
python/exercises/change/change_test.py
Lines 9 to 10 in 222c029
| def test_single_coin_change(self): | |
| self.assertEqual(find_minimum_coins(25, [1, 5, 10, 25, 100]), [25]) |
From the canonical-data:
{
"description": "single coin change",
"property": "findFewestCoins",
"input": {
"coins": [1, 5, 10, 25, 100],
"target": 25
},
"expected": [25]
},
In an effort to simplify the job of the WIP test generator, it would be beneficial to reduce these inconsistencies now, so that it does not become the job of the generator PR to correct example solutions and stubs that do not match newly generated tests.
Here is the full list of exercises in which this occurs
- alphametics
- armstrong-numbers
- binary-search
- bob
- book-store
- change
- collatz-conjecture
- crypto-square
- diamond
- difference-of-squares
- dominoes
- gigasecond
- grains
- grep
- isbn-verifier
- knapsack
- leap
- list-ops
- markdown
- meetup
- minesweeper
- nth-prime
- palindrome-products
- prime-factors
- pythagorean-triplet
- raindrops
- rectangles
- roman-numerals
- saddle-points
- secret-handshake
- sieve
- spiral-matrix
- sublist
-
sum-of-multiples(foregoing updates for now) - tournament
- transpose
- triangle
- two-fer
- word-count
- wordy
- yacht
This issue may be considered resolved once all of the above issues have been updated to match the canonical properties.