Puzzle: What's the number on my Hat?

I got this puzzle from Gurmeet Singh Manku's blog. Awesome CS guy he is. Good one! Give it a try.
Original Link
The solution proposed by Gurmeet was wrong. I have added a comment and I hope it would be corrected in some time.

Puzzle:
A goblin forewarns N gnomes as follows: “Tomorrow morning, I shall place one hat on each of you. Each hat shall be labeled 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 them devise a strategy?

Solution: (correct version)
Highlight the part between the * symbols for the answer.
* Let gnomes be numbered 0 thru N-1. The i-th gnome should announce (i – s) mod N, where s is the sum of numbers he sees. With this strategy, if the sum of all N numbers equals m mod N, then the m-th gnome is guaranteed to announce the number of his own hat! *

:)

Comments

  1. Say the gnomes are numbered from 0 to n-1 all the gnomes from 0 to n-2 can announce the sum of all the numbers they see... Say there are five :

    a b c d e numbers on cap,

    a announces : b+c+d+e
    b announces : a+c+d+e
    c announces : a+b+d+e
    d announces : a+b+c+e

    so summing all this we get

    3*(a+b+c+d) + 4*e with this e can announce number on his hat easily.

    Generalizing, for n persons the number on the last persons cap would be :

    (Sum of all the announced numbers - (n-2)*(Sum of all the numbers last person can see))/(n-1)

    ReplyDelete
    Replies
    1. I think they cannot hear what other gnome announces.. otherwise tell first one to announce the number in one of the gnomes hat and all the gnome announces same number.. so atleast one will be right on whom first gnome has seen the number..

      Delete
    2. If they can listen to what others are announcing then there is no point in the puzzle...

      Delete
    3. Right. Correct point Jeet. Thanks.

      Delete

Post a Comment

Popular posts from this blog

Buying Dimsums

Fraction Brainteaser

Consecutive Heads