You have a cable with 4 wires inside.

If they were color coded like this, it would be easy to tell which wires are which.

However, suppose they
**
aren't
**
color coded, but you have a potentiometer, which can detect if two ends of a wire are connected or not, and you can short together as many wires as you like on either end of the cable, including one you might have hooked to the potentiometer.

What is the minimum number of times you would need to hook up the potentiometer in order to guarantee the determination of which wires on one end connect to which wires on the other end?

**
Clarification:
**
No matter what the result of your measurements (i.e. assuming the worst case scenario), what is the minimum number of measurements that guarantees that you can determine the connectivity of all four wires?

**
Inspired by:
**
Brian Charlesworth

4
3
5
7
16
8
10
6

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

First off, there are $4! = 24$ different ways the wires could be connected up, and every time you make a measurement, you get one bit of information (connected or not connected).

So, the lower bound on the number of times you'd need to hook up the potentiometer is:

$\lceil \log_2(24) \rceil = 5$

And, you can do it with five measurements as follows:

Call the wires on one end A1, B1, C1, and D1, and the wires on the other end A2, B2, C2, and D2.

(1) Short A2 and B2 together, and hook the potentiometer between them and A1.

If it shows a connection, you know A1 connects to A2 or B2. Otherwise, you know that A1 connects to C2 or D2.

(2) Connect the potentiometer between A1 and one of the two that you know it has to be connect to.

Now you have determined which one A1 connects to with 2 hook ups.

So, now you have 3 wires you need to figure out the connectivity of, lets rename them E1, F1, and G1 on one end, and E2, F2, and G2 on the other end.

This can be done, as follows:

3) Measure E1 vs E2:

So, the most it should take is $\boxed5$ measurements.