You are at the bottom of the elevator shaft of a 100 story building.
You see 21 wires labelled 1 2 3 … 21.
The wires go up to the 100th floor where the ends are labelled A B C … U, but you don’t know how they correspond to the ends at the bottom.
You have a battery, a light bulb, and many small wires.
What is the minimum number of trips required to find out the pairing between the letters and the numbers?
Note that connecting the small wires to form a wire 21 floor long is not an option.
Note that your battery, light bulb and small wires are basically a connection tester, and that “connected” is an equivalence relation.
At the bottom, leave 1 unconnected, connect 2 and 3 to each other, connect 4–6 to each other, 7–10, etc, so that we have “equivalence classes” of connectedness of sizes 1, 2, 3, 4, 5 and 6.
Now make a trip to the top, and figure out which letters are connected to nothing else, to one other letter, to two others, etc, until you have figured out the equivalence classes.
Now connect the first letters from each equivalence class (there are 6 of them) in a new equivalence class, the second from each (5 of them) in another, etc. Go to the bottom, remove the original connections, and figure out the new equivalence classes in a similar manner.
We now know from the first set of classes what groups of n letters (for n=1 to 6) at the top correspond to what groups of n numbers at the bottom. From the second set of classes we now know which letters and numbers were the “first” in their original classes, which were the “second,” etc, so we have the complete pairing.
This solution works cleanly for any triangular number of wires, but can be easily adapted to work for all natural numbers greater than 2.