From d5ec646848dd40d5ebc263f9326d4e8a98264063 Mon Sep 17 00:00:00 2001 From: mk-mxp <55182845+mk-mxp@users.noreply.github.com> Date: Sun, 7 Apr 2024 16:06:29 +0200 Subject: [PATCH] Sync scrabble score (#680) [no important files changed] --- .../scrabble-score/.docs/instructions.md | 47 ++++++---------- .../scrabble-score/.docs/introduction.md | 7 +++ .../practice/scrabble-score/.meta/config.json | 3 +- .../practice/scrabble-score/.meta/example.php | 22 -------- .../scrabble-score/ScrabbleScoreTest.php | 55 ++++++++----------- 5 files changed, 47 insertions(+), 87 deletions(-) create mode 100644 exercises/practice/scrabble-score/.docs/introduction.md diff --git a/exercises/practice/scrabble-score/.docs/instructions.md b/exercises/practice/scrabble-score/.docs/instructions.md index 3f986c94..738f928c 100644 --- a/exercises/practice/scrabble-score/.docs/instructions.md +++ b/exercises/practice/scrabble-score/.docs/instructions.md @@ -1,40 +1,25 @@ # Instructions -Given a word, compute the Scrabble score for that word. +Your task is to compute a word's Scrabble score by summing the values of its letters. -## Letter Values +The letters are valued as follows: -You'll need these: +| Letter | Value | +| ---------------------------- | ----- | +| A, E, I, O, U, L, N, R, S, T | 1 | +| D, G | 2 | +| B, C, M, P | 3 | +| F, H, V, W, Y | 4 | +| K | 5 | +| J, X | 8 | +| Q, Z | 10 | -```text -Letter Value -A, E, I, O, U, L, N, R, S, T 1 -D, G 2 -B, C, M, P 3 -F, H, V, W, Y 4 -K 5 -J, X 8 -Q, Z 10 -``` - -## Examples - -"cabbage" should be scored as worth 14 points: +For example, the word "cabbage" is worth 14 points: - 3 points for C -- 1 point for A, twice -- 3 points for B, twice +- 1 point for A +- 3 points for B +- 3 points for B +- 1 point for A - 2 points for G - 1 point for E - -And to total: - -- `3 + 2*1 + 2*3 + 2 + 1` -- = `3 + 2 + 6 + 3` -- = `5 + 9` -- = 14 - -## Extensions - -- You can play a double or a triple letter. -- You can play a double or a triple word. diff --git a/exercises/practice/scrabble-score/.docs/introduction.md b/exercises/practice/scrabble-score/.docs/introduction.md new file mode 100644 index 00000000..8821f240 --- /dev/null +++ b/exercises/practice/scrabble-score/.docs/introduction.md @@ -0,0 +1,7 @@ +# Introduction + +[Scrabble][wikipedia] is a word game where players place letter tiles on a board to form words. +Each letter has a value. +A word's score is the sum of its letters' values. + +[wikipedia]: https://en.wikipedia.org/wiki/Scrabble diff --git a/exercises/practice/scrabble-score/.meta/config.json b/exercises/practice/scrabble-score/.meta/config.json index 39fca361..b0358f64 100644 --- a/exercises/practice/scrabble-score/.meta/config.json +++ b/exercises/practice/scrabble-score/.meta/config.json @@ -6,7 +6,8 @@ "arueckauer", "kunicmarko20", "kytrinyx", - "petemcfarlane" + "petemcfarlane", + "mk-mxp" ], "files": { "solution": [ diff --git a/exercises/practice/scrabble-score/.meta/example.php b/exercises/practice/scrabble-score/.meta/example.php index 072ff3ef..9df33e2e 100644 --- a/exercises/practice/scrabble-score/.meta/example.php +++ b/exercises/practice/scrabble-score/.meta/example.php @@ -1,27 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); function score($word) diff --git a/exercises/practice/scrabble-score/ScrabbleScoreTest.php b/exercises/practice/scrabble-score/ScrabbleScoreTest.php index e4e2f7f6..2019152b 100644 --- a/exercises/practice/scrabble-score/ScrabbleScoreTest.php +++ b/exercises/practice/scrabble-score/ScrabbleScoreTest.php @@ -1,27 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); /** @@ -35,7 +13,8 @@ public static function setUpBeforeClass(): void } /** - * Test lowercase single letter word. + * uuid f46cda29-1ca5-4ef2-bd45-388a767e3db2 + * @testdox Lowercase letter */ public function testLowercaseSingleLetter(): void { @@ -44,7 +23,8 @@ public function testLowercaseSingleLetter(): void } /** - * Test uppercase single letter word. + * uuid f7794b49-f13e-45d1-a933-4e48459b2201 + * @testdox Uppercase letter */ public function testUppercaseSingleLetter(): void { @@ -53,7 +33,8 @@ public function testUppercaseSingleLetter(): void } /** - * Test valuable single letter word. + * uuid eaba9c76-f9fa-49c9-a1b0-d1ba3a5b31fa + * @testdox Valuable letter */ public function testValuableSingleLetter(): void { @@ -62,7 +43,8 @@ public function testValuableSingleLetter(): void } /** - * Test short word. + * uuid f3c8c94e-bb48-4da2-b09f-e832e103151e + * @testdox Short word */ public function testShortWord(): void { @@ -71,7 +53,8 @@ public function testShortWord(): void } /** - * Test short valuable word. + * uuid 71e3d8fa-900d-4548-930e-68e7067c4615 + * @testdox Short, valuable word */ public function testShortValuableWord(): void { @@ -80,7 +63,8 @@ public function testShortValuableWord(): void } /** - * Test medium word. + * uuid d3088ad9-570c-4b51-8764-c75d5a430e99 + * @testdox Medium word */ public function testMediumWord(): void { @@ -89,7 +73,8 @@ public function testMediumWord(): void } /** - * Test medium valuable word. + * uuid fa20c572-ad86-400a-8511-64512daac352 + * @testdox Medium, valuable word */ public function testMediumValuableWord(): void { @@ -98,7 +83,8 @@ public function testMediumValuableWord(): void } /** - * Test long mixed-case word. + * uuid 9336f0ba-9c2b-4fa0-bd1c-2e2d328cf967 + * @testdox Long, mixed-case word */ public function testLongMixedCaseWord(): void { @@ -107,7 +93,8 @@ public function testLongMixedCaseWord(): void } /** - * Test english-like word. + * uuid 1e34e2c3-e444-4ea7-b598-3c2b46fd2c10 + * @testdox English-like word */ public function testEnglishLikeWord(): void { @@ -116,7 +103,8 @@ public function testEnglishLikeWord(): void } /** - * Test empty word score. + * uuid 4efe3169-b3b6-4334-8bae-ff4ef24a7e4f + * @testdox Empty input */ public function testEmptyWordScore(): void { @@ -125,7 +113,8 @@ public function testEmptyWordScore(): void } /* - * Test entire alphabet word. + * uuid 3b305c1c-f260-4e15-a5b5-cb7d3ea7c3d7 + * @testdox Entire alphabet available */ public function testEntireAlphabetWord(): void {