Herllo, metlx!

A bicylcist cycled from town $\displaystyle A$ to town $\displaystyle B$ and back in 4 hours.

His speed on the flat part of the road was 16 km/h.

His speed going uphill was 12 km/h, and his speed going downhill was 24 km/h.

What is the distance between towns $\displaystyle A$ and $\displaystyle B$? Code:

*
x * * y
* *
* *
A * - * - * - - - - - - - - - - * - * - * - * B
: - w - : : - - z - - :

Let $\displaystyle w,x,y,z$ be the distances for the four phases of the ride.

$\displaystyle \text{From }A\text{ to }B.$

. . $\displaystyle \begin{array}{cc}\text{He rode }w\text{ km at 16 kph.} & \text{This took: }\frac{w}{16}\text{ hours.} \\

\text{He rode }x\text{ km at 12 kph.} & \text{This took: }\frac{x}{12}\text{ hours.} \\

\text{He rode: }y\text{ km at 24 kph.} &\text{This took: }\frac{y}{24}\text{ hours.} \\

\text{He rode: }z\text{ km at 16 kph.} & \text{This took: }\frac{z}{16}\text{ hours.}\end{array}$

His ride from A to B took: .$\displaystyle \frac{w}{16} + \frac{x}{12} + \frac{y}{24} + \frac{z}{16}\:=\:\frac{3w+4x+2y+3z}{48}$ hours.

$\displaystyle \text{From }B\text{ to }A.$

. . $\displaystyle \begin{array}{cc}\text{He rode }z\text{ km at 16 kph.} & \text{This took: }\frac{z}{16}\text{ hours.} \\

\text{He rode }y\text{ km at 12 kph.} & \text{This took: }\frac{y}{12}\text{ hours.} \\

\text{He rode }x\text{ km at 24 kph.} & \text{This took: }\frac{x}{24}\text{ hours.} \\

\text{He rode }w\text{ km at 16 kph.} & \text{This took: }\frac{w}{16}\text{ hours.} \end{array}$

His ride from B to A took: .$\displaystyle \frac{z}{16} + \frac{y}{12} + \frac{x}{24} + \frac{w}{16} \:=\:\frac{3w + 2x + 4y + 3z}{48}$ hours.

The round trip took 4 hours.

. . $\displaystyle \frac{3w + 4x + 2y + 3z}{48} + \frac{3w + 2x + 4y + 3z}{48} \:=\:4 \quad\Rightarrow\quad 6w + 6x + 6y + 6z \:=\:192$

Therefore: . $\displaystyle w + x + y + z \:=\:32\text{ km}$