Poker hand analyser: Difference between revisions

Content added Content deleted
(Added Elixir)
m (added a ;Task: (bold) header, made other wording changes to the task's preamble (spelled-out some numbers).)
Line 1: Line 1:
{{draft task}} [[Category:Cards]] [[Category:Games]]
{{draft task}}
[[Category:Cards]]
Create a program to parse a single 5 card poker hand and rank it according to this [[wp:List_of_poker_hands|list of poker hands]].
[[Category:Games]]


;Task:
A poker hand is specified as a space separated list of 5 playing cards.
Create a program to parse a single five card poker hand and rank it according to this [[wp:List_of_poker_hands|list of poker hands]].


A poker hand is specified as a space separated list of five playing cards.


Each input card has two characters indicating face and suit.
Each input card has two characters indicating face and suit.
Line 14: Line 19:
Duplicate cards are illegal.
Duplicate cards are illegal.


The program should analyse a single hand and produce one of the following outputs:
The program should analyze a single hand and produce one of the following outputs:

straight-flush
straight-flush
four-of-a-kind
four-of-a-kind
Line 28: Line 32:


Examples:
Examples:

2♥ 2♦ 2♣ k♣ q♦: three-of-a-kind
2♥ 2♦ 2♣ k♣ q♦: three-of-a-kind
2♥ 5♥ 7♦ 8♣ 9♠: high-card
2♥ 5♥ 7♦ 8♣ 9♠: high-card
Line 41: Line 44:
The programs output for the above examples should be displayed here on this page.
The programs output for the above examples should be displayed here on this page.



For extra credit:
;Extra credit:
# use the playing card characters introduced with Unicode 6.0 (U+1F0A1 - U+1F0DE).
# use the playing card characters introduced with Unicode 6.0 (U+1F0A1 - U+1F0DE).
# allow two jokers
# allow two jokers
Line 48: Line 52:
::* five-of-a-kind would then be the highest hand
::* five-of-a-kind would then be the highest hand


Extra Credit 2. Examples:


;More extra credit examples:
joker 2♦ 2♠ k♠ q♦: three-of-a-kind
joker 2♦ 2♠ k♠ q♦: three-of-a-kind
joker 5♥ 7♦ 8♠ 9♦: straight
joker 5♥ 7♦ 8♠ 9♦: straight
Line 63: Line 67:
joker Q♦ joker A♦ 10♦: straight-flush
joker Q♦ joker A♦ 10♦: straight-flush
joker 2♦ 2♠ joker q♦: four-of-a-kind
joker 2♦ 2♠ joker q♦: four-of-a-kind
<br><br>


=={{header|C++}}==
=={{header|C++}}==