|
|
|
|
|
by alex-g
4517 days ago
|
|
Suppose you don't have absolute clocks (so you don't know when it's 1pm) but you do have the ability to count time steps. Then you can solve the problem by "pinging" down to the end of the line and back, counting along the way. The first soldier sees the returned ping and fires immediately. The second soldier (who knows he's second, since when the ping went out, the message was only at "1") fires one interval after the returned ping passes by him, so that's the same time as the first soldier does it. Likewise, the third soldier fires two intervals after hearing the returned ping. Alas, in this scenario we don't even have the ability to count, since we have a limited number of internal states to use to store numbers. So the really clever part is to encode additional information in the flow of additional messages. For example, to find the middle soldier, we can send out two pings, one three times faster than the other. They meet when the slower ping has gone through half the soldiers, and the faster one has gone all the way down the line, and back through half the soldiers (it's three times faster). Additional pings of different speeds can bounce back and forth in order to divide the interval still further - effectively, recursing into narrower sub-lines. Everything is set up so that all of the sub-lines reach their minimal size - one soldier - at the same time, at which point they know it's time to fire. The "recursion" means that the number of states can be bounded, as there are only a few different "modes" for the soldiers to operate in, regardless of the length of the sub-line involved. |
|