A bunch of
As you might have guessed, the only way to gain information in this setup is to connect some set of wires at one end, walk up to the other end, and test for conductivity — this would give some partial labeling information. The process may have to be repeated many times before a complete labeling can be constructed. And since each such step involves walking across the distance of the wires, we wish to solve the problem with the least number of trips.
It should be easy to convince oneself that this problem cannot be solved when n = 2 — there’s really nothing we can use to break the symmetry of the situation.
For n = 3, we can use the following simple procedure (see the illustration on the right):
- Step 1: Connect the and wires at the labeled end, walk up to the unlabeled end, and test for conductivity. The pair that conducts electricity would be and , although we cannot determine exactly which is or at this point, and the remaining wire is uniquely identified as . For notation, we use lowercase letters for the labelings that we discover, versus uppercase letters for the given labeling.
- Step 2: Connect the newly identified wire with any one of the wires (recall, we don’t know which is or individually, only that one is and the other ). Now walk back to the labeled side and test for conductivity of with the remaining wires. If we find that — is conducting, then the wire we hooked up on the other side was really , otherwise it was .
The case n = 4 can be solved similarly with just two trip: Hook up — on one side and then run conductivity tests on the other side to partition the wires into two groups — and —; then hook up one from each of the two groups together etc.
So the question is: Can the problem be solved for all n with just two trips?
The General Case
The wire identification problem is one of those puzzles that is deceptively simple in its description, whose small cases are easy enough to solve in the head, and yet a fair amount of math goes into proving the general result.
Knuth states the following idea, attributed to Kenneth Knowlton, to solve the general problem:
Partition into disjoint sets in two ways and , subject to the condition that at most one element appears in -set of cardinality and a -set of cardinality , for each and . We can then use the coordinates to identify each element.
Knuth in his paper translates the problem of Knowlton-Graham partitions in terms of 0/1-matrices. Lemma 1 in that paper states: Knowlton-Graham partitions exist for iff there’s a 0/1-matrix having row sums and column sums such that and are multiples of and .
Let’s use this lemma to label a set of 6 wires (). Since we can write 6 = 1 + 2 + 3, a rather obvious matrix satisfying the conditions of the lemma is:
Guided by this matrix, here’s our two-trip identification procedure:
- On the labeled side, hook up wires in the following groups: , , and .
- Walk over to the unlabeled side, run the conductivity tests, and make the corresponding groups , , and .
- Still on the unlabeled side, hook up the wires in the groups , , and . Note that we still don’t know exactly which wire is, say, ; but we do know the two wires of which one if and the other .
- Walk over to the labeled side, unhook the connection we had made in the first step, and check for conductivity. The sole wire here, say, would correspond to the the sole wire from the group on the other side. Similarly, the connected-pair of — corresponds to the pair on the other side. etc.
Navin Goyal, Sachin Lodha, and S. Muthukrishnan consider some variants & generalizations of the wire identification problem in their paper The Graham-Knowlton Problem Revisited. In particular, they consider the restrictions to just hooking up pairs in the identification process (in our examples above, we were free to hook, say, 3 wires).