Basically, I’d like to know for a card game this particular question. I have 13 “basic” cards in the deck, one of which must be in my starting hand - a hand of 7 cards drawn from a randomly shuffled deck. If I don’t get a “basic” in this hand of cards I then reshuffle the deck with that hand going back into it and draw a new 7 card. There’s 6 different types of “basic” card - 5 having a two count with one having three. (resulting in the previously mentioned 13 “basic” cards.)

After drawing a hand of 7 cards with at least one basic from my shuffled deck, I place 6 cards face down from the top of the deck - without shuffling again or looking at them to the side of my board. What are the odds that all copies of the same “basic” as well as one other specific card from the deck (let’s call it “X”) are placed in this 6 cadd pile. For reference, the decklist would look like:

”Basic” cards. (13)

3 A, 2 B, 2 C, 2 D, 2 E, 2 F

Other (47)

46 cards not relevant, 1 X

  • $\begingroup$ 1) Is it guaranteed, or by chance that "After drawing a hand of 7 cards with at least one basic ..." (2) You could draw all cards from more than one basic (3) What have you attempted so far ? Pl edit in your efforts and where you are stuck. $\endgroup$ Commented Mar 28, 2023 at 7:36
  • $\begingroup$ "I place 6 cards face down to the side of my board": Do you choose these cards, or do you pick them at random? $\endgroup$ Commented Mar 29, 2023 at 4:42

1 Answer 1



Here's a solution using my Icepool Python package:

from icepool import Deck, multiset_function, Reroll

deck = Deck({
    'A' : 3,
    'B' : 2,
    'C' : 2,
    'D' : 2,
    'E' : 2,
    'F' : 2,
    'N' : 46,
    'X' : 1,

def all_basic(outcome, count):
    return outcome <= 'F' and count == deck[outcome]

def hand_pile(hand, pile):
    return (
        (hand & ['A', 'B', 'C', 'D', 'E', 'F']).any(),
        pile >= ['X'],
def final_evaluation(keep, got_x, got_all_basic):
    if not keep:
        return Reroll
    return got_x and got_all_basic

output(hand_pile(deck.deal(7, 6)).map(final_evaluation))

(API subject to change. This script is based on Icepool v0.25.6.)

Try this script in your browser.


Die with denominator 7422507311299080

Outcome Quantity Probability
False 7401705459513360 99.719746%
True 20801851785720 0.280254%


  • Given a single card and how many of that card were drawn, all_basic returns 1 if that card is a basic card and all copies of that card were drawn, and 0 otherwise.
  • The multiset_function allows us to define a function using some simple multiset operations. In this case, we jointly determine three things:
    • Whether the "hand" contained any basic card. The & operator represents multiset intersection, and .any() determines whether that intersection is non-empty.
    • Whether the "pile" contained the X card.
    • Whether the "pile" contained all copies of a basic card for .any() such card.
  • final_evaluation describes restarting if the first condition is not met, and otherwise determines whether the other two conditions are met.
  • Finally, we put it all together by dealing 7 cards to the "hand" and 6 to the "pile".


The algorithm uses dynamic programming and the decomposition of the hypergeometric distribution into binomials to find the distribution efficiently. If you are curious to learn more, you can read my paper here.

    title={Icepool: Efficient Computation of Dice Pool Probabilities},
    author={Albert Julius Liu},
    booktitle={Eighteenth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment},
    venue={Pomona, California},

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .