A common question asked about Deck-u-lator is why does it take so long to calculate my combination.
Time to calculate binomial coefficient
The fundamental calculation performed is the binomial coefficient. Python can perform four million binomials coefficients per second using math.comb() function.
Deck-u-lator uses Python functools.cache to do these even faster, only calculating the result for each set of inputs once and remembering that result.
Time to calculte multivariate hypergeometric
When you draw exactly as many cards as are in your combination, Deck-u-lator calculates the multivariate hypergeomatric once, with one binomial coefficient for each card in the combination (C) and one for the deck. For a combination with 4 cards, binomial coefficient is calculated 5 times.
Time to draw extra cards
When you draw more cards than your combination, Deck-u-lator calculates the multivariate hypergeometric for each different way to draw those extra cards. The number of different ways to draw the extra cards is roughly the product of the number of cards C of each type in your deck. In a 60 card deck, a three card combination where there are four of each card in your deck will calculate multivariate hypergeometric 64 times (\(4^C\) or \(4^3\))
Time to draw alternate hands
When your combination includes alternate hand columns, Deck-u-lator must calculate every combination of hand columns. For H hand columns, there are \(2^H -1\) combinations to calculate.
Deck-u-lator also uses functools.cache to combine hand columns, making this a bit faster.
Total time to calculate your combination
To estimate the time it will take to complete your calculation, substitute C for the card rows in your combination and H for the hand columns in this formula:
$$ \frac {(2^H - 1) \times (4^C) \times (C + 1) }{4,000,000 } \text{ seconds} $$
A sample calculation with C=5 card rows and H=3 card columns
$$ (2^3 - 1) \times (4^5) \times (5 + 1) / 4,000,000 \text{ seconds} $$
$$ (7) \times (1,024) \times 6 /4,000,000 \text{ seconds} $$
$$ 0.01 \text{ seconds}$$


