Demento-Santa (deluxe edition)

Demento-Santa enters the workshop at his evil lair on the South Pole where he is holding a number of elves he has kidnapped from Santa's workshop at the North Pole. He offers them a grand bargain. Although they're starved, tired, and can't even support their own weight, he'll open the bay doors and let the elves make a run for it if some subset of 2 n 1 2^n -1 (for an integer n n ) elves can play and survive the following game:

  1. First, Demento-Santa puts the elves into separate the rooms and affixes a 0 or 1 (randomly) to the forehead of each elf. In each room is a set of closed-circuit monitors that allow each elf to see every other elf, but not themselves. In other words, each elf can see the numbers of the other elves but not their own number. On Demento-Santa's command, every elf must either guess the number on his head, or decline to guess. If no elves guess, they all instantly die. If any elf guesses incorrectly, they also all die. If the elves that guess all guess correctly, they survive this stage of the grand bargain.

  2. Demento-Santa has a radioactive element, Mousekingium, in his collection. It is special, just for Demento-Christmas, and has a half-life of exactly 69 seconds. He will put one atom of Mousekingium into a box. If it takes longer to decay (in seconds) than there are elves playing the game, the elves win the second round and the bay doors open.

The question is: how many of the elves should play in the game if the elves want to maximize their chance for survival?

Details and assumptions

  • The elves all guess at the same time and cannot communicate with each other once the game begins.
  • The elves can discuss a strategy before the game begins.
  • Mousekingium decays like any normal radioactive element.
  • The number of elves that play the game must be of the form 2 n 1 2^n -1 .


The answer is 7.

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.

1 solution

Josh Silverman Staff
Dec 22, 2013

The skills required for this deluxe challenge branch the realms of physics, combinatorics, and algebraic coding, and requires the confidence to believe in your answer for two separate substantial problems in order to arrive safely at the end of this glorious road. Normally this would be separated into two, and it would probably be best to have more than 3 attempts allowed, but I figured many people will have extra time around the holidays. With that, let us look at the elve's first challenge.

First challenge

At first glance, it appears that the elves can learn absolutely nothing by looking at the numbers of the other elves. Let's look at the possibile outcomes:

    Elf1     Elf2    Elf3
       1        1       1
       1        1       0
       1        0       1
       0        1       1
       1        0       0
       0        1       0
       0        0       1
       0        0       0

Consider this table from the perspective of a single elf. If Elf1 looks around and sees distinct numbers on the heads of the other elves, there is a 50% chance that he has a 0 or a 1. Similarly, if he sees the same number on the heads of the two other elves, he has a 50% chance of being a 0 or a 1.

Now, consider the middle six cases from the perspective of the group:

    Elf1     Elf2    Elf3
       1        1       0
       1        0       1
       0        1       1
       1        0       0
       0        1       0
       0        0       1

in these six cases, the elves can always win if they use the following strategy:

  1. If an elf looks at the other two and sees different numbers, they refuse to guess.
  2. If an elf looks at the other two and sees the same number, they guess the opposite number.

In these six cases, only one elf will guess in any given round and they'll always guess correctly.

In the remaining cases:

    Elf1     Elf2    Elf3
       1        1       1
       0        0       0

every elf will guess and they will all guess incorrectly. Across all assignments, this strategy yields an expected survival rate of 3/4.

This may appear as though information has appeared magically from nowhere. This (magic) would be the case if the individual elves were able to increase their ability to guess the number on their head.

In fact, it must be the case that, in the aggregate, each elf has still just a 50% chance of success at guessing his number. The strategy does not give them any new information.

Looking at any given elf, we see that each one makes two successful guesses and two incorrect guesses using the strategy so described. Therefore, each elf has a 50% success rate, as expected. What increases the population survival rate is the concentration of the wrong guesses. I.e. the elves are able to pack all of their wrong guesses into just two of the eight assignment cases.

Putting aside the task of identifying the actual guessing rules, we can generalize the above logic to find the maximum possible survival rate for a given number of elves.

Let's see if we can improve our chances with 4 elves. Again, each elf has a 50% success rate in their individual guesswork.

Overall, there must be 2 S 2S guesses made, where S S is the total number of successful guesses. If we try to match the success rate from the three elf cases, we'd need 3 4 × 16 = 12 \displaystyle\frac34\times 16 = 12 successful guesses, and 12 12 unsuccessful guesses. This is feasible because we can spread 12 successful guesses across 12 cases, leaving four cases (with room for 16 guesses) into which we must fit just 12 unsuccessful guesses. Let's call the fully packed unsuccessful guess cases "death strings".

Let's try for 13 successful guesses, making a survival rate of 13 16 = 81.25 % \displaystyle\frac{13}{16} = 81.25\% . This would require us to fit 13 successful guesses into twelve rounds and 13 unsuccessful guesses into three death strings. But three death strings only have a capacity for 12 ( 3 N 3N ) guesses. Clearly this is not possible. The best strategy for 4 elves is then to match the strategy of 3 elves which can be achieved with either a more complicated guessing rule or simply by having one of the elves sit out from the game entirely (always refuse to guess).

In the 3 elf case we are able to make full use of the guess space to pack incorrect guesses into a small subspace of the guess space. In the 4 elf case we are unable to leverage the extra volume we're afforded. Generalizing a bit, we can see what condition must be met for us to maximally leverage the volume of the space and increase our chances from 3 4 \frac34 .

In a space of N N elves, to have S S isolated successful guesses maximally pack a space, we must have S S unsuccessful guesses that we will pack into death strings of length N N , yielding S / N S/N death strings. We then have 2 N S / N 2^N - S/N strings available to spread the correct guesses. This gives us a self-consistent equation for S = U S = U :

2 N U N = U 2^N-\frac{U}{N} = U

which implies S = 2 N 1 + 1 / N S = \frac{2^N}{1+1/N} or S = N 1 + N 2 N S = \frac{N}{1+N}2^N . The success rate of the maximal packing strategy is the number of successful guess strings relative to the total number of guess strings:

S / 2 N = N 1 + N S/2^N = \displaystyle\frac{N}{1+N}

Now, the maximal packings will occur whenever the expression for the number of successful guess strings is an integer, i.e. when N + 1 N+1 divides 2 N 2^N . This is true whenever N + 1 = 2 k N+1 = 2^k for some integer k k . Therefore, N N elves can maximally pack their incorrect guesses into death strings whenever N = 2 k 1 N = 2^k-1 .

When this is true, they'll have a survival rate of

S 2 N = 2 N 2 N 1 + N 2 N = N 1 + N \frac{S}{2^N} = \frac{2^N - \frac{2^N}{1+N}}{2^N} = \frac{N}{1+N}

The maximal survival rate jumps whenever the number of elves playing the game, N N , is equal to 2 k 1 2^k-1 k N \forall k \in \mathbb{N} .

We can reflect these jumps by writing the survival rate in terms of N N as the floor of the log \log of N N . The survival rate as a function of N N is

2 log 2 ( N + 1 ) 1 2 log 2 ( N + 1 ) \frac{\displaystyle 2^{\left\lfloor \log_2 (N+1)\right\rfloor }-1}{\displaystyle 2^{\left\lfloor \log_2 (N+1)\right\rfloor }}

img img

This leaves the task of identifying the death strings, which we'll describe in a Python program at the end.

Second challenge

The second part of the challenge requires the elves to calculate the distribution of first passage times for radioactive decay, i.e., the probability that the atom's decay event doesn't happen until t t seconds have passed.

First, let's consider the role of the half-life. If a group of radioactive atoms decay with the rate k k , then we expect the number of undecayed atoms to change as N ˙ ( t ) = k N ( t ) \dot{N}(t) = -kN(t) . The solution is given by N / N 0 = exp k t N/N_0 = \exp -kt . We can find the half life of the atoms by solving for t t in 1 2 = exp k t \frac12 = \exp -kt , yielding t 1 / 2 = ln 2 k \displaystyle t_{1/2} = \frac{\ln 2}{k} , or equivalently, k = ln 2 t 1 / 2 k = \frac{\ln 2}{t_{1/2}} .

Therefore, Mousekingium atoms, which have a half-life of 69 s 69\mbox{ s} , have a decay rate of k 69 = ln 2 69 s k_{69} = \frac{\ln 2}{69} \displaystyle \mbox{ s} .

Now, let's suppose there are a large number of identical Mousekingium atoms at time t = 0 t = 0 and let P 0 ( t ) P_0(t) be the probability that a given atom of Mousekingium has not decayed by time t t . This probability decays as

P 0 ˙ ( t ) = k 69 P 0 ( t ) \dot{P_0}(t) = -k_{69}P_0(t)

(because systems with undecayed atoms decay at the rate k k ) which yields P 0 ( t ) = exp k 69 t P_0(t) = \exp{-k_{69}t} . Therefore, the probability that the atom of Mousekingium lasts until t t seconds or later is given by exp k 69 t \exp -k_{69}t .

For our elves, who pick n n elves to play the game, the chance that the atom won't decay until N N seconds is exp k 69 N \exp-k_{69}N .

Putting it all together

From the first part, we have the chance for survival as a function of the number of players: P 1 = 1 2 log 2 ( N + 1 ) P_1 = \displaystyle 1- 2^{-\left\lfloor \log_2 (N+1)\right\rfloor } . The chance for the atom of Mousekingium to last longer in seconds than the number of players is given by P 2 = exp k 69 n P_2 = \exp-k_{69}n . Since this function monotonically decays with the number of players, we only have to consider the jump points of the first game in determining the optimal number of players to choose, i.e. where N = 2 k 1 N = 2^k-1 : 3,7,15,31, et cetera.

The probability of the elves surviving the first game is given by P 1 P_1 and is independent of the chance for them to survive the second game P 2 P_2 . The chances for them to survive both games is then P 1 × P 2 = 1 2 log 2 ( N + 1 ) exp k 69 N P_1 \times P_2 = \displaystyle 1- 2^{-\left\lfloor \log_2 (N+1)\right\rfloor } \exp-k_{69}N .

We can finish the problem off by plotting this quantity over the series: 3, 7, 15, 31, ... :

img img

Numerically:

 N  P1*P2
 1  0.495
 3  0.728
 7  0.816*
15  0.806
31  0.710
63  0.523

we see that 7 is the optimal number of elves to play in order to maximize the chance for survival, assuming the elves can divine the death string maximal packing strategy and remember how to calculate first passage times.

Appendix

We gave a proof that the maximum survival rate for N N elves in the first game is given by 1 2 log 2 ( N + 1 ) \displaystyle 1- 2^{-\left\lfloor \log_2 (N+1)\right\rfloor } but we didn't identify the death strings in that space. Here we display the death strings for the case of 7 elves.

According to the calculation, for 7 elves we have 2 N N 1 + N = 112 2^N\frac{N}{1+N} = 112 successful guess strings and 128 112 = 16 128-112 = 16 death strings. Now, considering the death strings with a metric of the Hamming distance, defined as the number of bit flips required to move between two strings:

Hamming ( 111 , 101 ) = 1 \mbox{Hamming}(111,101) = 1 Hamming ( 111 , 010 ) = 2 \mbox{Hamming}(111,010) = 2 Hamming ( 001 , 001 ) = 0 \mbox{Hamming}(001,001) = 0

et cetera.

Each guess string in the space will have 7 nearest neighbors (flipping an entry at each position in the string).

It wouldn't make any sense for any of the nearest neighbors of a death string to also be death strings. If it were, we could have, for instance, both 1111000 1111000 and 1111010 1111010 as death strings.

In either case, Elf6's information is the same, therefore, Elf6 would be make the same guess in both cases. This is a contradiction however as both are supposed to be death strings. He can't make an incorrect guess both times by guessing the same thing both times if his number is different in both cases.

Therefore, the death strings have a Hamming distance of at least 2 from one another.

If each set of nearest neighbors to death strings is unique, they would account for all 16 × 7 = 112 16\times 7 = 112 safe strings. If we go to next nearest neighbors, each death string would have 42 possibilities, which means that there is crossover between the next nearest neighbors of any pair of death strings.

This implies that each death string has a unique set of nearest neighbors, which touch a neutral network of shared next nearest neighbors which in turn are one step from another death string (after passing through another unique set of nearest neighbors), giving each death string a distance of at least 1 + 1 + 1 = 3 1 + 1 + 1 = 3 from any other death string.

This reduces the problem of finding the death strings to finding a set of 16 strings that are all 3 or more away from one another. We can assign the remaining 112 cases to successful guess strings.

The following Python program builds up the library of 128 strings in the 7 elf guess space and then filters them until all remaining strings have a Hamming distance of at least 3 to one another:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    def hamming(s1, s2):
        return sum(d1 != d2 for d1, d2 in zip(s1,s2))

    def check(a):
        return [hamming(item1,item2) for item1 in a 
        for item2 in a[a.index(item1):len(a)] if item1 != item2]

    initialset = ['1', '0']

    for i in range(6):
        tempset = []
        for item in initialset:
            tempset.append(str(item + '1')) 
            tempset.append(str(item + '0'))
        initialset = tempset

    a = initialset[:1]
    for item in initialset[1:]:
        temp = a + [item]   
        if min(check(temp)) == 3:
            a.append(item)

    for item in a:
        print item

This returns the following set of death strings:

1111111
1111000
1100110
1100001
1010101
1010010
1001100
1001011
0110100
0110011
0101101
0101010
0011110
0011001
0000111
0000000

At that, we conclude the deluxe challenge.

Sorry, but I don't think your solution is correct --- it is actually possible to leverage extra volume in the general case without N + 1 N + 1 needing to reach the next power of 2, becuase you don't need to maximally pack the space to do so.

Just take 5 elves, for instance. By having two elves sit out, we spread 24 unsuccessful guesses across 8 death strings, and can attain a success rate of 3 4 \frac{3}{4} as above. However, improving this is possible, because unlike what happens with 4 elves, 25 unsuccessful guesses can be held by 7 death strings ( 25 35 = 7 × 5 25 \leq 35 = 7 \times 5 unsuccessful guesses). It's alright if more than one elf guesses correctly in some successful strings. In general, the optimal strategy depends on a minimal binary covering code ( http://oeis.org/A000983 , which gives a formula for the optimal probability of winning this exact game).

It appears that not much is known about later terms of this sequence when N N is not one less than a power of two. If this table (PDF) is up-to-date, the current best known lower bound for length-11 binary covering codes is 180. So it's possible that a length-11 size-180 binary covering code exists; if so, then 11 elves would have ( 1 180 2 11 ) × ( 1 2 ) ( 11 69 ) 0.81669 \left(1 - \frac{180}{2^{11}}\right) \times \left(\frac{1}{2}\right)^{\left(\frac{11}{69}\right)} \approx 0.81669 probability of surviving. This would be very slightly better than 7 elves' survival chances of 0.81558 0.81558 .

Brian Chen - 7 years, 5 months ago

Log in to reply

hah, no need to be sorry about anything.

25 unsuccessful guesses can be held by 7 death strings ( unsuccessful guesses).

that's true

the current best known lower bound for length-11 binary covering codes is 180

i wasn't aware the lower bound for K ( 11 , 1 ) K(11,1) was shown to be 180. i recalled 185 when i was writing this problem. if the K ( 11 , 1 ) K(11,1) is 183, 7 would still be optimal. if it is between 180 and 182, 11 would become the new optimum.

to be fair, i didn't give the elves a supercomputer in the problem so i'm confident 7 would be the best one at their disposal (and perhaps the best in truth) but ruling out (or in) 11 as the best is still an open problem, as you say. the problem should be restricted to 2 k 1 2^k-1 .

Josh Silverman Staff - 7 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...