30
$\begingroup$

This is a real-life puzzle encountered by one of my friends.

I want to arrive early to my class today. Exactly every $7$ minutes, there is a bus that arrives at the station near my dorm and will bring me to my school. In addition, I also want to fully refill my bottle with a dispenser's mineral water. There are two dispensers: one in my dorm and another one at the bus station near my school. It takes $3$ minutes to fully refill my bottle from either dispenser.

Assuming I can't tell when the bus arrives unless I'm already at the station and seeing it arrives (a.k.a. not by some kind of schedule/timetable), what is the best strategy for me to arrive early to my class?

  • Refill my bottle first, then try to take the bus;
  • Try to take the bus, then refill my bottle later; or
  • Refill some first, try to take the bus, then refill again later?

The best strategy means the earliest expected time to be in the class.

Note: You may assume the time taken for walking from dorm to dorm's dispenser, dorm's dispenser to the bus station, the bus trip, walking from bus to school's dispenser, and school's dispenser to class are all constants for every strategy. They are all also assumed to be in one line.

Bonus: What if the time taken to refill for both dispensers are different? What if the bus arrives every $2$, $3$, $120$, or $N$ minutes?

$\endgroup$
  • 4
    $\begingroup$ I think that some of the answers wrongly assume that there is a dispenser at the bus stop. There isn't. There are only two dispensers: one at the dorms and the second one at the bus stop at the destination. So it's not possible to wait for the bus AND fill the bottle up. $\endgroup$ – rhsquared Apr 24 '18 at 11:21
  • 16
    $\begingroup$ Possible migration to lifehacks.stackexchange.com ;) $~~$ (no, don't do this. it's a joke!) $\endgroup$ – Rubio Apr 24 '18 at 11:50
  • $\begingroup$ What time is it currently and what time does the class start? Define "early" (simply not "late", or arriving a set amount of time before class starts?). What else does your friend need to do prior to leaving? $\endgroup$ – Michael Richardson Apr 24 '18 at 14:24
  • $\begingroup$ @MichaelRichardson, it doesn't matter and you may neglect it :) While "early" can be defined as to enter the class as soon as possible. $\endgroup$ – athin Apr 25 '18 at 0:58
  • $\begingroup$ This is not clear to me. $\endgroup$ – paparazzo Apr 27 '18 at 13:42
34
$\begingroup$

Buses are devilish conundrums. I assume you don't have any clue on the bus schedule, which makes the time of waiting for a bus evenly distributed on an interval [0 min, 7 min]. That makes the time you spend on a station mean 3.5 min, no matter how much time you spend at home. So, if your intentions are to refill the bottle for sure, then you can fill what you want at home or at school.

on the practical side...

Though: If you can deal with missing the water sometimes: you should use school's dispenser to have a chance to leave if you are really late.

The problem is so bland that even the bonus makes no difference:

It doesn't matter how frequently the bus comes, as long as you cannot predict its schedule. Thus, if dispenser time differs, you just fill your bottle at a quicker dispenser – it will save you exactly the same time as if you just chose between two dispensers at hand.

$\endgroup$
  • $\begingroup$ +1 for the comment: if you are really late skip the refill after bus trip. (you might refill in a break) $\endgroup$ – Bernd Wilke πφ Apr 24 '18 at 13:59
  • 4
    $\begingroup$ +1 for being mathematically much more precise than Keelhaul's answer $\endgroup$ – ffao Apr 24 '18 at 18:23
  • $\begingroup$ I'm accepting this answer as it's more precise than Keelhaul's answer (plus it includes the bonus part). Congrats :) $\endgroup$ – athin Apr 25 '18 at 1:02
  • $\begingroup$ If you know (or, at least, trust) that the busses follow the schedule exactly, but can never remember what that schedule is, then choosing to fill the bottle at home rather thn at school converts time spent filling the bottle at school into a probability of getting to school 7 minutes later with a full bottle. Which one you want to go for is entirely up to you. $\endgroup$ – Arthur Apr 25 '18 at 11:58
37
$\begingroup$

I believe that the answer is

It's all equivalent. Since there's no way to parallelize some tasks, the time you'll take is entirely dependent on when the bus arrives, independently of when and where you fill your bottle.

To expand a bit on that, let's consider the 3 possible strategies (considering only the filling time and waiting time):

  1. Refill my bottle first, then try to take the bus

    Best case scenario, you take 3 minutes to fill your bottle, then get immediately on the bus: it took you 3 minutes (plus all the travelling, but we ignore that).
    Worst case scenario, you take 3 minutes to fill your bottle, then wait 7 minutes for the bus: it took you 10 minutes.

  2. Try to take the bus, then refill my bottle later

    Best case scenario, you take the bus immediately, then spend 3 minutes filling your bottle: total 3 minutes.
    Worst case scenario, you wait for the bus 7 minutes, and then spend 3 minutes filling your bottle: total 10 minutes.

  3. Refill some first, try to take the bus, then refill again later

    Best case scenario, you spend 1.5 minutes filling half your bottle, take the bus immediately, then spend 1.5 minutes filling your bottle again: total 3 minutes.
    Worst case scenario, you spend 1.5 minutes filling half your bottle, wait for the bus 7 minutes, then spend 1.5 minutes filling your bottle again: total 10 minutes.

In conclusion:

It's all the same. In the best case you get your bus immediately and "lose" 3 minutes, and in the worst case you wait 7 minutes for your bus and "lose" 10 minutes. Filling your bottle before or after has no impact on this.

$\endgroup$
8
$\begingroup$

There can be a faster solution in some cases, depending on the distance between the dispenser in the dorm and the bus station - which unfortunately was not given.

Let's say this takes OP's friend one minute.

Dorm Dispenser > (1min) > Dorm Station

OP's friend could check the departure time first and if it is >5 minutes go back to the dispenser and refill his bottle. This only works if the distance is short enough and the waiting time is long enough.

This is what the way of OP's friend would look like in case the bus leaves in more than 5 minutes and it takes the friend a minute or less to the dispenser.

DS > 1min > DD > refill 3min > 1min > DS

.. which equals to 5 minutes.

$\endgroup$
  • $\begingroup$ Interesting view on the problem! Unfortunatley OP specified that all the steps are assumed to be in one line, so I guess this going back and forth DS and DD is out of question... $\endgroup$ – Keelhaul Apr 24 '18 at 15:19
  • 1
    $\begingroup$ Ah, I was assuming the "may" was also applying to this sentence, but when reading carefully it seems it does not. As this is a real life problem and it surely is possible to go back and forth I will leave the answer here. ;) $\endgroup$ – Tom K. Apr 24 '18 at 15:41
  • $\begingroup$ If it's less than 5 minutes but more than 2, some time can also be saved by refilling the bottle partially at home and completing at school. $\endgroup$ – Maciej Stachowski Apr 24 '18 at 20:06
  • 1
    $\begingroup$ +1 for the hack of going back from the station. Unfortunately, there is no timetable there :'> $\endgroup$ – athin Apr 25 '18 at 1:04
  • 1
    $\begingroup$ @Chris, alright I'll clarify that on the statement, thanks before :D $\endgroup$ – athin May 3 '18 at 13:15
4
$\begingroup$

Let's say you spend $t$ minutes filling your bottle before taking the bus and $3-t$ after getting off. Assuming it takes the bus $u$ minutes to get to your school and you've reached the station in minute $m$, the time spent will be $7-m+u+3-t$ minutes if you catch the first bus. If $m>7-t$, you'll miss it by $m+t-7$ minutes, meaning you spend $14-m+u+3-t$ minutes. Let's find out about the expected time:

The bus waiting times for any value of $m$ increases or decreases in a linear piecewise function, which can be represented as such:

diagram

The maroon area is $(7+t)(7-t)/2 + (14+t)t/2 = (14t + 49)/2$. Including the time it takes to fill it for the second time, it makes $(14t + 49)/2 + 7(3-t) = 91/2 = 45.5$, so it doesn't matter how you use the dispensers.

PS. Just for the record:

We can see that the same applies no matter how often buses arrive at the station.

$\endgroup$
  • $\begingroup$ Sorry, I must have forgotten about it, but now changed it to the closest possible time. $\endgroup$ – Nautilus Apr 24 '18 at 17:28
  • $\begingroup$ Just realized there was a mistake in the picture, so I had to completely change the answer. $\endgroup$ – Nautilus Apr 24 '18 at 19:30
  • $\begingroup$ +1 for the nice diagram, :D $\endgroup$ – athin Apr 25 '18 at 1:10
3
$\begingroup$

The answer is that:

It is irrelevant. If the distribution of the arrival time of the bus is uniform, then the distribution of time to get to school is also uniform, with the same parameters whether we fill up first or afterward.

Here is some python code to simulate the situation. Change up the values as you like.

import numpy as np
import matplotlib.pyplot as plt

#time units in seconds
X = np.linspace(1,210000,210000)
to_bus = 60
to_class = 60
bus_ride = 60*10
fill = 3*60
bus = 60*7
bus_schedule = np.linspace(1,(210000+2100),(210000+2100)/bus)

@np.vectorize
def time_taken_bottle_first(x):
    time = x #start
    time += fill #fill bottle
    time += to_bus #get to the station
    time = bus_schedule[bus_schedule>=time][0] #catch the next bus
    time += bus_ride #ride the bus
    time += to_class #walk to class
    return time - x
@np.vectorize
def time_taken_bottle_last(x):
    time = x #start
    time += to_bus #get to the station
    time = bus_schedule[bus_schedule>=time][0] #catch the next bus
    time += bus_ride #ride the bus
    time += fill #fill bottle
    time += to_class #walk to class
    return time - x

bottle_first = time_taken_bottle_first(X)
bottle_last = time_taken_bottle_last(X)

plt.hist(bottle_first/60, weights = np.ones_like(bottle_first)/float(len(bottle_first)),rwidth=0.95)
plt.show()

plt.hist(bottle_last/60, weights = np.ones_like(bottle_last)/float(len(bottle_last)),rwidth=0.95)
plt.show()

This will dump out two pictures of the distributions of time to get to class, one filling up the bottle first, one filling up the bottle afterward.

Both histograms are identical (X-axis := time in minutes): The distributions

$\endgroup$
3
$\begingroup$

Here is my version, Mathematics with a bit of reality.

Let's assume two things:
You never know the schedule of the bus until you reach the bus stop.
Once at the bus stop, you can assume if the bus just went or if it is about to arrive thanks to crowd (no one means the bus just went).
first possibility The bus is about to arrive (lot of people), take it and fill your bottle at the arrival before school.
second possibility The bus station is empty, it is probable the bus just went, if the time needed to do Bus-Dorm + Fill_bottle + Dorm-Bus is less than the time between two bus then you may go back to your dorm, fill your bottle and then come back to take the bus.

One example

Let's say Dorm-bus time is 1 minute. You see no one at the bus station and so you go to your dorm, fill your bottle and walk back to the bus station in 5 minutes. Making it worth.

Issues with that strategy

If you are the only one to take the bus, then you are screwed. You have to be ready to walk some more to arrive earlier at school... As pointed out in comments, if there your bus is not the only bus then you can't use this strategy.

$\endgroup$
  • $\begingroup$ Where's the answer? $\endgroup$ – Astralbee Apr 24 '18 at 16:46
  • 1
    $\begingroup$ Some problems. First, how can you make assumptions based on the wait from the crowd - does only one bus come to this station? The question is about getting to class early - wouldn't you assume that most people get a later bus? You're bringing too many non-mathematical possibilities into your "mathematics with a bit of reality". This question is about maths and statistics, the OP has deliberately left out details like time from dorm-station. Secondly, why are there only two possibilities and how is "arriving soon" a mathematical reality? It's more like the vaguest of assumptions. $\endgroup$ – Astralbee Apr 24 '18 at 17:38
  • $\begingroup$ I was making the assumption that this the only bus coming and that people take the bus randomly (like uniform law). I must admit my answer is not really clear! "arriving soon" means the time needed to make the travel back and forth to dorm and refill the bottle is greater than waiting the bus. See Tom. K answer for a clearer way to explain that! $\endgroup$ – Untitpoi Apr 25 '18 at 8:12
2
$\begingroup$

The best strategy is:

Whatever, man. Fill the bottle up at your Dorm.

We have 6 points of interest: Dorm ($A$), Dispenser1 ($B$), Departure Bus-stop($C$), Arrival Bus-stop ($D$), Dispenser2 ($E$) and Class ($F$)

Since these are all on a line, we have to go in the order $A > B > C > D > E > F$, even if we do not stop.

As such, we can discard the time taken to travel between these points, and only need to pay attention to the time we spend waiting at $B$, $C$ or $E$.

Times $t(B) + t(E) = 3$, since we need to spend 3 minutes at 1 Water Dispenser, and 0 minutes at the other. $t(C)$, on the other hand, is variable - it is anywhere from $0$ (we arrived at the same time as the bus) to $7$ (we arrive just as the bus is leaving)

So, our Delay (which we want to minimise) is 3 minutes to fill the water bottle, plus however long we spend waiting for the bus.

If we define $t(X)$ as the time we would have to wait if $t(B)=0$, then we can construct the following table for filling at Dispenser 2 (Class):

[t(X) | Delay ]
[ 0 | 3 ] 0 mins for the bus + 3 mins for the water
[ 1 | 4 ] 1 min for the bus + 3 mins for the water
[ 2 | 5 ] 2 mins for the bus + 3 mins for the water
[ 3 | 6 ]
[ 4 | 7 ]
[ 5 | 8 ]
[ 6 | 9 ]
[ Avg | 6 ]
[  7  |  10    ]
[ Avg |   6.5  ]

And, if we fill our water bottle at Dispenser 1 (Dorm):

[t(X) | Delay ]
[ 0 | 7 ] We arrive 3 minutes late, and must wait 4 more minutes for the next bus
[ 1 | 8 ] We arrive 2 minutes late, and must wait 5 more minutes for the next bus
[ 2 | 9 ] We arrive 1 minute late, and must wait 6 more minutes for the next bus
[ 3 | 3 ] All 3 minutes waiting are spent filling our bottle, for 0 minutes at the bus-stop
[ 4 | 4 ] 3 of the 4 minutes are spent filling our bottle
[ 5 | 5 ]
[ 6 | 6 ]
[ Avg | 6 ]
[  7  |   7    ]
[ Avg |   6.125]

 

As you increase the resolution of the table (0.5 minutes, 0.1 minutes, etc) the average wait tends towards 6.5

Of course, the true optimal solution is:

Fill your bottle up the night before! Average delay: $3.5$ minutes

$\endgroup$
  • $\begingroup$ You have a t(X)=7 in the second table and not in the first, when fixing this the average delay is the same ;) $\endgroup$ – Keelhaul Apr 24 '18 at 15:16
  • $\begingroup$ @Keelhaul The average in the first table was for t(X)=0 to 7, but I missed a line typing the data out. The average for t(X)=0 to 6 is 6, not 6.5. The missing line has been added $\endgroup$ – Chronocidal Apr 24 '18 at 15:29
  • 4
    $\begingroup$ Having lines for both 0 and 7 minutes is double-counting that situation, artificially biasing it. (Note that in your calculations, the bus is twice as likely to leave just as you get to the bus stop, than it is to leave a minute later.) The solution is to remove the line from the first table, not to add it to the second. $\endgroup$ – Sneftel Apr 24 '18 at 16:48
  • $\begingroup$ @Sneftel You're right, I should have implied to remove the 7, which actually gives the same average, instead of merely saying there was a difference $\endgroup$ – Keelhaul Apr 24 '18 at 17:19
2
$\begingroup$

I would say...

It doesn't matter. You'll never get there on time and will be forever thirsty. This is due to the well-known (but sadly non-provable) law that:

  1. Buses are either always late or never arrive at all and
  2. Water dispensers usually don't work (in my experience)

Interestingly, despite this (obviously trolling) response, the result aligns with the actual accepted answer of 'no difference'

Congrats to the OP for creating a problem where even a joke response creates a paradoxically correct solution!

$\endgroup$
0
$\begingroup$

With the current information, there isn't a basis for there being a difference between the strategies. But with different conditions, there could be. For instance, suppose the bus passes by the dorm dispenser, so you know whether the bus has passed by while you have been filling the bottle. Then the following strategy is better than either filling at the dorm or at school:

Spend one minute filling up. If the bus passes, keep filling up. Otherwise, finish filling up at school. You have a 1/7 chance of "wasting" 4 minutes (you'll have to take a later bus, which is seven minutes away, but you can spend 3 of those minutes getting the bottle filled). You have a 6/7 chance of saving one minute. So you save on average 2/7 of a minute.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.