• There are precisely 100 lights in a huge room.
• A switch panel outside the room has 100 switches each corresponding to one light in the room.
• None of the switches or lights are labeled, so its extremely difficult to identify which switches turns on which light.
• Stan is standing outside of the room and his task is to map each switch to its corresponding light using a marker pen.
• He has to accomplish this mapping in a minimum number of trips to the room.
• Initially all the lights are turned off.
Determine the minimum number of times Stan needs to enter the room to complete the mapping of each switch to its corresponding light.
• To check the state of a light Stan must enter the room. He cannot check it from outside.
• There is nothing related to the heating of a light.
This can be done in no less than 7 entries into the room.
Mark each switch with a consecutive binary number, beginning with 0000001. Use leading zeros so they all have 7 digits.
First turn on all the lights that have a 1 in the first position. Enter the room and put a 1 next to each of the lit bulbs and a zero next to each of the unlit bulbs.
Go back to the switch panel and turn off all the on switches, and turn on the ones that are marked with a 1 in the next consecutive position. Re-enter the room and mark a 1 or zero next to the previously placed mark, again depending on on or off status respectively.
Repeat until all the digits of each binary number are accounted for. That's 7 trips into the room.
Posted by Charlie
on 2022-11-28 09:09:35