5

The problem is a generalization of this uyhip riddle. A similar puzzle has also been discussed in Puzzle Toad.

A prisoner has been trapped in a dark room, and he can only escape if he could successfully solve out the following puzzle:

In front of the prisoner is a large circular table with $n$ poker cards equidistantly placed along the perimeter of the table. He can feel the cards but cannot tell if each one of them is face-up or face-down due to the darkness. The prisoner is allowed to turn over any subset of the cards each time. Once he finishes doing so, a check will be made and the prisoner will be freed if all cards are face-up.

Unfortunately, the table will be rotated by a supervisor after a fixed number of tries. After each rotation, the prisoner will be unable to recognize the previous position of any of the cards. Furthermore, the supervisor knows exactly the prisoner's strategy and will always rotate the table in a way to hinder the prisoner's success.

Now we let $\varphi(n)$ be the least number such that the prisoner may come up with a winning strategy in finitely many times when table is rotated after every $\varphi(n)$ tries.

It has been already proved that $$\varphi(2^k)=1,\qquad \forall k\textrm{ non-negative integer}.$$

It is also easy to show $\varphi(3)\leq 3$. And I believe we actually have $\varphi(3)= 3$. Here goes the questions:

  1. Is it true that $\varphi(5)\leq 5$? In general, do we have $\varphi(n)\leq n$?

  2. Is it true that $\varphi(2^k m)=\varphi(m)$, where $m$ is odd?

  3. Do we have an explicit formula for $\varphi(n)$?

Any help would be appreciated.

Dongyu Wu
  • 857
  • @Dongyu_Wu I'm not sure if I fully understand the question, but can the prisoner just flip one of the cards after each rotation? Eventually just by chance the cards will all be face up with a finite number of rotations. This would be equivalent to random walks on a $Q_n$ graph and the prisoner would guarantee freedom when all nodes are visited. If this strategy works I'll post this as an answer. – quantus14 May 02 '20 at 02:02
  • @quantus14 I believe that by using the theory of random walks one may show the prisoner will guarantee a success eventually with probability 1, but a winning strategy requires more than that. Let's say a God is controlling the table and always rotate the table at his discretion to obstruct the prisoner's success and prolong the game as long as possible. A winning strategy guarantees a success in finitely many times even in this arrangement. – Dongyu Wu May 02 '20 at 05:13
  • 1
    Nice puzzle! Do you mind changing the wording to eliminate the word "randomly"? You're actually playing against a perfect adversary, not a randomizer. (It might not make any difference because you're interested in winning strategies with known bounded time to success, but I still find the word "randomly" to be confusing.) – antkam May 02 '20 at 06:37
  • @antkam Sure, I would be glad to remove any possible confusion. I made a small modification of the puzzle and now it should be good. Thanks for the suggestion. – Dongyu Wu May 02 '20 at 14:41

2 Answers2

1

I can propose the following mathematical model of the gameplay as follows. For given $n$, we can naturally encode each choice of orientations of card faces by an equivalence class $c$ of sequences of zeroes and ones of length $n$. Namely, sequences $s$ and $s’$ are equivalent provided $s’$ is a cyclic shift of $s$. For instance, sequences $11101100$ and $10110011$ are equivalent. Now let $C$ be the set of all such equivalence classes. For instance, for $n=3$ the set $C$ consists of the classes $\{000\}$, $\{100, 010, 001\}$, $\{110, 101, 011\}$, and $\{111\}$. The only key knowledge about a puzzle state which the prisoner has is a family $C’\subset C$ of classes of possible choices of orientations of card faces. So at a phase between rotations the prisoner tries either to win or to change the family $C’$.

The following his strategy shows that $\varphi(n)\le n+1$ for each natural $n$. Let $c_1,\dots, c_k$ be the classes of the family $C$. At $k$-th phase at the first $n$ tries the prisoner checks orientations of card faces encoded by sequences from the class $c_k$ by turning card faces according to each of such sequences (this is possible, since $|c_k|\le n$) and at the last try he turns all card faces to the orientation which was at the beginning of the phase. Doing so, he either win (if the choice of orientations of card faces belonged to $c_k$) or assure that $c_k$ does not belong to $C’$. Clearly, the prisoner will win at at most $k$-th phase.

Alex Ravsky
  • 106,166
  • 1
    Indeed. It would be natural to consider the orbits of $S_n/C_n$. What I am actually wondering is if we could do better than this as it is easy to see for n=3 we could. Thank you for the answer. – Dongyu Wu May 10 '20 at 15:53
1

I wrote a program to solve this by modeling it as a graph problem in the following way:

The nodes are the possible states the cards may be in (not counting the one where all cards are face-up) + how many rounds has passed since the table was rotated. The edges are subsets of the cards we may flip. We start at the node where all states are possible and traverse the graph until we reach one where the only possible state is the one where all cards are face-up. The source code can be found here, there is one implementation in Python and one in Rust.

As this is a pretty brute-force approach, it doesn't scale very well. I've tried some further optimizations but I haven't been able to calculate $\varphi(6)$ yet. Still, what I have found is that:

$\varphi(3)=3$, $\varphi(5)=6$, and $\varphi(6)>4$.

This shows that the answers to your first and second questions are both no.

Edit:

I've found that $\varphi(6)=5$. Calculating this took 7 hours of compute, even though I added several optimizations, small and big (some specialized for when $n < 7$).

One thing to note is that I only do a simple depth-first search of the graph. Finding the node where all cards must be face-up could be much faster if you used some kind of heuristic (such as decreasing the number of possible states). The problem is that this wouldn't be very useful to find lower bounds as that forces you to explore the whole graph anyway.

Pazzaz
  • 664
  • Nice. This answer is informative. I will accept it but I still really want to know what exactly $\varphi(6)$ is. – Dongyu Wu May 15 '20 at 16:38