All the Way to the Top - A problem left for readers

This is All the Way to the Top , which can be solved using brute-force since there are only 32 32 possibilities.

What's the minimum number of clicks Alice needs to check all 32 32 possibilities?

Bonus: Find the clicking sequnce.


The answer is 31.

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.

2 solutions

Chris Lewis
Jul 27, 2020

We can code the state of each input as 0 0 for "off" and 1 1 for "on". A particular combination is then represented in binary by a number in the range [ 0 , 2 n 1 ] \left[ 0,2^n-1 \right] , where there are n n input boxes ( 5 5 in the case of this problem).

Since there are 2 n 2^n states, and we start in a given state, the best we can possibly do is 2 n 1 2^n-1 clicks; but is this possible?

Let's start with a simpler case: n = 2 n=2 . The four states are 00 , 01 , 10 , 11 00,01,10,11 ; but this ordering doesn't work (at one point we change two bits). But reordering to 00 01 11 10 00 \to 01 \to 11 \to 10 does work.

If we think about the two bits as coordinates, the four points form the vertices of a square. "Clicking" moves us along an edge of this square.

So we need to find a path around a square that visits every vertex exactly once by travelling along edges.

This is easy for n = 2 n=2 ; the path we found above has this shape: \sqsupset

Now let's try n = 3 n=3 . Here the points we have to visit form a cube; again, clicking corresponds to moving along an edge. This is a bit harder to picture (but worth trying), but we can solve this with the n = 2 n=2 solution. Split the cube into two parallel squares; the path we'll take will visit the four vertices of the first square, then jump to the second square, and visit those four vertices. The path we get is 000 001 011 010 110 100 101 111 000 \to 001 \to 011 \to 010 \to 110 \to 100 \to 101 \to 111

Note that, as required, we only click one box each time. Also, there are various points we can make a choice about the path; but we only have to find one solution.

We can continue this idea for larger n n ; a 4 4 -d hypercube can be thought of as two parallel cubes; a 5 5 -d hypercube is two parallel 4 4 -d hypercubes.

An explicit example for n = 5 n=5 using this approach is below: 00000 00001 00011 00010 00110 00100 00101 00111 01111 01101 01100 01110 01010 01011 01001 01000 10000 10001 10011 10010 10110 10100 10101 10111 11111 11101 11000 11110 11010 11011 11001 11000 \begin{aligned} &00000 \to 00001 \to 00011 \to 00010 \to 00110 \to 00100 \to 00101 \to 00111 \\ \to &01111 \to 01101 \to 01100 \to 01110 \to 01010 \to 01011 \to 01001 \to 01000 \\ \to &10000 \to 10001 \to 10011 \to 10010 \to 10110 \to 10100 \to 10101 \to 10111 \\ \to &11111 \to 11101 \to 11000 \to 11110 \to 11010 \to 11011 \to 11001 \to 11000 \end{aligned}

(each row above corresponds to visiting the vertices of a cubic cell of the 5 5 -d hypercube)

This sequence is called Gray code .

Victor Chan - 8 months, 3 weeks ago
Prakash Mortha
Jul 26, 2020

Since Alice need to check all the 32 possibilities, which are all UNIQUE, Alice would have to either turn an input on or off. Since the each click makes a new combinations of inputs, Alice need 2^5=32 clicks to check every single possibility. But Alice has to subtract one off of 32 because the problem automatically checks one of the possible inputs, which is when all the inputs are off. Therefore, Alice needs 32-1 = 31 clicks to check all possibilities.

This shows 31 31 is the minimum possible number of clicks, but it's not obvious that each click gives you a new combination. Even with 3 3 inputs, it's a little tricky; you might start with 000 001 011 111 000 \to 001 \to 011 \to 111 which seems promising but it's not possible to finish that sequence in just four more clicks.

Chris Lewis - 10 months, 2 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...