We have two replies to your question, one from Penny and a second from Stephen La Rocque.
Emily, you don't need to know the time or distance.
For convenience just suppose that Luke and Slim met after 24 miles. In this case, Luke rode for an hour and walked for 3 hours - total time four hours. Slim walked for 3 hours and then rode for an hour. Thus in the 4 hours total time, the horse has been ridden for 2 hours and idle for 2 hours. The horse rests half of the time.
The same argument works for any distance. Try different distances. No matter how far Luke rides it takes Slim 3 times that amount to get to the place where Luke stops riding; now Luke walks three times as much as Slim rides. In total, 4 units of time of which the horse rides for 2 of them.
The question is "what PART of the time is the horse resting". This means ratios or fractions are important here, so it isn't necessary to know the total distance or time. In fact, you can just choose a distance that is convenient and figure out the times involved!
Let's say the "agreed on distance" is 4 miles. Since time = distance/speed, we know Luke rode the horse for 4 miles / 12 miles per hour = 1 /3 of one hour. That's 20 minutes. Then both boys are walking and the horse is resting until Slim walks up to her. Slim had to walk the first 4 miles, so he took 4 miles / 4 miles per hour = 1 hour to get to her. That means the horse was resting 40 minutes of that first hour.
Now Slim rides her for 4 miles (the same "agreed on distance"). That takes him 20 minutes, because each ride is the same speed for the same length, so it is the same time. Now Slim and the horse are at the 8 mile mark and an hour has gone by (40 minutes plus 20 minutes) since Luke started walking, so he's walked a total of 4 miles. This means all three are in the same place now! They are 8 miles from the starting point two hours later, and you can easily see how much time the horse spent carrying a rider and resting in that period of time.
Now you can see that we could choose any amount for the agreed on distance and we'd get the same ratio. An alternative approach can use algebra. If you do this carefully, you'll see that the time and the distance variables cancel out - that's why it doesn't matter what the agreed-on-distance is.
I hope this helps.
Stephen La Rocque>