IBM Research | Ponder This | July 2004 solutions
Skip to main content

July 2004

<<June July August>>


The solution is possible exactly when n is a power of 2.

Suppose n is not a power of 2, so n=r*2^s with r odd and r at least 3. Label the cups 0 through n-1. Also, "face-up" and "face-down" will be called values "0" and "1", respectively. Let the two "special" cups 0 and 2^s start out with opposite
orientations. In the requested move, consider the positions with labels (i*2^s, i=0,1,...,r-1). Since r is odd, the requests (move, non-move) among these r positions cannot strictly alternate: there are two requests, separated by exactly 2^s, which agree (either both are to move, or both are not to move). Imagine that the cups have been rotated before fulfilling this request, so that our two special cups (initially at 0 and 2^s) fall into these two positions. Then after the move, these two cups still have opposite orientations. This can go on forever, no matter what we request.

Suppose instead that n is a power of 2. We will use induction to create a sequence of (2^n)-1 requests which will satisfy the problem. If n=1, one move suffices: (0). (That is, we have a single request, which is to flip the single cup at position 0.) Either the cup is face up before the move, or it is afterwards. Now suppose n=2m, where m is a power of 2. Let S=(s_1,s_2,...,s_((2^m)-1)) be a sequence which works for m, where each s_i is a subset of {0,1,...,m-1}. Construct a sequence T=(t_1,t_2,...,t_((2^n)-1)) with t_i in {0,1,...,n-1}. The move t_(i*2^m) is s_i (it only operates on the first m elements); it is called an "outer move". The move t_(i*2^m+j), j=1,2,...,(2^m)-1, is (s_j,m+s_j). That is, operates on first m elements the same way s_j did, and also acts identically on the second m elements. These "inner moves" (t_(i*2^m+j), j nonzero) leave the relation between items x and m+x the same: either they remain identical or they remain opposite each other. Only the "outer moves" (t_(i*2^m)) change these relations. Keeping track of the relations, r_i=(x_i + x_(m_i)) mod 2, i=0,1,...,m-1, there are only m of them; one of the (2^m)-1 outer moves (say t_(i*2^m)) brings all these relations to all 0, by induction. Then during the block of inner moves between i*2^m and (i+1)*2^m, we have always x_k=x_(m+k), and the inner moves bring all the x_k (k<m) to 0, simultaneously bringing the x_(m+k) also to 0.

For n=2, the complete set of 3 moves is (0,1), (0), (0,1).

For n=4, the complete set of 15 moves is
(0,1,2,3), (0,2), (0,1,2,3), (0,1),
(0,1,2,3), (0,2), (0,1,2,3), (0),
(0,1,2,3), (0,2), (0,1,2,3), (0,1),
(0,1,2,3), (0,2), (0,1,2,3).

For n=8 there are 255 moves.

The number of moves, (2^n)-1, is clearly optimal: we get exactly 2^n chances to win (counting the initial position), and if the cups were initially random, each time we would have a chance 1/2^n of winning.

"Tomas Rokicki points out that the solution actually requires 2^n moves, rather than 2^n-1, because the genie does not tell us whether our initial configuration is already a winner."

If you have any problems you think we might enjoy, please send them in. All replies should be sent to: