Monday, November 9, 2015

Room with four bulbs - PrismoSkills



Room with four bulbs - PrismoSkills
Puzzle: There is a room with a door (closed) and four light bulbs.
Outside the room there are four switches, connected to the bulbs.
It is not known before hand which switch connects to which bulb.
You may ON/OFF the switches as many times as you wish, but once you open the door you can't change them.
Identify each switch with its bulb.


Hint: Some out of the box thinking is required in this puzzle.


Solution: If there were two bulbs, and two switches only, then ON/OFF status would be enough to find the connection between the bulbs and the switches.
This could be done by employing the brightness property of the ON bulb.

For more than two bulbs, we need some more property of the bulbs to find the switches for number of bulbs.
Temperature of the bulb can be another such property.


ON first switch and third switch for half an hour.
OFF first switch, ON the 2nd switch and enter the room.

OFF and hot bulb belongs to switch 1.
ON and cold bulb belongs to switch 2.
ON and hot bulb belongs to switch 3.
OFF and cold bulb belongs to switch 4.

http://n1b-algo.blogspot.com/2015/02/finding-switch-light-bulb-association.html
Problem 1: There are three light bulbs in a room. Outside the room are three switches which operate those bulbs. You know that the bulbs are initially turned off and you can toggle the switches as much as you want. While you toggle the switches, you cant peek inside the room. Finally when you are done with the switches, you enter the room once and you have to tell which switch is associated with which bulb. 

1. Toggle switch 1 and wait for 10 mins. 
2. Toggle switch 1 and 2. 
3. Enter the room.
4. Touch all the bulbs and the bulb which is hot is associated with switch 1. 
5. Bulb which is on is associated with switch 2. 
6. Bulb which is off is associated with switch 3.

Problem 2: Same problem as 1, but now we dont know if the bulbs are initially on or off. So in a way we do not know if turning the switch up turns on the bulb or turns it off. All we know is that all the bulbs are in same state, i.e., all are either on or off. Now we have to toggle the switches and enter the room once and tell which switch operates which bulb. 
Read full article from Room with four bulbs - PrismoSkills

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts