Skip to content

Commit c04edf1

Browse files
authored
Sync tournament with problem-specifications (#1437)
* Sync tournament with problem-specifications The sync brought in changes to the docs and tests.toml The example solution failed the new test due to a small formatting difference in the spec. The new test is the first one that shows a score that has double-digits. I updated the example solution to pass the new test, but did not spend any time thinking about how to make the code nice. * Sync tournament docs from problem-specifications The previous sync uncovered a slight mismatch between the instructions and the tests. I submitted a pull request to the problems-specifications repository, which has now been merged. This brings the docs up-to-date with the most recent change there.
1 parent 110bc9e commit c04edf1

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

exercises/practice/tournament/.docs/instructions.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
Tally the results of a small football competition.
44

5-
Based on an input file containing which team played against which and what the
6-
outcome was, create a file with a table like this:
5+
Based on an input file containing which team played against which and what the outcome was, create a file with a table like this:
76

87
```text
98
Team | MP | W | D | L | P
@@ -21,9 +20,12 @@ What do those abbreviations mean?
2120
- L: Matches Lost
2221
- P: Points
2322

24-
A win earns a team 3 points. A draw earns 1. A loss earns 0.
23+
A win earns a team 3 points.
24+
A draw earns 1.
25+
A loss earns 0.
2526

26-
The outcome should be ordered by points, descending. In case of a tie, teams are ordered alphabetically.
27+
The outcome is ordered by points, descending.
28+
In case of a tie, teams are ordered alphabetically.
2729

2830
## Input
2931

@@ -38,7 +40,8 @@ Blithering Badgers;Devastating Donkeys;loss
3840
Allegoric Alaskans;Courageous Californians;win
3941
```
4042

41-
The result of the match refers to the first team listed. So this line:
43+
The result of the match refers to the first team listed.
44+
So this line:
4245

4346
```text
4447
Allegoric Alaskans;Blithering Badgers;win

exercises/practice/tournament/.meta/example.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.tally(input)
4444
stats[:draw],
4545
stats[:loss],
4646
stats[:points]
47-
].join(' | ')
47+
].map {|row| "#{row} ".rjust(4)}.join('|').strip
4848
end
4949

5050
result.join("\n") + "\n"

exercises/practice/tournament/.meta/tests.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ description = "incomplete competition (not all pairs have played)"
4141

4242
[3aa0386f-150b-4f99-90bb-5195e7b7d3b8]
4343
description = "ties broken alphabetically"
44+
45+
[f9e20931-8a65-442a-81f6-503c0205b17a]
46+
description = "ensure points sorted numerically"

exercises/practice/tournament/tournament_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,23 @@ def test_ties_broken_alphabetically
188188

189189
assert_equal expected, Tournament.tally(input)
190190
end
191+
192+
def test_ensure_points_sorted_numerically
193+
skip
194+
input = <<~INPUT
195+
Devastating Donkeys;Blithering Badgers;win
196+
Devastating Donkeys;Blithering Badgers;win
197+
Devastating Donkeys;Blithering Badgers;win
198+
Devastating Donkeys;Blithering Badgers;win
199+
Blithering Badgers;Devastating Donkeys;win
200+
INPUT
201+
202+
expected = <<~TALLY
203+
Team | MP | W | D | L | P
204+
Devastating Donkeys | 5 | 4 | 0 | 1 | 12
205+
Blithering Badgers | 5 | 1 | 0 | 4 | 3
206+
TALLY
207+
208+
assert_equal expected, Tournament.tally(input)
209+
end
191210
end

0 commit comments

Comments
 (0)