Skip to content

Commit 2251c29

Browse files
authored
Merge pull request #13 from Kpler/adjust-poker-kata
remove bias due to existing code
2 parents d67cd5c + 12fb7d0 commit 2251c29

5 files changed

Lines changed: 91 additions & 103 deletions

File tree

src/poker/readme.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,94 @@
22

33
https://codingdojo.org/kata/TexasHoldEm/
44

5+
## Starter suggestion
6+
7+
Given the subject, you could start by:
8+
```
9+
def test_solve_poker_game() -> None:
10+
assert solve_poker_game(
11+
"""
12+
Kc 9s Ks Kd 9d 3c 6d
13+
9c Ah Ks Kd 9d 3c 6d
14+
Ac Qc Ks Kd 9d 3c
15+
9h 5s
16+
4d 2d Ks Kd 9d 3c 6d
17+
7s Ts Ks Kd 9d
18+
"""
19+
) == """
20+
Kc 9s Ks Kd 9d 3c 6d Full House (winner)
21+
9c Ah Ks Kd 9d 3c 6d Two Pair
22+
Ac Qc Ks Kd 9d 3c
23+
9h 5s
24+
4d 2d Ks Kd 9d 3c 6d Flush
25+
7s Ts Ks Kd 9d
26+
"""
27+
```
28+
29+
Then, defining the strategy you would follow to reach the goal. As mentioned in the subject, you will need several steps:
30+
```
31+
def solve_poker_game(input_data: str) -> str:
32+
hands = parse_input(input_data)
33+
ranked_hands = rank_hands(hands)
34+
winner = compute_winner(ranked_hands)
35+
return format_results(...)
36+
```
37+
38+
## Helpers
39+
40+
You can use the following classes to represent the cards and their properties:
41+
```
42+
from dataclasses import dataclass
43+
from enum import Enum, auto
44+
45+
class Suit(Enum):
46+
SPADE = auto()
47+
HEART = auto()
48+
DIAMOND = auto()
49+
CLUB = auto()
50+
51+
class Face(Enum):
52+
ONE = auto()
53+
TWO = auto()
54+
THREE = auto()
55+
FOUR = auto()
56+
FIVE = auto()
57+
SIX = auto()
58+
SEVEN = auto()
59+
EIGHT = auto()
60+
NINE = auto()
61+
TEN = auto()
62+
JACK = auto()
63+
QUEEN = auto()
64+
KING = auto()
65+
ACE = auto()
66+
67+
@dataclass
68+
class Card:
69+
face: Face
70+
suit: Suit
71+
```
72+
73+
And you can also use the following mappings:
74+
```
75+
char_to_suit_map = {
76+
's': Suit.SPADE,
77+
'h': Suit.HEART,
78+
'd': Suit.DIAMOND,
79+
'c': Suit.CLUB
80+
}
81+
char_to_face_map = {
82+
'2': Face.TWO,
83+
'3': Face.THREE,
84+
'4': Face.FOUR,
85+
'5': Face.FIVE,
86+
'6': Face.SIX,
87+
'7': Face.SEVEN,
88+
'8': Face.EIGHT,
89+
'9': Face.NINE,
90+
'T': Face.TEN,
91+
'J': Face.JACK,
92+
'Q': Face.QUEEN,
93+
'K': Face.KING,
94+
'A': Face.ACE,
95+
```

src/poker/with_read_input/__init__.py

Whitespace-only changes.

src/poker/with_read_input/poker.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

tests/poker/with_read_input/__init__.py

Whitespace-only changes.

tests/poker/with_read_input/test_poker.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)