Monday, July 14, 2008

Puzzle: Locker box and padlocks

Problem: Boris and Natasha live in different cities in a country with a corrupt postal service. Every box sent by mail is opened by the postal service, the contents stolen, and the box never delivered. Except: if the box is locked, then the postal service won't bother trying to open it (since there are so many other boxes whose contents are so much easier to steal) and the box is delivered unharmed.

Boris and Natasha each has a large supply of boxes of different sizes, each capable of being locked by padlocks. Also, Boris and Natasha each has a large supply of padlocks with matching keys. The padlocks have unique keys. Finally, Boris has a ring that he would like to send to Natasha. How can Boris send the ring to Natasha so that she can wear it (without either of them destroying any locks or boxes)?

Solution: They follow the following sequence of steps:
(1) Boris sends a locked box containing the ring to Natasha
(2) Natasha locks this box with her own padlock and sends it back to Boris
(3) Boris removes his padlock and then sends back the box to Natasha
(4) Natasha unlocks her padlock and gets her hands on the Ring

Sunday, July 13, 2008

Puzzle: Table with four coins

Problem: A square table has a coin at each corner. Design an execution sequence, each of whose steps consists of one of the following operations:

* ONE (O): The operation chooses a coin (possibly a different one with each execution of the operation) and flips it.
* SIDE (S): The operation chooses a side of the table and flips the two coins along that side.
* DIAG (D): The operation chooses a diagonal of the table and flips the two coins along that diagonal.

such that at some point during the execution (not necessarily at the end), a state where all coins are turned the same way (all heads or all tails) obtains.

Solution:
There are 3 types of configuration possible:
(a) all coins have same face up
(b) 3 coins have same face up (and 1 has the other face up)
(c) 2 coins have same face up (and other 2 have the other face up)

Config (a) is the desired final position. Configs (b) and (c) are potentially one step away from the final position F (where all coins have same side facing up). However, is there a config such that we can choose one of O, S or D and then we are guaranteed to reach the final desired position F ? Yes, there is. A special case of config (c) where the diagonally opposite coins have same face up is such a penultimate position:
H T     T H
T H  or  H T
Applying the D operation here will definitely result in F.

Perhaps our goal then should be to reach this position F' from other positions.

If two coins along a side have same face up, then F can be reached through F' by the following sequence: S, D.
Therefore, F can be reached from config (c) by the following sequence: D, S, D.

If a single coin is face up, then we have the following sequence towards F: O, D, S, D.

Applying this sequence to config (b) will definitely lead to F. Applying this sequence to config (c) however might result in config (b). Therefore this sequence must be repeated:
O, D, S, D, O, D, S, D.

This is the desired sequence of operations which will guarantee that the final position F is reached at some time during its execution.