Hold'em Holecard Combinatorics
Description:
In the Poker game Texas Hold'em, a player is dealt 2 cards randomly out of a standard 52-card deck. Write a function that accepts a string which defines a 2-card starting hand. Your function should return the number of possible combinations of the 2-card hand in a 52-card deck. The string can represent an exact specific hand, a specific pair (e.g. 22, 77), a specific type of hand of any suit, or a suited or offsuit combo. the character 'T' reperesents a ten, and 'Q' 'K' 'A' represent queens, kings, and aces. Suits are represented by lowercase letters: 'd' for diamond, 's' for spade, 'c' for club, and 'h' for heart. See example strings below:
Pocket pairs:
'22' //a pair of twos
'TT' //a pair of tens
'KK' //a pair of kings
Exact hand combos:
'AsKd' //Ace of spades and King of diamonds
'QdTd' //Queen of diamonds and Ten of diamonds
'4d4s' //4 of diamonds and 4 of spades
Any of a specific hand, suited OR offsuit:
'AK' //Any Ace and King, any suit
'78' //Any 7 and 8, any suit
Any of a specific suited hand:
'AKs' //Any Ace and King of same suit
'78s' //Any 7 and 8 of same suit
Any of a specific off-sut hand:
'AKo' //Any Ace and King not of same suit
'89o' //Any 8 and 9 not of same suit
Your function should return -1 for any invalid string. Otherwise it should return the number of possible combinations of the given hand. Here are some examples:
'4d4d' //Return -1 because there is only one 4 of diamonds in the deck, this is invalid.
'4d4s' // Return 1,because this represents an exact specific hand, there is only one combo of this hand in the deck.
Similar Kata:
Stats:
Created | Dec 2, 2016 |
Published | Dec 13, 2016 |
Warriors Trained | 27 |
Total Skips | 0 |
Total Code Submissions | 55 |
Total Times Completed | 7 |
JavaScript Completions | 7 |
Total Stars | 3 |
% of votes with a positive feedback rating | 50% of 3 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |