wood burning stoves*
The moose likes Programming Diversions and the fly likes Lights and Switches Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Lights and Switches" Watch "Lights and Switches" New topic
Author

Lights and Switches

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Just saw this on slashdot and couldnt see it here so I thought I would share.

Given:
* One room has three switches, labeled A, B, and C.
* Another room has three light bulbs, labeled 1, 2, and 3.
* Each switch is connected to one bulb, but you do not know which is connected to which.
* When inside either room, you cannot see the other room.
* You begin in the room with the switches and may turn the switches on and off in any way you choose.
* Once you leave the room with the switches, you may not reenter it. You may, however, go to the room with the light bulbs.

How can you determine which switch is connected to which light?
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Well I think this might work

Go to the room which contains switches, if any button is switched on switch off that button and wait for a while say about 1/2 an hour then switch on any of the button for awhile say about 15 minutes and then switch it off. Then switch on one of the remaining two buttons and leave the room. Enter the room which contain bulbs the bulb which is switched off but is slightly warm is the bulb connected with the switch you first switched on for about 15 minutes, the switched on bulb is connected with the switch you switched on next and the bulb which is off and is cold is connected with the third button.
[ October 16, 2005: Message edited by: Sameer Jamal ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

very close, except that 'slightly warm' cannot be determined in this case.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
David -

Just to be sure...

Do we know for sure that off means off for all of the switches? Do we know that at the start of the problem all of the lights are off, or do we know the state of the lights when we start?

Thanks!


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Originally posted by David O'Meara:
very close, except that 'slightly warm' cannot be determined in this case.


Ok the bulb which is warmest
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
there are three switches a b c
and three respective bulbs.
but we dont know exact order of bulb .

to find the solution of a problem
suppose initial condition is all the bulb are switched off

now we will not touch switch a (switch a is off)
we will switch on bulb b (for 5 min) than switch it off.
so now switch b is also off
now put switch c on (so one bulb is glowing )


now we will go in second room

we will find only one bulb glowing (that is c)
and one bulb warm ( that is b)
and one bulb that is cold taht is a.


hi david am i right , or i m thinking in wrong direction
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yup, sounds about right.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

turn on switch a, and make sure b and c are off.

for fun, at various intervals, flip A on and off. continue this for 30 years.

turn on swith b.

go into room. the light that is on is b. examine the other two bulbs to see which filament is broken - this is A. the other bulb that is off is C.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Now that, sirs, is lateral thinking
Randall Kippen
Greenhorn

Joined: Oct 18, 2005
Posts: 15
1. punch a hole in the wall
2. pull all 3 wires as far as they will go
(in other words, they will be touching the ceiling).
3. lower each wire a different distance
Now go to the other room, and match distance to wire.

1. punch a hole in the wall
2. cut all 3 wires (careful not to get electricuted)
3. tear off pieces of your clothes that are different colors
4. attach pieces to wire securely
5. go to other room, pull lightbulbs until end of wire.
6. match color to switch
Abhishek Sawant
Greenhorn

Joined: Feb 21, 2010
Posts: 13
Three bulbs are A,B,C
Three switches are X,Y,Z.

Turn on switch X, you don't know which bulb is glowing inside... never mind you'll know it soon...
Keep switch X on for 15 minutes.
Now, turn off X, turn on Y.
go to room with light bulbs.

Bulb glowing belongs to switch Y.
Now touch remaining two bulbs.
Warmer bulb belongs to switch X.
and remaining bulb belongs to switch Z. You didn't turn it on...
right?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14155
    
  18

Right, but a little late, since samdeep aarzoo already gave the same answer on 16 October 2005 (see above).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

I wonder if we need to rethink this problem. In the past five years, CFL's have become much more commonplace. And, they don't heat up nearly as much, so using the 'see which bulb is still warm' approach may not work much longer...
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1007
    
    3
fred rosenberger wrote:I wonder if we need to rethink this problem. In the past five years, CFL's have become much more commonplace. And, they don't heat up nearly as much, so using the 'see which bulb is still warm' approach may not work much longer...


I've noticed that the CFLs in our bed room continue to glow faintly for a good five minutes after the switch is turned off. However I do kinda doubt one would be able to distinguish the faint glow and an electrified one is nearby. It depends on how the light bulbs are arranged in the room, how isolatable they are and how much ambient light there is.

Even though the tube part of a CFL stays more-or-less cool, do the base and or light socket become noticeably warmer? I may have to do some experimentation tonight.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
CFLs do become warm, only less so than incandescent bulbs.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
CFLs take a minute or so until they reach full brightness. If one walks over to the other room right after turning on one of the switches, the brightness might still be distinguishable from the one that's been turned on for a while.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3561
    
  15
fred rosenberger wrote:I wonder if we need to rethink this problem. In the past five years, CFL's have become much more commonplace. And, they don't heat up nearly as much, so using the 'see which bulb is still warm' approach may not work much longer...


You may also have to extend the time frame for your alternative suggestion. CFLs are supposed to have a much longer life than a normal bulb.
It could be a project you can pass on to your children and grandchildren


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
I haven't got any grandchildren, Joanne. Well, not yet.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I don't remember posting this
Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Interesting. I was asked this on a job interview five years; the same year as the original post! My initial response was "What kind of light bulbs?" Which got a smile out of the interviewer.
Think he also asked the Die Hard2 water jug question. (Or was it Die Hard3, I can never remember)
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

#3, #2 was at the airport
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Lights and Switches