Five Quick Probability Puzzles: Dice, Deck, Coins, Boxes
Math & Bit ManipulationAuto-graded · 2 test casesLast updated
Work out five small probability puzzles using symmetry, complements, counting and pigeonhole, and return the exact answers as fraction strings in order.
Five Quick Probability Puzzles
Write a function that takes no arguments and returns the exact answers to five short probability puzzles. Return a list of five strings, one per puzzle, in the order given below. Each string is a fraction in lowest terms written as "a/b", except when the answer is a whole number, in which case it is written as a plain integer such as "1".
Throughout, all dice are fair six-sided dice, all coins are fair, and all rolls and flips are independent. The deck is a standard 52-card deck (26 red, 26 black) shuffled uniformly at random.
The five puzzles
- A single die is rolled twice. What is the probability that the second roll shows a different number than the first?
- A well-shuffled 52-card deck has its top 10 cards removed and discarded without anyone looking at them. What is the probability that the next card (the 11th card of the original deck) is red?
- Two dice are rolled. What is the probability that their total is 11 or 12?
- A coin is flipped 3 times. What is the probability that all three flips give the same result (all heads or all tails)?
- 61 coins are dropped at random into 15 boxes. You win a prize if at least one box ends up holding more than 4 coins. What is the probability that you win?
Output format
Return a list of exactly five strings, the answers to puzzles 1 through 5 in order, each as an exact fraction in lowest terms (or an integer string when the value is a whole number).
Constraints
- Dice and coins are fair; all rolls and flips are independent.
- The deck has 52 cards, 26 red and 26 black, in uniformly random order.
- The 10 discarded cards are never seen, so they give no information.
- "Different" in puzzle 1 means strictly different from the first roll.
- Puzzle 3 counts ordered outcomes of the two dice.
- Answers must be exact, not rounded decimals.
- The function takes no input.
Examples
Example 1
Input: quick_probability_answers()
Output: ['5/6', '1/2', '1/12', '1/4', '1']
Hints
Hint 1
For puzzle 1, whatever the first roll is, exactly one of the six faces on the second roll would match it.
Hint 2
For puzzle 2, every position in a uniformly shuffled deck has the same chance of holding a red card; discarding unseen cards teaches you nothing. For puzzle 3, list ordered pairs out of 36.
Hint 3
For puzzle 5, suppose no box had more than 4 coins and compute the maximum number of coins that could then be in the boxes.
Worked solution
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Approach
Each puzzle has a short argument, so the function just returns the five answers.
-
Second roll differs: 5/6. Whatever the first roll shows, the second roll is independent and uniform over 6 faces, and exactly one face matches. So the probability is 1 - 1/6 = 5/6.
-
11th card is red: 1/2. In a uniformly shuffled deck, every position has the same distribution, so the 11th card is red with the same probability as the 1st card: 26/52 = 1/2. Discarding 10 cards unseen provides no information, so nothing changes.
-
Total of 11 or 12: 1/12. There are 36 equally likely ordered outcomes. Total 11 comes from (5,6) and (6,5); total 12 comes from (6,6). That is 3 favorable outcomes, and 3/36 = 1/12.
-
Three identical flips: 1/4. The first flip is arbitrary, and each of the next two must match it, each with probability 1/2. That gives 1/4. Equivalently, 2 sequences (HHH, TTT) out of 8 gives 2/8 = 1/4.
-
Some box holds more than 4 coins: 1. If every box held at most 4 coins, the total would be at most 15 x 4 = 60, which is less than 61. So every possible arrangement has some box with at least 5 coins, and the prize is guaranteed. The probability is 1.
Why it is correct
- Puzzle 1 follows from independence, and the answer is the same for every first value.
- Puzzle 2 follows from the exchangeability of positions in a uniform random permutation.
- Puzzle 3 is an exact count over a uniform sample space of 36 ordered outcomes.
- Puzzle 4 is a product of independent probabilities, cross-checked by counting.
- Puzzle 5 is the pigeonhole principle: the event covers the whole sample space.
Complexity
Time O(1), space O(1).
Reference solution
from typing import List
def quick_probability_answers() -> List[str]:
return ["5/6", "1/2", "1/12", "1/4", "1"]