Bathroom etiquette · Science
The Mathematics of the Urinal
Real mathematicians have studied where to stand. This page is mostly true, which sets it apart from the rest of the site.
Everything else we publish is a joke about manners. This is the exception. The question of which urinal to choose has been taken seriously by computer scientists, by a well-known cartoonist with a physics degree, and by probability theorists who were officially working on something else. The sources are listed at the foot of the page, and the arithmetic is simple enough to check with a pencil.
The urinal problem
In 2010 two computer scientists, Evangelos Kranakis and Danny Krizanc, published a paper called "The Urinal Problem". It opens with a man walking into a men's room with a row of empty urinals, and asks which one he should pick to keep his privacy for as long as possible, meaning the longest wait before somebody ends up standing next to him.
The answer depends on how everybody else behaves. Later arrivals might be lazy and take the nearest free urinal, or keep as far from other people as they can, or choose at random, and the best opening move shifts with each. The authors work through these models, and their conclusion is that you should take the urinal farthest from the door, provided the one beside it is free.
That is the conclusion the unwritten rules reached without any mathematics at all, which says something for the unwritten rules.
The rows that waste space
In September 2009 Randall Munroe, the author of the webcomic xkcd, wrote up a related question on his blog. Suppose everybody follows the standard protocol exactly: the first person takes an end, each new arrival takes the spot farthest from everyone already there, and nobody ever stands directly beside anybody else. How many people can a row of a given length actually hold before the next arrival has nowhere acceptable to go?
The best possible result is every other urinal in use. Some rows achieve it and some fall well short, and which is which follows a pattern:
- Five urinals: people take 1, then 5, then 3. Three in use, which is the most that five can hold. Perfect.
- Seven urinals: people take 1, then 7, then 4. The two gaps left are each two wide, so anyone else would have to stand beside someone. Three in use, where four would have fitted.
- Nine urinals: 1, 9, 5, then 3 and 7. Five in use. Perfect again.
- Thirteen urinals: only five get used, where seven would have fitted.
- Seventeen urinals: nine in use. Perfect.
The good row lengths are one more than a power of two: 3, 5, 9, 17, 33. Each new arrival splits a gap exactly in half, and the halving comes out even all the way down. The bad lengths are 7, 13, 25 and 49, where the splits leave gaps that are just too narrow to use. As those rows get longer, the share that is ever occupied falls towards a third.
We checked these figures ourselves by running the protocol for every row length up to 66. If you are ever asked to specify a bathroom, the mathematics says to order nine urinals, not seven. Nobody will ask you why. You will know.
What if nobody plans at all?
There is an older version of the question in probability theory, usually told about seats instead of urinals. People arrive one at a time and each takes a random place from those that are not next to anyone. When no such place is left, what fraction of the row is in use?
This is the unfriendly seating problem, posed in 1962 and solved soon afterwards. For a long row the answer settles at a fixed number: (1 − e−2) / 2, or about 43 per cent. Careful planning can reach 50 per cent. Bad luck with the row length can drag it towards 33. Pure chance lands in between, which is a fair summary of most things.
The experiment
The buffer is not only a convention. In 1976 three psychologists, Middlemist, Knowles and Matter, published a study in the Journal of Personality and Social Psychology with the title "Personal space invasions in the lavatory". Sixty men using a three-urinal lavatory found a stranger standing at the next urinal, one urinal away, or not there at all. The closer the stranger, the longer the men took to get started and the sooner they finished.
The stranger was working for the researchers, and the timing was done by an observer hidden in a stall. The following year the same journal published a reply questioning whether the study should have been done at all. It is fair to say the participants were not consulted, and that the result confirmed what every one of them could have told the researchers for free.
How the game scores distance
The Pee Game asks an easier question than the mathematicians do. It does not care what happens after you have chosen. It looks at the row as it stands and scores the spot you took.
- Standing directly beside someone is heavily penalised. A divider or privacy wings reduce the penalty without removing it.
- With no neighbour beside you, there is a bonus for distance from the nearest person in your row. It is larger when that person is three urinals along than when he is two, and largest at four or more, where it stops growing.
- An end urinal earns a small bonus of its own.
- If nothing in the row is acceptable, the least bad spot counts as correct.
So the game rewards the same instinct the papers describe: go far, prefer the end. What it adds is a clock, a queue, a man who will not stop talking and a janitor, none of whom appear in the literature. You can try the scoring on ten worked puzzles.
Sources
- Evangelos Kranakis and Danny Krizanc, "The Urinal Problem", in Fun with Algorithms (FUN 2010), Lecture Notes in Computer Science 6099, Springer, 2010.
- Randall Munroe, "Urinal protocol vulnerability", the xkcd blog, 2 September 2009.
- D. Freedman and L. Shepp, "An unfriendly seating arrangement", Problem 62-3, SIAM Review, 1962.
- R. D. Middlemist, E. S. Knowles and C. F. Matter, "Personal space invasions in the lavatory: suggestive evidence for arousal", Journal of Personality and Social Psychology 33, 1976; and G. P. Koocher, "Bathroom behavior and human dignity", in the same journal, 35, 1977.
A mostly true history of the urinal · The Urinal Code · More bathroom etiquette
Last updated 20 November 2026.