Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-150

Poker Flush Probability

Problem

Probability that a 5-card hand from a deck with 13 ranks and suits suits is a flush:

P = suits * C(13, 5) / C(13 * suits, 5).

When include_straight_flush is False, subtract the 10 * suits straight flushes from the numerator. Return 0.0 for suits < 1.

Hint

There are 10 straight sequences in 13 ranks: A2345 through 9TJQK.

Test cases

case 1
in: [4,true]
expected: 0.0019807923169267707
case 2
in: [4,false]
expected: 0.001965401545233478
case 3
in: [2,true]
expected: 0.0391304347826087
case 4
in: [2,false]
expected: 0.03882639100030404
Starter codePython
import math


def poker_flush_probability(suits, include_straight_flush):
    # Your code here
    pass

4 test cases · run your code against them in the editor