#poker.py def fact(n): prod = n for i in range(n-1,1,-1): prod *= i return prod def combos(n,k): return int(fact(n) / (fact(k) * fact(n-k))) poker = {} five_card_hands = combos(52,5) print("Number of 5-card hands:",five_card_hands) poker['straight_flushes'] = 4*10 poker['four_of_a_kinds'] = 13*48 poker['full_houses'] = 13*combos(4,3) * 12*combos(4,2) poker['flushes'] = 4*combos(13,5)-(4*10) poker['straights'] = 10*4**5 -(4*10) poker['three_of_a_kinds'] = 13*combos(4,3) * combos(12,2)*4*4 poker['two_pairs'] = combos(13,2)*combos(4,2)**2 * 44 poker['one_pairs'] = 13*combos(4,2) * combos(12,3)*4*4*4 #print(poker) for hand in poker: print('#%-16s %9d %6.5f%%'%(hand,poker[hand],poker[hand]/five_card_hands*100)) print() print("outside straight:",8/47*100,"%") print("2-pair to full house:",4/47*100,"%") print("3-of-a-kind to full house:",12*combos(4,2)/combos(47,2)*100,"%") print("3-of-a-kind to 4-of-a-kind:",1/47*100,"%") #? print("4 same suit to flush:",9/47*100,"%")