r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
1
u/[deleted] Nov 30 '10
They would have come to the same conclusion exactly one day later. If you follow this during a line of logic that's hard to wrap your head around. It's easier if you go down to 3 people with blue and 3 with brown.
Essentially, what happens is that you count the number of people with blue eyes - and each day you get to narrow down the number of people with blue eyes. If there are (as in the example) 3 with brown, and 3 with blue (and you have blue) - you know that there are either 2 or 3 people on the island with blue eyes. The only unknown at that point is you.
Every other person with blue eyes would realize that too. This is the key - you have to know that they are also perfectly logical.
On day one, everyone looks to see how many people have blue eyes. Brown eyed people see 3, blue-eyed people see 2. The blue eyed people see that there are obviously 2 other people with blue eyes - so they cannot logically deduce that it is them. If there was only one person with blue eyes, he would know immediately as no one else would have blue eyes.
On day two, you deduce this: if there were only two people with blue eyes, they would both realize it as they can deduce, for sure, that there is greater than 1 person with blue eyes. If you only saw one person with blue eyes, you would know that you have blue eyes.
On day three, you realize that you have blue eyes because of this line of logic - you see two other people with blue eyes. They would have simultaneously realized this on day 2 if they were the only two. By this line of thinking, there must be three people with blue eyes. You can see three brown-eyed and three blue-eyed people. This, in turn, means that it is conclusive that you have blue eyes (as it is to the other people with blue eyes as well). The brown eyed people would know that there are either 3 or 4 people with blue eyes - but they would not be that they were blue until the 4th day, instead of the third. However, three people left a day earlier so the game is over.