How I encountered math in real life

Konstantin Bobenko

  ·  4 min read

The game #

This is the math behind Hand-it, a party game I built that my friends and I play whenever we get together. The nice thing about the game is that it doesn’t take over the evening and you don’t sit around a board the whole time. It just runs quietly in the background while you eat, talk, and hang out.

How it works #

The setup is simple:

  1. Everyone writes their name on a small piece of paper.
  2. The papers are folded, mixed up, and each person secretly draws a paper with another person’s name on it.

From there, the rules are as these:

  • Your mission is to hand your target any object at all. A fork, a beer bottle, a napkin, whatever’s nearby.
  • If your target accepts the item, they’re eliminated.
  • When you eliminate someone, you take the name they drew and inherit their target. Now you are chasing someone new.

How to win #

You win the game in one of two ways:

  • You get your own name from a person you have eliminated
  • You’re the last player still standing.

As fun as it is, we ran into a couple of problems over the years. The first one shows up before the game even starts.

Problem 1: drawing your own name #

When the papers get mixed up and everyone draws, there’s always a chance that someone pulls their own name. That player can’t very well go after themselves, which means everyone has to hand the names they drew back, shuffle, and draw all over again.

Suppose there are $n$ players. Look at a single player first. They draw one name out of $n$, and only one of those names is their own, so the chance they avoid it is

$$\frac{n-1}{n} = 1 - \frac{1}{n}.$$

If we treat the players as drawing roughly independently, the chance that all $n$ players avoid their own name is that fraction multiplied by itself $n$ times:

$$\left(\frac{n-1}{n}\right)^{n} = \left(1 - \frac{1}{n}\right)^{n}.$$

As $n$ approaches infinity, this probability approaches a fixed value of:

$$\lim_{n \to \infty} \left(1 - \frac{1}{n}\right)^{n} = \frac{1}{e} \approx 0.368.$$

So for an infinite number of players:

The probability of a clean draw (nobody picks themselves) is about $1/e \approx 37\%$.

How many tries until it works? #

If a single attempt succeeds with probability $p$, then the average number of attempts you need before getting a clean draw is just the reciprocal, $1/p$, which is the mean of a geometric distribution.

For an infinitely large group the average number of tries approaches

$$\frac{1}{1/e} = e \approx 2.72.$$

But how does this look for a real number of players?

Players ($n$)Clean draw ($p$)Redraw ($1-p$)Avg. tries until clean ($1/p$)
329.6296%70.3704%3.3750
532.7680%67.2320%3.0518
1034.8678%65.1322%2.8680
$\infty$$1/e \approx 36.7879\%$$1 - 1/e \approx 63.2121\%$$e \approx 2.7183$

Even with just a handful of players the numbers are already close to their limiting value: you can expect to shuffle and redraw roughly three times before the game can finally start.

Problem 2: the dead loop #

Take five players, and suppose the draw comes out like this:

  • A is after B, and B is after A.
  • C is after D, D is after E, and E is after C.
ABdead loopCDE

The moment A hands B an object, A inherits B’s target, which is A. A wins instantly while the other three players still continue to play the game.

Bigger loops are gentler, but the issue is the same: every separate loop produces its own winner and removes everyone in it. The more we split players into small loops, the more people drop out early.

The fix: a Hamiltonian cycle #

What we really want is a single loop through everyone — in graph terms, a Hamiltonian cycle. One unbroken loop that runs through every player.

ABCDE

Hand It is a digital version of this game. Grab some friends and give it a go.