diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json index 3f66237d..e5f532f0 100644 --- a/exercises/practice/hello-world/.meta/config.json +++ b/exercises/practice/hello-world/.meta/config.json @@ -30,7 +30,7 @@ ".meta/example.sh" ] }, - "blurb": "The classical introductory exercise. Just say \"Hello, World!\".", + "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", "source": "This is an exercise to introduce users to using Exercism", "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" } diff --git a/exercises/practice/phone-number/.docs/instructions.md b/exercises/practice/phone-number/.docs/instructions.md index 6b86bbac..62ba48e9 100644 --- a/exercises/practice/phone-number/.docs/instructions.md +++ b/exercises/practice/phone-number/.docs/instructions.md @@ -11,12 +11,14 @@ The first three digits of the local number represent the _exchange code_, follow The format is usually represented as ```text -(NXX)-NXX-XXXX +NXX NXX-XXXX ``` where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9. -Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present. +Sometimes they also have the country code (represented as `1` or `+1`) prefixed. + +Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code if present. For example, the inputs diff --git a/exercises/practice/poker/.meta/tests.toml b/exercises/practice/poker/.meta/tests.toml index 76ac892d..d859563a 100644 --- a/exercises/practice/poker/.meta/tests.toml +++ b/exercises/practice/poker/.meta/tests.toml @@ -21,12 +21,18 @@ description = "a tie has multiple winners" [61ed83a9-cfaa-40a5-942a-51f52f0a8725] description = "multiple hands with the same high cards, tie compares next highest ranked, down to last card" +[da01becd-f5b0-4342-b7f3-1318191d0580] +description = "winning high card hand also has the lowest card" + [f7175a89-34ff-44de-b3d7-f6fd97d1fca4] description = "one pair beats high card" [e114fd41-a301-4111-a9e7-5a7f72a76561] description = "highest pair wins" +[b3acd3a7-f9fa-4647-85ab-e0a9e07d1365] +description = "both hands have the same pair, high card wins" + [935bb4dc-a622-4400-97fa-86e7d06b1f76] description = "two pairs beats one pair" @@ -54,6 +60,10 @@ description = "both hands have three of a kind, tie goes to highest ranked tripl [eb856cc2-481c-4b0d-9835-4d75d07a5d9d] description = "with multiple decks, two players can have same three of a kind, ties go to highest remaining cards" +[26a4a7d4-34a2-4f18-90b4-4a8dd35d2bb1] +description = "with multiple decks, two players can have same three of a kind, ties go to highest remaining cards" +reimplements = "eb856cc2-481c-4b0d-9835-4d75d07a5d9d" + [a858c5d9-2f28-48e7-9980-b7fa04060a60] description = "a straight beats three of a kind" @@ -78,6 +88,10 @@ description = "flush beats a straight" [4d90261d-251c-49bd-a468-896bf10133de] description = "both hands have a flush, tie goes to high card, down to the last one if necessary" +[e04137c5-c19a-4dfc-97a1-9dfe9baaa2ff] +description = "both hands have a flush, tie goes to high card, down to the last one if necessary" +reimplements = "4d90261d-251c-49bd-a468-896bf10133de" + [3a19361d-8974-455c-82e5-f7152f5dba7c] description = "full house beats a flush" diff --git a/exercises/practice/poker/poker.bats b/exercises/practice/poker/poker.bats index 3fb3f8fd..8c338f11 100644 --- a/exercises/practice/poker/poker.bats +++ b/exercises/practice/poker/poker.bats @@ -6,7 +6,7 @@ load bats-extra @test "single hand always wins" { #[[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5S 7H 8D JC" + run bash poker.sh "4S 5S 7H 8D JC" assert_success assert_line "4S 5S 7H 8D JC" assert_equal "${#lines[@]}" "1" @@ -14,7 +14,7 @@ load bats-extra @test "highest card out of all hands wins" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4D 5S 6S 8D 3C" "2S 4C 7S 9H 10H" "3S 4S 5D 6H JH" + run bash poker.sh "4D 5S 6S 8D 3C" "2S 4C 7S 9H 10H" "3S 4S 5D 6H JH" assert_success assert_line "3S 4S 5D 6H JH" assert_equal "${#lines[@]}" "1" @@ -22,7 +22,7 @@ load bats-extra @test "a tie has multiple winners" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4D 5S 6S 8D 3C" "2S 4C 7S 9H 10H" "3S 4S 5D 6H JH" "3H 4H 5C 6C JD" + run bash poker.sh "4D 5S 6S 8D 3C" "2S 4C 7S 9H 10H" "3S 4S 5D 6H JH" "3H 4H 5C 6C JD" assert_success assert_line "3S 4S 5D 6H JH" assert_line "3H 4H 5C 6C JD" @@ -31,15 +31,47 @@ load bats-extra @test "multiple hands with the same high cards, tie compares next highest ranked, down to last card" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "3S 5H 6S 8D 7H" "2S 5D 6D 8C 7S" + run bash poker.sh "3S 5H 6S 8D 7H" "2S 5D 6D 8C 7S" assert_success assert_line "3S 5H 6S 8D 7H" assert_equal "${#lines[@]}" "1" } +@test "winning high card hand also has the lowest card" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash poker.sh "2S 5H 6S 8D 7H" "3S 4D 6D 8C 7S" + assert_success + assert_line "2S 5H 6S 8D 7H" + assert_equal "${#lines[@]}" "1" +} + +@test "both hands have the same pair, high card wins" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash poker.sh "4H 4S AH JC 3D" "4C 4D AS 5D 6C" + assert_success + assert_line "4H 4S AH JC 3D" + assert_equal "${#lines[@]}" "1" +} + +@test "with multiple decks, two players can have same three of a kind, ties go to highest remaining cards" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash poker.sh "4S AH AS 7C AD" "4S AH AS 8C AD" + assert_success + assert_line "4S AH AS 8C AD" + assert_equal "${#lines[@]}" "1" +} + +@test "both hands have a flush, tie goes to high card, down to the last one if necessary" { + [[ $BATS_RUN_SKIPPED == "true" ]] || skip + run bash poker.sh "4H 7H 8H 9H 6H" "2S 4S 5S 6S 7S" + assert_success + assert_line "4H 7H 8H 9H 6H" + assert_equal "${#lines[@]}" "1" +} + @test "one pair beats high card" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5H 6C 8D KH" "2S 4H 6S 4D JH" + run bash poker.sh "4S 5H 6C 8D KH" "2S 4H 6S 4D JH" assert_success assert_line "2S 4H 6S 4D JH" assert_equal "${#lines[@]}" "1" @@ -47,7 +79,7 @@ load bats-extra @test "highest pair wins" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 2H 6S 2D JH" "2S 4H 6C 4D JD" + run bash poker.sh "4S 2H 6S 2D JH" "2S 4H 6C 4D JD" assert_success assert_line "2S 4H 6C 4D JD" assert_equal "${#lines[@]}" "1" @@ -55,7 +87,7 @@ load bats-extra @test "two pairs beats one pair" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2S 8H 6S 8D JH" "4S 5H 4C 8C 5C" + run bash poker.sh "2S 8H 6S 8D JH" "4S 5H 4C 8C 5C" assert_success assert_line "4S 5H 4C 8C 5C" assert_equal "${#lines[@]}" "1" @@ -63,7 +95,7 @@ load bats-extra @test "both hands have two pairs, highest ranked pair wins" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2S 8H 2D 8D 3H" "4S 5H 4C 8S 5D" + run bash poker.sh "2S 8H 2D 8D 3H" "4S 5H 4C 8S 5D" assert_success assert_line "2S 8H 2D 8D 3H" assert_equal "${#lines[@]}" "1" @@ -71,7 +103,7 @@ load bats-extra @test "both hands have two pairs, with the same highest ranked pair, tie goes to low pair" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2S QS 2C QD JH" "JD QH JS 8D QC" + run bash poker.sh "2S QS 2C QD JH" "JD QH JS 8D QC" assert_success assert_line "JD QH JS 8D QC" assert_equal "${#lines[@]}" "1" @@ -79,7 +111,7 @@ load bats-extra @test "both hands have two identically ranked pairs, tie goes to remaining card (kicker)" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "JD QH JS 8D QC" "JS QS JC 2D QD" + run bash poker.sh "JD QH JS 8D QC" "JS QS JC 2D QD" assert_success assert_line "JD QH JS 8D QC" assert_equal "${#lines[@]}" "1" @@ -103,7 +135,7 @@ load bats-extra @test "three of a kind beats two pair" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2S 8H 2H 8D JH" "4S 5H 4C 8S 4H" + run bash poker.sh "2S 8H 2H 8D JH" "4S 5H 4C 8S 4H" assert_success assert_line "4S 5H 4C 8S 4H" assert_equal "${#lines[@]}" "1" @@ -111,15 +143,7 @@ load bats-extra @test "both hands have three of a kind, tie goes to highest ranked triplet" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2S 2H 2C 8D JH" "4S AH AS 8C AD" - assert_success - assert_line "4S AH AS 8C AD" - assert_equal "${#lines[@]}" "1" -} - -@test "with multiple decks, two players can have same three of a kind, ties go to highest remaining cards" { - [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S AH AS 7C AD" "4S AH AS 8C AD" + run bash poker.sh "2S 2H 2C 8D JH" "4S AH AS 8C AD" assert_success assert_line "4S AH AS 8C AD" assert_equal "${#lines[@]}" "1" @@ -127,7 +151,7 @@ load bats-extra @test "a straight beats three of a kind" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5H 4C 8D 4H" "3S 4D 2S 6D 5C" + run bash poker.sh "4S 5H 4C 8D 4H" "3S 4D 2S 6D 5C" assert_success assert_line "3S 4D 2S 6D 5C" assert_equal "${#lines[@]}" "1" @@ -135,7 +159,7 @@ load bats-extra @test "aces can end a straight (10 J Q K A)" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5H 4C 8D 4H" "10D JH QS KD AC" + run bash poker.sh "4S 5H 4C 8D 4H" "10D JH QS KD AC" assert_success assert_line "10D JH QS KD AC" assert_equal "${#lines[@]}" "1" @@ -143,7 +167,7 @@ load bats-extra @test "aces can start a straight (A 2 3 4 5)" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5H 4C 8D 4H" "4D AH 3S 2D 5C" + run bash poker.sh "4S 5H 4C 8D 4H" "4D AH 3S 2D 5C" assert_success assert_line "4D AH 3S 2D 5C" assert_equal "${#lines[@]}" "1" @@ -160,7 +184,7 @@ load bats-extra @test "both hands with a straight, tie goes to highest ranked card" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 6C 7S 8D 5H" "5S 7H 8S 9D 6H" + run bash poker.sh "4S 6C 7S 8D 5H" "5S 7H 8S 9D 6H" assert_success assert_line "5S 7H 8S 9D 6H" assert_equal "${#lines[@]}" "1" @@ -168,7 +192,7 @@ load bats-extra @test "even though an ace is usually high, a 5-high straight is the lowest-scoring straight" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2H 3C 4D 5D 6H" "4S AH 3S 2D 5H" + run bash poker.sh "2H 3C 4D 5D 6H" "4S AH 3S 2D 5H" assert_success assert_line "2H 3C 4D 5D 6H" assert_equal "${#lines[@]}" "1" @@ -176,23 +200,15 @@ load bats-extra @test "flush beats a straight" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4C 6H 7D 8D 5H" "2S 4S 5S 6S 7S" + run bash poker.sh "4C 6H 7D 8D 5H" "2S 4S 5S 6S 7S" assert_success assert_line "2S 4S 5S 6S 7S" assert_equal "${#lines[@]}" "1" } -@test "both hands have a flush, tie goes to high card, down to the last one if necessary" { - [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4H 7H 8H 9H 6H" "2S 4S 5S 6S 7S" - assert_success - assert_line "4H 7H 8H 9H 6H" - assert_equal "${#lines[@]}" "1" -} - @test "full house beats a flush" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "3H 6H 7H 8H 5H" "4S 5H 4C 5D 4H" + run bash poker.sh "3H 6H 7H 8H 5H" "4S 5H 4C 5D 4H" assert_success assert_line "4S 5H 4C 5D 4H" assert_equal "${#lines[@]}" "1" @@ -200,7 +216,7 @@ load bats-extra @test "both hands have a full house, tie goes to highest-ranked triplet" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4H 4S 4D 9S 9D" "5H 5S 5D 8S 8D" + run bash poker.sh "4H 4S 4D 9S 9D" "5H 5S 5D 8S 8D" assert_success assert_line "5H 5S 5D 8S 8D" assert_equal "${#lines[@]}" "1" @@ -208,7 +224,7 @@ load bats-extra @test "with multiple decks, both hands have a full house with the same triplet, tie goes to the pair" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "5H 5S 5D 9S 9D" "5H 5S 5D 8S 8D" + run bash poker.sh "5H 5S 5D 9S 9D" "5H 5S 5D 8S 8D" assert_success assert_line "5H 5S 5D 9S 9D" assert_equal "${#lines[@]}" "1" @@ -216,7 +232,7 @@ load bats-extra @test "four of a kind beats a full house" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5H 4D 5D 4H" "3S 3H 2S 3D 3C" + run bash poker.sh "4S 5H 4D 5D 4H" "3S 3H 2S 3D 3C" assert_success assert_line "3S 3H 2S 3D 3C" assert_equal "${#lines[@]}" "1" @@ -224,7 +240,7 @@ load bats-extra @test "both hands have four of a kind, tie goes to high quad" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "2S 2H 2C 8D 2D" "4S 5H 5S 5D 5C" + run bash poker.sh "2S 2H 2C 8D 2D" "4S 5H 5S 5D 5C" assert_success assert_line "4S 5H 5S 5D 5C" assert_equal "${#lines[@]}" "1" @@ -232,7 +248,7 @@ load bats-extra @test "with multiple decks, both hands with identical four of a kind, tie determined by kicker" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "3S 3H 2S 3D 3C" "3S 3H 4S 3D 3C" + run bash poker.sh "3S 3H 2S 3D 3C" "3S 3H 4S 3D 3C" assert_success assert_line "3S 3H 4S 3D 3C" assert_equal "${#lines[@]}" "1" @@ -240,7 +256,7 @@ load bats-extra @test "straight flush beats four of a kind" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4S 5H 5S 5D 5C" "7S 8S 9S 6S 10S" + run bash poker.sh "4S 5H 5S 5D 5C" "7S 8S 9S 6S 10S" assert_success assert_line "7S 8S 9S 6S 10S" assert_equal "${#lines[@]}" "1" @@ -272,7 +288,7 @@ load bats-extra @test "both hands have straight flush, tie goes to highest-ranked card" { [[ $BATS_RUN_SKIPPED == "true" ]] || skip - run bash poker.sh "4H 6H 7H 8H 5H" "5S 7S 8S 9S 6S" + run bash poker.sh "4H 6H 7H 8H 5H" "5S 7S 8S 9S 6S" assert_success assert_line "5S 7S 8S 9S 6S" assert_equal "${#lines[@]}" "1" diff --git a/exercises/practice/pop-count/.meta/config.json b/exercises/practice/pop-count/.meta/config.json index 36225329..17851e82 100644 --- a/exercises/practice/pop-count/.meta/config.json +++ b/exercises/practice/pop-count/.meta/config.json @@ -13,7 +13,7 @@ ".meta/example.sh" ] }, - "blurb": "Help Eluid count the number of eggs in her chicken coop by counting the number of 1 bits in a binary representation.", + "blurb": "Help Eliud count the number of eggs in her chicken coop by counting the number of 1 bits in a binary representation.", "source": "Christian Willner, Eric Willigers", "source_url": "https://forum.exercism.org/t/new-exercise-suggestion-pop-count/7632/5" }