Kohl's Interview Question
Software Engineer in TestsCountry: United States
Interview Type: In-Person
Turn on one switch. Leave it on for half an hour. Turn on another switch and immediately walk upstairs.
The light that's off is the one you didn't touch. Of the two that are on, the room with light bulbs that are hot links to the first switch turned on, the room with light bulbs that are on but not hot is the second switch turned on.
turn on the swithch. go upstairs. remove one of the bulb which is not on. come down and turn on the next switch if it lights up thats the next one or else its the removed bulb
Let 1 define an ON state and 0 define an OFF state.
While there are 8 (2^3) mathematical scenarios for three binary positions, there are only two "logical" scenarios. Uniform [111,000] and Single-Exception {[100,010,001],[011,101,110]}
Begin this exercise upstairs.
If the lights in the rooms are UNIFORM, then simply complete the following:
Go downstairs and toggle switches A and C. Toggle switch A first and switch C a unit of time later. By toggling two of the three switches you have forced a Single-Exception scenario.
Go upstairs(!). The un-toggled switch (B) is your CONTROL switch and is assigned to the only bulb that did not change its state. A temperature comparison will reveal the final switch-bulb assignments. If the initial condition was 111, switch A is the cooler of the two (now 0) bulbs. If the initial condition was 000, then switch A controls the warmer of the two (now 1) bulbs.
If the lights in the rooms are SINGLE-EXCEPTION, do the following:
Remove the exception (the single 1 or 0 bulb) and note your remaining Uniform state [11 or 00].
Go downstairs and toggle switches A and C a unit of time apart.
Go upstairs(!)
You will observe one of two "logical" conditions Uniform [11,00] or Single-Exception [01,10].
If the condition is Uniform (and therefore inverse) both switches has toggled bulbs. The CONTROL switch (B) is assigned to the REMOVED bulb and the same temperature logic applies - switch A is the cooler bulb (if 11) and C is the warmer, or switch A is the warmer bulb (if 00) and C is the cooler.
If the condition is Single-Exception only one bulb has toggled. This means that the ONLY non-toggled remaining bulb is assigned to the CONTROL switch (B). Temperature logic can be used to determine which switch controls the toggled bulb. If the bulbs original state was 1 and it is cool, it is assigned to switch A. If it is warm it is assigned to switch C. If the bulbs original state was 0 and it is now warm it is assigned to switch A. If it is 1 and cool it is assigned to switch C.
Turn ON 1st switch for 10 min. and turn it off, turn on 2nd switch, leave 3rd one as it is.
- GAURAV October 05, 2014Now go upstairs, room with ON light is of 2nd switch, room with hot bulb is of the 1st one and another one is of 3rd.