Saturday, January 5, 2013

Puzzle # 2

Puzzle 2 : Take the last chip

Turkey sandwich was worried about an upcoming test in discrete maths and was finding it hard to get to sleep. Turkey awoke early in the morning, aroused by a devilish laughter, only to see an impish looking homunclus sitting at the bottom of the bed next to a seemingly infinte pile of chips. Hello turkey, it said, would you like to play a little game ? This pile contains 43546758343209876 chips and the bottom chip represents your immortal soul. The rules are quite simple. The first player takes some chips, but not all of them. After that we take it in turns to take some chips.

The only rule now is that a player cant take more in their turn than the previous player took. The winner is the player who takes the last chip. If I win I get to keep your soul and if you win, you get an A in the test. Would you like to go first or second ? Can you give turkey a strategy for playing no matter how many chips are there ?

Was that easy ? What if a player can take up to twice the number of chips that the previous player took. What is the best strategy now ?


(I would love you to first attempt before seeing my attempt on the problem).


My attempt :

For the first part of the problem, I took three cases :
1)  no of chips is odd : in that case, the player who plays first will win. I pick first, you pick second, that way when the odd number is reached, the first player will be the one to pick it.

2) no of chips is even but some odd multiple of 2 :  In that case (take 2*3), I claim that first player wins. Divide the whole pair of 6 (2*3) chips as follows :
_ _ | _ _ | _ _
First player aims to win each division of chips.
Suppose player 1 chooses the first 2 chips. Player 2 has two choices, choose 1 chip or 2 of'em.
If he chooses 1, the problem reduces to 1) where no of chips becomes odd.
If he chooses 2, the problem is a reduced version of the same problem.

3) no of chips is even but even multiple of 2 : This is a tricky case. I claim that in such a case, the person who goes second will win. Take the no 4.
For 4, if each takes 1 chip, second person will win.
If first takes 2 chips, second will take will take 2 and win
If first takes 3 chips, then also second will win.

In general, for 2* even number, I will divide the whole set of chips like the following :
_ _ _ _ | _ _ _ _ | _ _ _ _  |..... and so on

And I will play second. I willl win no matter what.


For the second part, I didn't  try much but my intuition says this :

Find out what range of 2^k-1 and 2^k the number lies in.
If k is even, I play first. Otherwise second.

Puzzle time

Puzzle 1 :

What's the number on my hat ?
A goblin forewarns n gnomes as follows : "Tomorrow morning, I shall place one hat on each of you.
Each hat shall be labled with some number drawn from the range [0,N-1]. Duplicates are allowed, so
two different hats might have the same label. Any gnome shall be able to see numbers on other hats but not his own !! When a bell rings, all gnomes shall simultaneously announce one number each. If any gnome succeeds in announcing the number on his own hat, all gnomes shall be set free." The gnomes have assembled in the evening to discuss their predicament. CAN YOU HELP  ??

(Recommend you to first try)





MY SOLUTION :



First Attempt : My first guess was that everyone will shout the lowest number they see. In that case let all have different hat numbers from 0 to N-1. In that case, all guys except the one with number 0 shall shout 0; and the guy with number 0 shall start saying "One..." and then immediately change it by shouting 0 (on hearing others). The problem here is, there is a condition that everyone shouts simultaneously.

Second solution : In my second solution, immediately after everyone assembles, they move "steps".Everyone  moves, that many number of steps, which he sees to be the minimum number amongst all hats. So in the case of everyone having different numbers, everyone will take 0 steps (i.e., wont move at all) except the guy with number 0, who will move 1 step. But he
will essentially know that 0 is the minimum through this strategy, and thus will shout 0  (along with everyone). In another case, lets assume everyone has the same number. So, everyone will take that number of steps, and will shout that number. Problem Solved.