From 985d8fcc79b3b333862d7609168c254e4bcc1ba0 Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 22:33:52 +0200 Subject: [PATCH 1/8] Synced metadata and docs --- .../practice/tournament/.docs/instructions.md | 13 ++++-- .../practice/tournament/.meta/tests.toml | 46 +++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 exercises/practice/tournament/.meta/tests.toml diff --git a/exercises/practice/tournament/.docs/instructions.md b/exercises/practice/tournament/.docs/instructions.md index 8831dd195..e5ca23738 100644 --- a/exercises/practice/tournament/.docs/instructions.md +++ b/exercises/practice/tournament/.docs/instructions.md @@ -2,8 +2,7 @@ Tally the results of a small football competition. -Based on an input file containing which team played against which and what the -outcome was, create a file with a table like this: +Based on an input file containing which team played against which and what the outcome was, create a file with a table like this: ```text Team | MP | W | D | L | P @@ -21,9 +20,12 @@ What do those abbreviations mean? - L: Matches Lost - P: Points -A win earns a team 3 points. A draw earns 1. A loss earns 0. +A win earns a team 3 points. +A draw earns 1. +A loss earns 0. -The outcome should be ordered by points, descending. In case of a tie, teams are ordered alphabetically. +The outcome is ordered by points, descending. +In case of a tie, teams are ordered alphabetically. ## Input @@ -38,7 +40,8 @@ Blithering Badgers;Devastating Donkeys;loss Allegoric Alaskans;Courageous Californians;win ``` -The result of the match refers to the first team listed. So this line: +The result of the match refers to the first team listed. +So this line: ```text Allegoric Alaskans;Blithering Badgers;win diff --git a/exercises/practice/tournament/.meta/tests.toml b/exercises/practice/tournament/.meta/tests.toml new file mode 100644 index 000000000..0e33c87fc --- /dev/null +++ b/exercises/practice/tournament/.meta/tests.toml @@ -0,0 +1,46 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[67e9fab1-07c1-49cf-9159-bc8671cc7c9c] +description = "just the header if no input" + +[1b4a8aef-0734-4007-80a2-0626178c88f4] +description = "a win is three points, a loss is zero points" + +[5f45ac09-4efe-46e7-8ddb-75ad85f86e05] +description = "a win can also be expressed as a loss" + +[fd297368-efa0-442d-9f37-dd3f9a437239] +description = "a different team can win" + +[26c016f9-e753-4a93-94e9-842f7b4d70fc] +description = "a draw is one point each" + +[731204f6-4f34-4928-97eb-1c307ba83e62] +description = "There can be more than one match" + +[49dc2463-42af-4ea6-95dc-f06cc5776adf] +description = "There can be more than one winner" + +[6d930f33-435c-4e6f-9e2d-63fa85ce7dc7] +description = "There can be more than two teams" + +[97022974-0c8a-4a50-8fe7-e36bdd8a5945] +description = "typical input" + +[fe562f0d-ac0a-4c62-b9c9-44ee3236392b] +description = "incomplete competition (not all pairs have played)" + +[3aa0386f-150b-4f99-90bb-5195e7b7d3b8] +description = "ties broken alphabetically" + +[f9e20931-8a65-442a-81f6-503c0205b17a] +description = "ensure points sorted numerically" From 4987c1043a20f9bd6335ffd1f387aecdfcee11c6 Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 22:34:59 +0200 Subject: [PATCH 2/8] Removed strict types comments --- .../practice/tournament/.meta/example.php | 22 ------------------- .../practice/tournament/TournamentTest.php | 22 ------------------- 2 files changed, 44 deletions(-) diff --git a/exercises/practice/tournament/.meta/example.php b/exercises/practice/tournament/.meta/example.php index f5da28e82..a6aa51566 100644 --- a/exercises/practice/tournament/.meta/example.php +++ b/exercises/practice/tournament/.meta/example.php @@ -1,27 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); class Tournament diff --git a/exercises/practice/tournament/TournamentTest.php b/exercises/practice/tournament/TournamentTest.php index 1b107ed87..a64a01efa 100644 --- a/exercises/practice/tournament/TournamentTest.php +++ b/exercises/practice/tournament/TournamentTest.php @@ -1,27 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); use PHPUnit\Framework\TestCase; From eafdf095e965b4038a89ccfca4796fbbadbcb2bd Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 22:36:17 +0200 Subject: [PATCH 3/8] Added tournament to `auto-sync.txt` --- bin/auto-sync.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/auto-sync.txt b/bin/auto-sync.txt index 80215b859..0bb1ef8de 100644 --- a/bin/auto-sync.txt +++ b/bin/auto-sync.txt @@ -91,6 +91,7 @@ state-of-tic-tac-toe strain sublist swift-scheduling +tournament triangle twelve-days two-bucket From 1ab71c120d23c0f2688b47e177c77e66fa84e25e Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 22:37:47 +0200 Subject: [PATCH 4/8] Added GitHub handle to `config.json` --- exercises/practice/tournament/.meta/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/practice/tournament/.meta/config.json b/exercises/practice/tournament/.meta/config.json index 404e75dfb..3b7d54413 100644 --- a/exercises/practice/tournament/.meta/config.json +++ b/exercises/practice/tournament/.meta/config.json @@ -3,7 +3,8 @@ "MichaelBunker" ], "contributors": [ - "dstockto" + "dstockto", + "resu-xuniL" ], "files": { "solution": [ From 97ac2431b7a9bbe22ce72e00b9af04b9635d2f4d Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 23:17:42 +0200 Subject: [PATCH 5/8] Added UUID and TestDox to tests --- .../practice/tournament/TournamentTest.php | 80 +++++++++++++++++-- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/exercises/practice/tournament/TournamentTest.php b/exercises/practice/tournament/TournamentTest.php index a64a01efa..025998c0a 100644 --- a/exercises/practice/tournament/TournamentTest.php +++ b/exercises/practice/tournament/TournamentTest.php @@ -3,6 +3,7 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\TestDox; class TournamentTest extends TestCase { @@ -18,14 +19,22 @@ protected function setUp(): void $this->tournament = new Tournament(); } - public function testHeaderOnlyNoTeams(): void + /** + * uuid: 67e9fab1-07c1-49cf-9159-bc8671cc7c9c + */ + #[TestDox('just the header if no input')] + public function testJustTheHeaderIfNoInput(): void { $scores = ''; $expected = 'Team | MP | W | D | L | P'; $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testWinIsThreePointsLossIsZeroPoints(): void + /** + * uuid: 1b4a8aef-0734-4007-80a2-0626178c88f4 + */ + #[TestDox('a win is three points, a loss is zero points')] + public function testAWinIsThreePointsALossIsZeroPoints(): void { $scores = 'Allegoric Alaskans;Blithering Badgers;win'; $expected = @@ -35,7 +44,11 @@ public function testWinIsThreePointsLossIsZeroPoints(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testWinCanAlsoBeExpressedAsALoss(): void + /** + * uuid: 5f45ac09-4efe-46e7-8ddb-75ad85f86e05 + */ + #[TestDox('a win can also be expressed as a loss')] + public function testAWinCanAlsoBeExpressedAsALoss(): void { $scores = 'Blithering Badgers;Allegoric Alaskans;loss'; $expected = @@ -45,7 +58,11 @@ public function testWinCanAlsoBeExpressedAsALoss(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testDifferentTeamsCanWin(): void + /** + * uuid: fd297368-efa0-442d-9f37-dd3f9a437239 + */ + #[TestDox('a different team can win')] + public function testADifferentTeamCanWin(): void { $scores = 'Blithering Badgers;Allegoric Alaskans;win'; $expected = @@ -55,6 +72,10 @@ public function testDifferentTeamsCanWin(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } + /** + * uuid: 26c016f9-e753-4a93-94e9-842f7b4d70fc + */ + #[TestDox('a draw is one point each')] public function testADrawIsOnePointEach(): void { $scores = 'Allegoric Alaskans;Blithering Badgers;draw'; @@ -65,7 +86,11 @@ public function testADrawIsOnePointEach(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testThereCanBeMultipleMatches(): void + /** + * uuid: 731204f6-4f34-4928-97eb-1c307ba83e62 + */ + #[TestDox('There can be more than one match')] + public function testThereCanBeMoreThanOneMatch(): void { $scores = "Allegoric Alaskans;Blithering Badgers;win\n" . @@ -77,6 +102,10 @@ public function testThereCanBeMultipleMatches(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } + /** + * uuid: 49dc2463-42af-4ea6-95dc-f06cc5776adf + */ + #[TestDox('There can be more than one winner')] public function testThereCanBeMoreThanOneWinner(): void { $scores = @@ -89,6 +118,10 @@ public function testThereCanBeMoreThanOneWinner(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } + /** + * uuid: 6d930f33-435c-4e6f-9e2d-63fa85ce7dc7 + */ + #[TestDox('There can be more than two teams')] public function testThereCanBeMoreThanTwoTeams(): void { $scores = @@ -103,7 +136,11 @@ public function testThereCanBeMoreThanTwoTeams(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testStandardInput(): void + /** + * uuid: 97022974-0c8a-4a50-8fe7-e36bdd8a5945 + */ + #[TestDox('typical input')] + public function testTypicalInput(): void { $scores = "Allegoric Alaskans;Blithering Badgers;win\n" . @@ -121,7 +158,11 @@ public function testStandardInput(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testIncompleteCompetitionWhereNotAllGamesPlayed(): void + /** + * uuid: fe562f0d-ac0a-4c62-b9c9-44ee3236392b + */ + #[TestDox('incomplete competition (not all pairs have played)')] + public function testIncompleteCompetitionNotAllPairsHavePlayed(): void { $scores = "Allegoric Alaskans;Blithering Badgers;loss\n" . @@ -137,7 +178,11 @@ public function testIncompleteCompetitionWhereNotAllGamesPlayed(): void $this->assertEquals($expected, $this->tournament->tally($scores)); } - public function testTiesSortedAlphabetically(): void + /** + * uuid: 3aa0386f-150b-4f99-90bb-5195e7b7d3b8 + */ + #[TestDox('ties broken alphabetically')] + public function testTiesBrokenAlphabetically(): void { $scores = "Courageous Californians;Devastating Donkeys;win\n" . @@ -154,4 +199,23 @@ public function testTiesSortedAlphabetically(): void "Devastating Donkeys | 3 | 0 | 1 | 2 | 1"; $this->assertEquals($expected, $this->tournament->tally($scores)); } + + /** + * uuid: f9e20931-8a65-442a-81f6-503c0205b17a + */ + #[TestDox('ensure points sorted numerically')] + public function testEnsurePointsSortedNumerically(): void + { + $scores = + "Devastating Donkeys;Blithering Badgers;win\n" . + "Devastating Donkeys;Blithering Badgers;win\n" . + "Devastating Donkeys;Blithering Badgers;win\n" . + "Devastating Donkeys;Blithering Badgers;win\n" . + "Blithering Badgers;Devastating Donkeys;win"; + $expected = + "Team | MP | W | D | L | P\n" . + "Devastating Donkeys | 5 | 4 | 0 | 1 | 12\n" . + "Blithering Badgers | 5 | 1 | 0 | 4 | 3"; + $this->assertEquals($expected, $this->tournament->tally($scores)); + } } From ab98cbc334b444195faf52bc790a4f1fd4316376 Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 23:18:58 +0200 Subject: [PATCH 6/8] fix `example.php` to pass new test unit --- exercises/practice/tournament/.meta/example.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/tournament/.meta/example.php b/exercises/practice/tournament/.meta/example.php index a6aa51566..5a4cd07d5 100644 --- a/exercises/practice/tournament/.meta/example.php +++ b/exercises/practice/tournament/.meta/example.php @@ -5,7 +5,7 @@ class Tournament { private string $header = "Team | MP | W | D | L | P\n"; - private string $teamRow = "%s | %d | %d | %d | %d | %d\n"; + private string $teamRow = "%s |%3d |%3d |%3d |%3d |%3d\n"; public function tally(string $scores): string { From 8bf837fa33245235bae3f2cd4dd2749759e80e28 Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 23:21:13 +0200 Subject: [PATCH 7/8] Change difficulty to 4 --- config.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config.json b/config.json index 8f612eda4..39af61436 100644 --- a/config.json +++ b/config.json @@ -969,18 +969,6 @@ "prerequisites": [], "difficulty": 3 }, - { - "slug": "tournament", - "name": "Tournament", - "uuid": "e0572cf4-5481-4da4-bf9b-0e921cb81627", - "practices": [], - "prerequisites": [], - "difficulty": 3, - "topics": [ - "parsing", - "strings" - ] - }, { "slug": "bob", "name": "Bob", @@ -1138,6 +1126,18 @@ "prerequisites": [], "difficulty": 4 }, + { + "slug": "tournament", + "name": "Tournament", + "uuid": "e0572cf4-5481-4da4-bf9b-0e921cb81627", + "practices": [], + "prerequisites": [], + "difficulty": 4, + "topics": [ + "parsing", + "strings" + ] + }, { "slug": "alphametics", "name": "Alphametics", From a8ec006b14691fef83f3564f0681848679b4e84a Mon Sep 17 00:00:00 2001 From: resu-xuniL Date: Mon, 6 Jul 2026 23:25:03 +0200 Subject: [PATCH 8/8] Harmonise textdox (capitalise first word) --- .../practice/tournament/TournamentTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/practice/tournament/TournamentTest.php b/exercises/practice/tournament/TournamentTest.php index 025998c0a..098b24874 100644 --- a/exercises/practice/tournament/TournamentTest.php +++ b/exercises/practice/tournament/TournamentTest.php @@ -22,7 +22,7 @@ protected function setUp(): void /** * uuid: 67e9fab1-07c1-49cf-9159-bc8671cc7c9c */ - #[TestDox('just the header if no input')] + #[TestDox('Just the header if no input')] public function testJustTheHeaderIfNoInput(): void { $scores = ''; @@ -33,7 +33,7 @@ public function testJustTheHeaderIfNoInput(): void /** * uuid: 1b4a8aef-0734-4007-80a2-0626178c88f4 */ - #[TestDox('a win is three points, a loss is zero points')] + #[TestDox('A win is three points, a loss is zero points')] public function testAWinIsThreePointsALossIsZeroPoints(): void { $scores = 'Allegoric Alaskans;Blithering Badgers;win'; @@ -47,7 +47,7 @@ public function testAWinIsThreePointsALossIsZeroPoints(): void /** * uuid: 5f45ac09-4efe-46e7-8ddb-75ad85f86e05 */ - #[TestDox('a win can also be expressed as a loss')] + #[TestDox('A win can also be expressed as a loss')] public function testAWinCanAlsoBeExpressedAsALoss(): void { $scores = 'Blithering Badgers;Allegoric Alaskans;loss'; @@ -61,7 +61,7 @@ public function testAWinCanAlsoBeExpressedAsALoss(): void /** * uuid: fd297368-efa0-442d-9f37-dd3f9a437239 */ - #[TestDox('a different team can win')] + #[TestDox('A different team can win')] public function testADifferentTeamCanWin(): void { $scores = 'Blithering Badgers;Allegoric Alaskans;win'; @@ -75,7 +75,7 @@ public function testADifferentTeamCanWin(): void /** * uuid: 26c016f9-e753-4a93-94e9-842f7b4d70fc */ - #[TestDox('a draw is one point each')] + #[TestDox('A draw is one point each')] public function testADrawIsOnePointEach(): void { $scores = 'Allegoric Alaskans;Blithering Badgers;draw'; @@ -139,7 +139,7 @@ public function testThereCanBeMoreThanTwoTeams(): void /** * uuid: 97022974-0c8a-4a50-8fe7-e36bdd8a5945 */ - #[TestDox('typical input')] + #[TestDox('Typical input')] public function testTypicalInput(): void { $scores = @@ -161,7 +161,7 @@ public function testTypicalInput(): void /** * uuid: fe562f0d-ac0a-4c62-b9c9-44ee3236392b */ - #[TestDox('incomplete competition (not all pairs have played)')] + #[TestDox('Incomplete competition (not all pairs have played)')] public function testIncompleteCompetitionNotAllPairsHavePlayed(): void { $scores = @@ -181,7 +181,7 @@ public function testIncompleteCompetitionNotAllPairsHavePlayed(): void /** * uuid: 3aa0386f-150b-4f99-90bb-5195e7b7d3b8 */ - #[TestDox('ties broken alphabetically')] + #[TestDox('Ties broken alphabetically')] public function testTiesBrokenAlphabetically(): void { $scores = @@ -203,7 +203,7 @@ public function testTiesBrokenAlphabetically(): void /** * uuid: f9e20931-8a65-442a-81f6-503c0205b17a */ - #[TestDox('ensure points sorted numerically')] + #[TestDox('Ensure points sorted numerically')] public function testEnsurePointsSortedNumerically(): void { $scores =