
🌐 이 글의 한국어 원문이 있습니다.한국어 원문 보기 →
Expressing a Simple Probability Problem Elegantly with Math
While working through a probability problem, I found an insight in how the solution expressed the problem's situation 'mathematically,' so I'm jotting it down briefly. The problem is as follows.


In a parking lot with spaces in a single row, one person (Mary) parks, and then we want the probability that another person (Tom) parks with at most one space between him and Mary. In other words, the probability that he parks 'right next to' her or 'one space' away.
1. Let's build the sample space.
Let's simply call the parking positions indices and . Then the set of all possible parking outcomes can be expressed like this.
- The set of all outcomes uses the conventional notation .
- This is the key point: each outcome of where Mary and Tom parked is expressed as a pair .
- Then, for and , the physical constraint that two cars can't park in the same spot is defined as .
- And the fact that each can take any position is expressed as .
All the possible parking outcomes are expressed in just a single statement. This set of all outcomes is called the sample space.
The total number of outcomes can be found simply using permutations, as follows.
So we've expressed and computed the sample space. Then how can we express the event mathematically?
The gist is at most one empty space (at most one parking spaces).
How can we express this in math?
Surprisingly and elegantly, it can be expressed as the absolute value of the difference between and not exceeding .
What does this mean?
- The definition of an event can be expressed concisely as a 'formula.'
- If it can be expressed as a formula, it can also be expressed as code.
- Concise expression leads to 'simplified thinking.'
The outcomes can be represented in a diagram like the one below.

That said, would have to be at least greater than .
First, the diagonal line in the middle is excluded, because .
Then the four lines form two pairs. One is , and the other is ). Adding these pairs together and simplifying, we can give the probability as follows.
It's a problem you can solve by working through each case, even if that gets complicated. But let's take away from this one problem that it's possible to design the sample space and the event space mathematically like this.
