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?

my answer is 1 trip:

Connect 2 wires to the negative terminal calling this group n. Connect 4 wires to the positive terminal calling this group p. Leave the remaining 6 wires disconnected but in 2 separate groups of 3 one grouping twisted together and the other remaining separated calling these groups x and y respectively.

go to roof

Upon circuit testing 3 groups emerge they being the n and p groups diffiencated by their differing numbers and a third group of 6 being a combination of the x and y groups below. The way to separate these 6 wires into their repective groups is to connect one of 6 wires to an n group wire and another to a p group wire, thus accessing the battery terminals below. Now if the two wires selected from the 6 group are twisted togerther in the cellar then you will have made a circuit and you can test this with the light globe. If its a circuit then you know it belongs to the x group or alternativly the y group. By now you will have separated all wires into their groups that correlate with the groups below. Now label them n1,n2,p1,p2,p3,p4,x1,x2,x3,y1,y2 and y3 with the first letter in each name representing the group they belong to. Now twist one wire from one group with a wire from another group to make up 5 pairs with the proviso that any 2 groups can share only 1 wire, the remaining 2 wires leave separate. There would be more than one way to acheive this, but this is mine.......(n1,p1)(p2,x1)(p3,y1)(x2,y2)(x3,n2) with y3 and p4 on their own.

go to cellar(one trip)

Now having written down all the pairing combinations you can circuit test to find and label all the wire ends that correspond to the wire ends in the roof eg: To find the third pairing(p3,y1) you would circuit test p group with y group until you found a live circuit and this would be unique because you only allowed any two groups to have only one wire in common. The ones that are on their own you would find last being that they would be the only ones left in their respective groups.

so my answer is one trip.