An island has 1,000,000 inhabitants. Each inhabitant has blue eyes or brown eyes. There are no reflective surfaces on the island, so no inhabitant knows their own eye color. The custom of the island also prevents anyone from talking or communicating about eye colors. The inhabitants are otherwise completely logical, able to deduce everything that can be deduced in an hour or so. If anyone knows their eye color, they must leave the island at the next midnight, never to return. All inhabitants know this paragraph.
An outsider that wants to wreck havoc arrives at the island and declares that there are a composite number of inhabitants who have blue eyes, before promptly fleeing. What is the minimum possible number of midnights after which the island gets completely deserted, no matter how many inhabitants with blue eyes there were initially?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This is not written formally yet; I skip a lot of details to present mostly the main idea.
Yes, this is a variant of the well-known blue-eyed islander puzzle. The usual question is that the statement by the outsider is "there is a blue-eyed islander", and this variant is "there is a composite number of blue-eyed islanders". (I hope I didn't botch up the first paragraph, because it's very crucial to the puzzle, but I hope that if you already know the problem, you can take from it.)
First, you need to prove yourself that whatever nontrivial statement it is (a trivial statement is true for all numbers of blue-eyed islanders; a nontrivial statement is false for some number), the island will eventually get deserted. The proof is by induction, as usual. Or you can read the proof here .
If you also know how the proof goes, the induction step works as follows. If n is the actual number of blue-eyed islanders, and m is the closest number to n where the statement is false if there are m blue-eyed islanders, then:
Finally, it's just the task of finding the smallest k such that all islanders will leave by the k -th midnight, no matter what n was initially. Since the forbidden numbers are the prime numbers (and 0 and 1), this is equivalent to finding the largest gap between two prime numbers; our n will be precisely in the middle between these two prime numbers. (There is an additional complication near the edges; for example, with n = 1 0 0 0 0 0 0 , m cannot be larger, so it will be eliminated by the case n > m only. As it turns out, this one doesn't matter; m = 9 9 9 9 8 3 , so n = 1 0 0 0 0 0 0 is eliminated by the 18th midnight.)
This is a simple task to program. Simply sieve the prime numbers up to 1000000 and find the largest gap. This occurs between 492113 and 492227, with a gap of 114; at n = 4 9 2 1 7 0 , the last case will occur after 57 midnights, and this is our answer.