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?

Hugo you are right, it would short the battery out, so my revised version is below. Your combination solution though the cascading circuit testing is a more elegant adaption of my solution. Therefor I think that it will be what the author will be looking for, congratulations. The only thing I had trouble with is the last paragraph where you say to use h to identify g, you would of already identified g when you found h because they still twisted together in the cellar. Instead of connecting h to the terminal you would connect g to find f, on finding f you would automatically find e(original cellar pairing) and so on. I think this is what you meant. Both solutions acheive the objective in one trip but yours is more elegant.

Connect 2 wires to the negative terminal calling this group n. Connect 3 wires to the positive terminal calling this group p. Leave the remaining 7 wires disconnected but in 2 separate groups of 3 and 4 , with the 3 grouping twisted together and the other 4 group remaining separated calling these groups x and y groups 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 7 being a combination of the x and y groups in the cellar. The way to separate these 7 wires into their repective groups is to connect one of 7 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 7 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,y1)(p1,x1)(p2,y2)(x2,y3)(x3,n2) with y4 and p3 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(p2,y2) 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.