The trip was a total of 120 miles, which at 8 miles to the gallon, used 15 gallons.
The outward trip of 60 miles was at 12 mph, which took 5 hours. The return trip was at 16 mph, which took 3.75 hours. Which is a total journey time of 8.75 hours, which meant that 8.75 gallons were lost.
So, 15 gallons were used for the trip, 8.75 gallons were lost, which is a total of 23.75 gallons. So the 24 gallons was enough for the return trip.