Beta

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.

Algorithms
Combinatorics
Algebra

Stats:

CreatedDec 2, 2016
PublishedDec 13, 2016
Warriors Trained27
Total Skips0
Total Code Submissions55
Total Times Completed7
JavaScript Completions7
Total Stars3
% of votes with a positive feedback rating50% of 3
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes0
Total Rank Assessments4
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Douggyfr3sh Avatar
Ad