Can You Slay The Puzzle Of The Monsters’ Gems?

A FiveThirtyEight Riddler puzzle.

May 20, 2016


A video game requires you to slay monsters to collect gems. Every time you slay a monster, it drops one of three types of gems: a common gem, an uncommon gem or a rare gem. The probabilities of these gems being dropped are in the ratio of 3:2:1 — three common gems for every two uncommon gems for every one rare gem, on average. If you slay monsters until you have at least one of each of the three types of gems, how many of the most common gems will you end up with, on average?


from random import random

runs = 100000
total_c = 0
for _ in range(runs):
    c, u, r = 0, 0, 0
        p = random()
        if p <= 1/6:
            r += 1
        elif  p >= 1/6 and p <= 1/2:
            u += 1
            c += 1
        if c > 0 and r > 0 and u > 0:
    total_c += c
print("Average number of common gems:", total_c/runs)

The average number of common gems collected before we have one of each gem is \(3.65\).

Back to top