It’s been a very long time since I’ve updated this, and while some if it has been laziness on my part, most of the blame can be blamed on Northwestern EDI — an awesome Master’s program I started about 2 months ago (also the last time I posted an update). It’s been a great experience so far, and the program’s going to be the catalyst for a lot of the work I’ll be posting from here on out.
Without further ado, The Riddler [Express].
For those that aren’t familiar, The Riddler is a weekly puzzle series from Oliver Roeder at FiveThirtyEight that usually involves some combination of math, logic and probability. The Riddler Express is a simpler version of the classic Riddler.
Four people have to cross an old, rickety bridge over deep, cold water infested with sharks, alligators, crocodiles and shrieking eels. The bridge is so old that it can hold no more than two people at any given time. It’s the middle of the night, so on every trip across the bridge, the person crossing needs to use the group’s only flashlight to cross safely. The four people who need to cross all walk at different speeds. One of them takes one minute to cross, one takes two minutes, one takes five minutes and one takes 10 minutes. If two people cross together, they need to stay together to share the flashlight, so they cross at the speed of the slower person. For example, the one-minute person can cross with the 10-minute person, and that trip would take 10 minutes.
How quickly can all four people get across the bridge?
So your first thought, as mine was, might have been to include the 1 Minute man (hereby referred to as 1M) in every transaction. That gives us a solution in 19 minutes (as illustrated by the gif below!).
1
If my excellent artwork didn’t make sense, here’s a table explaining what happened.
Side A | Side B | Time Elapsed |
1M, 2M, 5M, 10M | X | 0 Minutes |
5M, 10M | 1M, 2M | 2 Minutes |
1M, 5M, 10M | 2M | 3 Minutes |
10M | 1M, 2M, 5M | 8 Minutes |
1M, 10M | 2M, 5M | 9 Minutes |
X | 1M, 2M, 5M, 10M | 19 Minutes |
So that gets us at a modest 19 minutes, but actually we can do better. Instead of making 1M run all over the place, we’re going to give him a break on Side B. The issue with the above solution is that we’re wasting a total of 15 minute getting 10M and 5M across. Ideally, you’d like 10M and 5M to go across together to mitigate the lost time, but still make it so that one of them doesn’t have to walk back.
The below gif illustrates the optimal solution of 17 minutes.
Again, if that didn’t make sense here’s a table:
Side A | Side B | Time Elapsed |
1M, 2M, 5M, 10M | X | 0 Minutes |
5M, 10M | 1M, 2M | 2 Minutes |
1M, 5M, 10M | 2M | 3 Minutes |
1M | 2M, 5M, 10M | 13 Minutes |
1M, 2M | 5M, 10M | 15 Minutes |
X | 1M, 2M, 5M, 10M | 17 Minutes |
You can see here that we were able to save time by making 5M & 10M go over together without making one of them walk back, giving the optimal solution of 17 minutes.