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?
It can easily be done in 4 trips, so I'll start there and see if I can improve.
lable the wires in the basement 1-12. Tie 1-6 together and attach to battery, go to attic and see which wires light the bulb. These, lable 1-6. The others, lable 7-12.
Return to basement, tie 4-9 and attach to battery. Back on roof, The wires that light the bulb lable 4-6 or 7-9, whichever is appropriate considering the first labling. The wires that don't light the bulb are 1-3 and 10-12.
Basement: tie and attach 1, 4, 7, and 10. On the roof, lable those that light the lamp 1, 4, 7, 10.
Cellar: tie 2, 5, 8, and 11.
roof, lable the wires that light the bulb 2, 5, 8, and 11. Those that don't light it are 3, 6, 9, and 12.