Home » Other » General » Puzzle n°- Traverse through 100 doors, find which are open/closed **
Puzzle n°- Traverse through 100 doors, find which are open/closed ** Mon, 26 May 2014 11:07
 Lalit Kumar B Messages: 3123Registered: May 2013 Location: World Wide on the Web Senior Member
Problem: You have 100 doors in a row that are all initially closed. You make 100 passes by the doors. The first time through, you visit every door and toggle the door (if the door is closed, you open it; if it is open, you close it). The second time you only visit every 2nd door (door #2, #4, #6, ...). The third time, every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.

Question: Write a SQL to determine what state are the doors in after the last pass? Which are open, which are closed?

The doors can be considered as rown in table. A flag could be used as a column to store the status open/close.

P.S. : It has had been one of the favorite questions in management exams in the logical reasoning section.

Regards,
Lalit
Re: Puzzle n°- Traverse through 100 doors, find which are open/closed ** [message #614735 is a reply to message #614731] Mon, 26 May 2014 12:25
 Michel Cadot Messages: 65082Registered: March 2007 Location: Nanterre, France, http://... Senior MemberAccount Moderator

Same than Puzzle n°13 - light bulbs

Re: Puzzle n°- Traverse through 100 doors, find which are open/closed ** [message #614737 is a reply to message #614735] Mon, 26 May 2014 12:34
 Lalit Kumar B Messages: 3123Registered: May 2013 Location: World Wide on the Web Senior Member
Duh, how did I miss it in the puzzle menu sticky. Sorry

Let me find some other puzzles. Thanks Michel

[Updated on: Mon, 26 May 2014 13:51]

Report message to a moderator

 Previous Topic: Puzzle n°01 - Finding adjacent seats in theater ** Next Topic: Data modelling involving many-to-many relationship and parent child hierarchy
Goto Forum:

Current Time: Fri Jul 21 10:03:15 CDT 2017

Total time taken to generate the page: 0.09746 seconds