KatInterview

Five Quick Probability Puzzles: Dice, Deck, Coins, Boxes

Math & Bit ManipulationAuto-graded · 2 test cases
EasyAuto-gradedMath & Bit Manipulationprobabilitycombinatoricspigeonhole

Last 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

  1. A single die is rolled twice. What is the probability that the second roll shows a different number than the first?
  2. 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?
  3. Two dice are rolled. What is the probability that their total is 11 or 12?
  4. A coin is flipped 3 times. What is the probability that all three flips give the same result (all heads or all tails)?
  5. 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.