The Mathematics of Urinals

Using restroom etiquette as an excuse to talk combinatorics.

Matthew Yuan
5 min readJul 4, 2020

If you use urinals in public bathrooms, then you probably know the golden rule of urinal etiquette: Don’t pee standing next to someone else.¹

One stick figure peeing at a urinal right next to another stick figure. One says, “Hi friend!” The other says, “…”
Poor right guy.

What you may not know, however, is how many standing arrangements actually uphold that rule. Lucky for you, this is exactly what we’ll be exploring today!

Definitions.

Let’s say that a standing arrangement of some people at some urinals is well-spaced if no two people are standing next to each other. Let S(n) be the set of possible well-spaced arrangements at n urinals, and let S(n, k) be the subset of S(n) of arrangements with exactly k people. Our goal is to come up with formulas for the sizes of S(n) and S(n, k), which we denote by |S(n)| and |S(n, k)|. To see what this all means, consider the following example.

A stick figure drawing of all thirteen well-spaced standing arrangements at five urinals.
The thirteen well-spaced arrangements at five urinals.

Pictured here is S(5), which contains thirteen arrangements (note that we include the empty arrangement). Then S(5, 2) consists of the arrangements in the picture with two people, of which there are six. So, we write |S(5)|= 13 and |S(5, 2)|= 6. Similarly, |S(5, 0)|= 1 and |S(5, 5)|= 0. We want to find a way to compute these kinds of values without explicitly drawing every standing arrangement.

A formula for |S(n)|.

There are lots of ways we might group the arrangements of S(n), like by number of people, by symmetry, or by aesthetic preference, but there’s one grouping that reveals a really nice recurrence relation.

An animation that transforms S(5) into S(4) and S(3).
Animation Magic transforms S(5) into S(4) and S(3).

Here we have S(5) again, but arrangements with their first urinal occupied are in the first column and arrangements with their first urinal empty are in the remaining columns. Everything in the “first occupied” group must have an empty second urinal (otherwise they wouldn’t be well-spaced), so they can only differ by what shows up in their last three urinals. The arrangements in the “first empty” group, however, can differ in their last four urinals. By the application of Animation Magic, we can see that grouping the arrangements of S(5) in this way reveals it to be nothing more than S(4) and S(3) taken together, with some urinals strategically tacked on the front.

In general we have the recurrence relation |S(n)|=|S(n – 1)|+|S(n – 2)|, and our initial conditions are |S(0)|= 1 and |S(1)|= 2 (which you can verify by drawing the pictures out yourself).

LaTeX equations that describe the recurrence relation for |S(n)|.

This is the Fibonacci sequence, but shifted by two places! If we write the nth Fibonacci number as F_n, then we have

LaTeX equation that says |S(n)| equals the n+2th Fibonacci number.

Man, that Fibonacci guy really does show up in everything.

A Fibonacci spiral atop a tweet complaining about people putting Fibonacci spirals on top of everything.
Ok to be clear, almost all of these Fibonacci spiral memes are bogus, but what we did here is real, I swear.

A formula for |S(n, k)|.

We were able to gain insight into S(n) by strategically removing certain urinals. In order to understand S(n, k), we will employ a more complicated removal process.

An animation that transforms S(7, 3) into the set of all arrangements of three people at five urinals.
Animation Magic (now with 30% more visual artifacts!) transforms S(7, 3) into the set of all arrangements of three people at five urinals.

Above we have S(7, 3), the set of well-spaced arrangements of three people at seven urinals. Since the arrangements are well-spaced, there is guaranteed to be at least one urinal between persons 1 and 2, and another between persons 2 and 3. If we remove a urinal from each of the spaces between people, we end up with standing arrangements of three people at five urinals. In fact, we end up with all standing arrangements of three people at five urinals, both well-spaced and, uh, ill-spaced, I guess. In this way, we eliminate the spacing requirement and our question boils down to this: How many ways can we put three (identical) things into five spots? Well that’s just a binomial coefficient! You know, those numbers in Pascal’s triangle.

A hotline bling meme where Drake dislikes a stack of binomial expansions but likes Pascal’s triangle.
Pascal’s triangle memes really can’t hold a candle to Fibonacci spiral memes.

|S(7, 3)| is equal to the binomial coefficient we call “five choose three,” which equals ten. If we have k people at n urinals, then we end up removing k – 1 urinals, so we have

LaTeX equation that says |S(n, k)| equals n-k+1 choose k.

And with that, we’ve achieved everything we’ve set out to do.

But wait, there’s more!

We know from their definitions that |S(n)| is the sum of the |S(n, k)|’s over all² k,

LaTeX equation that says|S(n)| the sum of |S(n, k)| over all k.

We found a formula for the left side and we also found a formula for every term on the right side. Invoking those formulas gives us

LaTeX equation that says F_{n+2} equals n+1 choose 0 plus n choose 1 plus n-1 choose 2, and so on.

which we can rewrite as

LaTeX equation that’s the same as the previous one, but with indices shifted to F_n.

Woah. This elegant formula gives us a way to compute a large Fibonacci number without computing all the Fibonacci numbers before it!

A screenshot from Desmos that calculates the fortieth Fibonacci number using the formula we just derived.
Plug the formula into Desmos and bam, you’ve got the fortieth Fibonacci number.

The next time you pee at a urinal, I hope you think about how the thing you’re aiming at is the mathematical link between Fibonacci numbers and binomial coefficients. At the very least, I hope you’re able to ward off unwanted restroom companions with well-informed complaints.

Ten urinals, four stick figures bunched on the right side. The rightmost guy says, “There were 35 better ways to do this!”
Right guy takes a stand.
  1. Unless there’s no other choice, of course. The rule mainly condemns the people who choose to stand right next to you when open urinals are aplenty.
  2. We are free to let k increase forever because once k gets big enough, all subsequent terms in the sum are zero. For instance, what’s the number of well-spaced arrangements of four people in six urinals?

--

--

Matthew Yuan

“Every being cries out silently to be read differently.” Simone Weil