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, N1]. 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 N1. The ith 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 mth gnome is guaranteed to announce the number of his own hat! *
:)
Quant, Math & Computer Science Puzzles for Interview Preparation & Brain Teasing
A collection of ~225 Puzzles with Solutions (classified by difficulty and topic)
Subscribe to:
Post Comments (Atom)
Fraction Brainteaser
Source: Sent to me by Gaurav Sinha Problem: Siddhant writes a Maths test and correctly answers 5 out of 6 Arithmetic questions and 20...

This is not a puzzle. So, for those of you who follow this puzzle blog, please bear with me for just one post. Interesting Math in this art...

Source: Sent to me by Gaurav Sinha Problem: Siddhant writes a Maths test and correctly answers 5 out of 6 Arithmetic questions and 20...

Let's say A keep tossing a fair coin, until he get 2 consecutive heads, define X to be the number of tosses for this process; B keep tos...
Say the gnomes are numbered from 0 to n1 all the gnomes from 0 to n2 can announce the sum of all the numbers they see... Say there are five :
ReplyDeletea 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  (n2)*(Sum of all the numbers last person can see))/(n1)
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..
DeleteIf they can listen to what others are announcing then there is no point in the puzzle...
DeleteRight. Correct point Jeet. Thanks.
Delete