There are twelve wires that run from your cellar to your roof. Unfortunately on their journey they could be randomly mixed up, so you can't tell which cellar wire-end corresponds to which roof wire-end. You have a battery and a light bulb, and you can temporarily twist wires together. You can also travel from the cellar to the roof and back again any number of times. Thus you can construct circuits and test the wires at either end in order to deduce what is going on. But it’s a long way to the roof. So, starting at the bottom, what is the minimum number of journeys you have to make, in order to work out exactly which wire-end in the cellar corresponds with which wire-end on the roof?
Probably my age, my former solution is not four trips, it is three trips, you start in the basement.
There is another solution with three trips, max number of wires is twelve (I think).
Suppose you have six wires, go to the cellar and number the wires one to twelve. Connect 2 to 3 and 4 to 5 and 6
Go tot the top with your battery and bulb. Look for a wire, that connected to your battery and bulb does not give light when connecting to any other wire. This wire is wire 1. Label it A. Look for a wire that lights the bulb in connection with only one wire. This wire is wire 2 or wire 3. Label them B and C. Look for a wire that lights the bulb in connection with two wires. This wire is wire 4, 5 or wire 6. Label them D, E and F. Connect B and D to A, connect C and E. Leave F alone
Go back down. Look for a wire, that connected to your battery and bulb does not give light when connecting to any other wire. This wire is wire F. Label it F. Look for a wire that lights the bulb in connection with only one wire. This wire is wire C if it comes from the original couple (2 and 3) connection, it is D if it comes from the original triple (3, 4 and 5) connection. Now use the same technique for a wire that gives light with 2 others. For twelve wires you have to do the above in two groups of six and find out what wires belong to which group of six. This you do by joining 2 to 12 to one pole of the battery, 1 to the other.
Go to the top with the bulb and look for the single wire that lights the bulb. This is wire 1.
I think that with more then 12 wires you will need to go to the former solution I posted.