How do you do this question?

There are two trips, but the distances are the same.
Trip #1: uphill, at 9 mph
Trip #2: downhill at 18 mph
Total round trip is 30 minutes.
Since he's going half the speed uphill, Trip #1 takes twice as long as Trip #2.
So if the time for Trip #2 is x, then the time for Trip #1 is 2x.
x + 2x = 30, so x=10
Trip #2 takes 10 minutes.
Trip #1 takes 20 minutes.
Trip #1: 20 minutes at 9 mph = 3 miles
Trip #2: 10 minutes at 18 mph = 3 miles
This means his school is 3 miles away.
If you want an equation to solve,
Let d = distance to school. We use d = r·t formula to set up that t = d/r
let t1 = time going to school and t2 = times going home
t1 + t2 = 30 and t1 = d/9 and t2 = d/18.
d/9 + d/18 = 0.5 (it's 0.5, because we need the time in hours)
mutiply both sides b 18
2d + d = 9
3d = 9
d = 3