Can Xiaoming catch the bus?

Jul 28, 2026 / 3 min read

Xiaoming and the Bus

One day my friend sent me the following problem:

“Xiaoming goes to work by bus every day, he arrives at the bus stop at any time(equally likely) between 6:30 - 7:30, the bus arrives at 7:00 - 8:00, the bus leaves immediately after picking up all waiting passengers. Arrival times of Xiaoming and bus are independent. What is the chance that Xiaoming catches the bus?”

Lets Draw the Answer

I did some arithmetic calculation and quickly gave up and started to draw on the paper, since I had seen some posts on the internet solving probability problems using visualization, which left an impression on me, also I like the feeling of drawing 2d diagram to solve leetcode dynamic programming problems.

xiaoming-and-bus Once you visualize it, the problem becomes very intuitive.

The x-axis is Xiaoming’s arrival time and y-axis the bus’s. Xiaoming always arrives before 7:30, that is on the left side of blue dashed line, the bus arrives after 7:00, thus above the orange line, the upper left 4 blocks rectangle is where we need to consider, the rest are outside the scope of the problem.

Then there is another constraint, since Xiaoming catches the bus if and only if he arrives before the bus, $y$ must be greater than $x$, we can draw a diagonal line (the green dashed one). The area above this line satisfies $y \gt x$, and below it , $y \lt x$. (i.e., Xiaoming catches the bus only in the region above the green line), this cuts off a triangular corner of one of our block.

So among four blocks the problem defines, only the lower-right triangle does not satisfy $y \gt x$, for all $x,y$ pair inside green shaded region, Xiaoming catches the bus. Thus we have the answer $=\frac{Area\,of\,green\,shaded\,region}{Area\,of\,upper\,left\,rectangle}=\frac{7}{8}$.

A Less Excited One

After I read a probability textbook, I found there is an ugly and less excited solution.

Lets 0 correspond to time 6:30, then Xiaoming arrives between 0 - 60 and bus 30 - 90.

Let the arrival time of Xiaoming be a random variable $X$, with probability density function $f_X(x) = \frac{1}{60-0} = \frac{1}{60}$, and arrival time of bus $Y$, $f_Y(y) = \frac{1}{90-30} = \frac{1}{60}$, since they are uniform random variables.

Since X and Y are independent, their joint probability density function is $f_{X,Y}(x,y)=f_X(x)f_Y(y)=\frac{1}{3600}$.

Xiaoming catches the bus if and only if $X \le Y$, and notice if Xiaoming arrives before 7:00 (i.e., $0 \leq X \leq 30$), he always catches the bus.

Therefore,

$$ \begin{aligned} P\{X\lt Y\} &= \iint_{x\lt y} f_{X,Y}(x,y)\,dy\,dx \\ &= \int_{0}^{30} f_X(x)dx + \int_{30}^{60}\int_{x}^{90} f_X(x)f_Y(y)\,dy\,dx \\ &= \int_{0}^{30} \frac{1}{60}dx + \int_{30}^{60}\int_{x}^{90} \left( \frac{1}{60} \right) ^2\,dy\,dx \\ &= \frac{1}{2} + \frac{1350}{3600} \\ &= \frac{7}{8} \end{aligned} $$