From 45cadc59cca082af22d1e646b96c3afb0197e106 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Mon, 20 Nov 2023 01:39:57 +0100 Subject: [PATCH] Sync poker (#1392) --- exercises/practice/poker/.meta/tests.toml | 16 ++++++++++ exercises/practice/poker/test/poker_test.exs | 32 ++++++++++++-------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/exercises/practice/poker/.meta/tests.toml b/exercises/practice/poker/.meta/tests.toml index 76ac892d93..2e654ef63b 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" @@ -53,6 +59,11 @@ 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" +include = false + +[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" @@ -77,6 +88,11 @@ 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" +include = false + +[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/test/poker_test.exs b/exercises/practice/poker/test/poker_test.exs index 3a7b12b97f..ca72ef127e 100644 --- a/exercises/practice/poker/test/poker_test.exs +++ b/exercises/practice/poker/test/poker_test.exs @@ -59,6 +59,14 @@ defmodule PokerTest do assert_poker(winning_hands, [high_of_8_low_of_3]) end + @tag :pending + test "winning high card hand also has the lowest card" do + high_of_8_low_of_5_and_3 = ~w(2S 5H 6S 8D 7H) + high_of_8_low_of_4_and_2 = ~w(3S 4D 6D 8C 7S) + winning_hands = Poker.best_hand([high_of_8_low_of_5_and_3, high_of_8_low_of_4_and_2]) + assert_poker(winning_hands, [high_of_8_low_of_5_and_3]) + end + @tag :pending test "one pair beats high card" do high_of_king = ~w(4S 5H 6C 8D KH) @@ -75,6 +83,14 @@ defmodule PokerTest do assert_poker(winning_hands, [pair_of_4]) end + @tag :pending + test "both hands have the same pair, high card wins" do + pair_of_4_low_of_j_and_3 = ~w(4H 4S AH JC 3D) + pair_of_4_low_of_6_and_5 = ~w(4C 4D AS 5D 6C) + winning_hands = Poker.best_hand([pair_of_4_low_of_j_and_3, pair_of_4_low_of_6_and_5]) + assert_poker(winning_hands, [pair_of_4_low_of_j_and_3]) + end + @tag :pending test "two pairs beats one pair" do pair_of_8 = ~w(2S 8H 6S 8D JH) @@ -141,14 +157,10 @@ defmodule PokerTest do @tag :pending test "with multiple decks, two players can have same three of a kind, ties go to highest remaining cards" do - three_aces_7_high = ~w(4S AH AS 7C AD) + three_aces_7_high = ~w(5S AH AS 7C AD) three_aces_8_high = ~w(4S AH AS 8C AD) winning_hands = Poker.best_hand([three_aces_7_high, three_aces_8_high]) assert_poker(winning_hands, [three_aces_8_high]) - - three_aces_8_high_5_low = ~w(5S AH AS 8C AD) - winning_hands = Poker.best_hand([three_aces_8_high_5_low, three_aces_8_high]) - assert_poker(winning_hands, [three_aces_8_high_5_low]) end @tag :pending @@ -209,13 +221,9 @@ defmodule PokerTest do @tag :pending test "both hands have a flush, tie goes to high card, down to the last one if necessary" do - flush_to_9 = ~w(4H 7H 8H 9H 6H) - flush_to_7 = ~w(2S 4S 5S 6S 7S) - winning_hands = Poker.best_hand([flush_to_9, flush_to_7]) - assert_poker(winning_hands, [flush_to_9]) - - flush_to_9_with_4_matches = ~w(3S 6S 7S 8S 9S) - winning_hands = Poker.best_hand([flush_to_9, flush_to_9_with_4_matches]) + flush_to_9 = ~w(2H 7H 8H 9H 6H) + flush_to_8 = ~w(3S 5S 6S 7S 8S) + winning_hands = Poker.best_hand([flush_to_9, flush_to_8]) assert_poker(winning_hands, [flush_to_9]) end