Here's a Python program that I believe is correct. It takes a little under 7 minutes on my machine to run through every pair of hands.
from itertools import combinations
from collections import Counter
JACK, QUEEN, KING, ACE = 11, 12, 13, 14
N_HANDS = 22100 # 52 choose 3
deck = frozenset((rank, suit)
for rank in range(2, ACE + 1)
for suit in range(4))
assert len(deck) == 52
evaluate_hand_cache = {}
def evaluate_hand(hand):
if hand not in evaluate_hand_cache:
evaluate_hand_cache[hand] = evaluate_hand_(hand)
return evaluate_hand_cache[hand]
def evaluate_hand_(hand):
ranks = tuple(sorted((rank for (rank, _) in hand), reverse = True))
suits = [suit for (_, suit) in hand]
if ranks[0] == ranks[1] == ranks[2]:
# Three of a kind
return (5, ranks[0])
straight = (ranks[0] == ranks[1] + 1 == ranks[2] + 2
or ranks == (ACE, 3, 2))
flush = suits[0] == suits[1] == suits[2]
if straight and flush:
return (6, ranks[0])
if straight:
return (4, ranks[0])
if flush:
return (3,) + ranks
if ranks[0] == ranks[1]:
# Pair
return (2, ranks[0], ranks[2])
if ranks[1] == ranks[2]:
# Also a pair
return (2, ranks[2], ranks[0])
return (1,) + ranks
results = Counter()
divisor = N_HANDS // 100
for i, dealer_hand in enumerate(combinations(deck, 3)):
if i % divisor == 0:
print "{}% complete".format(i // divisor)
dealer_hand = frozenset(dealer_hand)
dealer_e = evaluate_hand(dealer_hand)
for player_hand in combinations(deck - dealer_hand, 3):
player_e = evaluate_hand(player_hand)
outcome = (
'Dealer does not qualify'
if dealer_e < (2, QUEEN) else
'Player loses'
if player_e < dealer_e else
'Player wins'
if dealer_e < player_e else
'Tie')
results[(player_e[0], outcome)] += 1
print "Player hand class,Outcome,Count"
for (hand, outcome), n in sorted(results.items()):
print ','.join([str(hand), outcome, str(n)])
The output is:
Player hand class,Outcome,Count
1,Dealer does not qualify,264851952
1,Player loses,38038608
2,Dealer does not qualify,60280560
2,Player loses,8453520
2,Player wins,242784
2,Tie,2592
3,Dealer does not qualify,17630040
3,Player loses,1260596
3,Player wins,1298780
3,Tie,3288
4,Dealer does not qualify,11581584
4,Player loses,267804
4,Player wins,1392204
4,Tie,23688
5,Dealer does not qualify,836520
5,Player loses,3312
5,Player wins,118216
6,Dealer does not qualify,771024
6,Player loses,956
6,Player wins,112204
6,Tie,168
Best Answer
I am not a keen poker player but I believe this refers to the possibility of selecting a card from each of the four suits. For each of the five cards in the straight, this can be done in $\binom{4}{1} = 4$ ways . For instance, for a straight of 1,2,3,4,5 there are four fives among which you can choose. And likewise for the rest of the cards.
Also, a word about the $\binom{10}{1}$ factor. This accounts for the number of ways one can select five adjacent cards out of the thirteen, there are nine ways to do so, plus the possibility of selecting the last four cards and having a high ace, which still counts as a straight I hear. In all, 10 ways.