Monday, January 12, 2015

Some Puzzles and Solutions

1.     
Puzzle 1:  Problem: you have 100 doors in a row that are all initially closed. you make 100 passes by the doors starting with the first door every time. the first time through you visit every door and toggle the door (if the door is closed, you open it, if its 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.What state are the doors in after the last pass? which are open which are closed?
      
      Solution 1: A door will be closed when an even number of passes are made at it and open when an odd number of passes are made at it. To determine the number of passes at a door consider the door number 4. It will be passed during 1st, 2nd and 4th visit, which means it will be passed 3 times, which is an odd number so on final pass it will be open. Similarly, door number 8 will be passed on 1st, 2nd, 4th and 8th visit, so door 8 will be passed 4 times which is an even number, hence the door will be closed on final pass. Now the number of passes for 8, which is 4 is actually 8's divisor, similarly there are 3 divisors for number 4. 
      Now as we know 'When the number is a square, the number of divisors will be odd. When it's not a square then the number of divisors will be even.'  So all the square integers like 1,4,9,16,25,36,49,64,81,100 will have odd number of divisors, so at the end only these 10 doors will be open.