All problems
Poker Two Pair Probability
Problem
Probability that a 5-card hand is exactly two pair in a deck with ranks ranks and suits suits:
P = C(ranks, 2) * C(suits, 2)^2 * (ranks - 2) * suits / C(ranks * suits, 5).
Return 0.0 for invalid inputs.
Hint
Choose two pair ranks, the suits in each pair, then any kicker from another rank.
Test cases
case 1
in: [13,4]
expected: 0.0475390156062425
case 2
in: [5,4]
expected: 0.2786377708978328
case 3
in: [4,2]
expected: 0.42857142857142855
Starter codePython
import math
def poker_two_pair_probability(ranks, suits):
# Your code here
pass3 test cases · run your code against them in the editor