In the center room of an ancient temple, there are $n$ identical chests. Of these, $k$ contain treasure, but the other $n-k$ contain mind erasers. You do not know $k$. If you open a chest with a mind eraser, you forget everything you’ve learned about the contents of the chests so far. The second time you open the same mind eraser, you’re instantly driven insane.

The room is a perfect circle with no distinguishing features, and the chests are arranged symmetrically around its circumference. You can’t mark chests, change their orientations, or otherwise break the symmetry. You can’t take treasure out of chests, and you must close each chest before opening the next. You can, however, swap pairs of chests as long as the symmetry of the room’s restored before you open a chest.

If you ever open all $k$ chests with treasure in a row, the room will fill with magical light, all treasure-containing chests will be flung open, and you will be permitted to take the treasure and return to your homeland.

When your mind’s erased, you wake up in front of the chest, closed like the others, with no memory you’ve opened it. That's also the state you start in. How can you identify all $k$ treasures and defeat the circular chamber?

  • $\begingroup$ If you operate according to a strategy, will it be still remembered by you? For example - you never open the chest in front of you. $\endgroup$
    – Moti
    Commented Oct 16, 2023 at 5:08
  • 2
    $\begingroup$ Is k known to you before you start opening chests? $\endgroup$ Commented Oct 16, 2023 at 6:25
  • $\begingroup$ The question doesn't say what happens when you go insane. Should the final question be "How can you identify all k treasures without going insane?" $\endgroup$
    – HappyDog
    Commented Oct 16, 2023 at 12:56
  • $\begingroup$ What does it mean to identify all k treasures? That at some point you say you stop opening chests and point correctly to all k chests containing treasures? $\endgroup$
    – xnor
    Commented Oct 16, 2023 at 18:57
  • 1
    $\begingroup$ edited the Q for clarity re: the win condition. agree it was a bit confusing! $\endgroup$ Commented Oct 16, 2023 at 23:58

1 Answer 1


I claim the following strategy works:

Suppose I remember finding T treasures so far. Shift one chest to the left. Swap that chest T places to the right, then open it. If I find treasure, shift T places left.

How it works:

The idea is to move leftwards around the room, pulling a line of treasure behind me. Whenever I open a new chest, I swap it with the last treasure in line and open it - if it's also treasure, I jump back to the front of the line and progress onward, and if it's a mind eraser, the mind eraser is now behind my treasure hoard. As I resume moving left, I will gradually re-find all the treasure collected so far. Eventually, I'll be in the state I was before getting my mind erased, but with the mind eraser tossed behind the treasure.
The room always remains divided into three regions: Never-opened chests, treasure, and opened mind erasers. I only swap rightward with known treasure, so I can only reach an opened mind eraser by moving left. Since I only progress into new territory one chest at a time, I'll only reach an opened mind eraser after making a full lap around the room, by which time I'll have already found all the treasure.

  • $\begingroup$ I can't visualise how this works at the start. Initially T=0, so you shift left, swap that chest with the one 0 places right (itself), and then open it. If it's a mind eraser, you get your mind erased and start again. On your second go, you haven't found any treasure so T=0 and you repeat, opening the same mind eraser. $\endgroup$
    – fljx
    Commented Oct 16, 2023 at 10:10
  • $\begingroup$ So.... you mean you know you've found all the treasure because that last chest drove you insane? Doesn't sound like a reasonable solution, to me. $\endgroup$
    – HappyDog
    Commented Oct 16, 2023 at 12:57
  • 1
    $\begingroup$ @HappyDog This solution requires the assumption that you know k - you stop once you have k treasures, so you'll never hit a mind-eraser you've hit before, because you get to it after opening k consecutive treasure chests. There can't be a solution for the version where you don't know k, so it seems a reasonable assumption. $\endgroup$ Commented Oct 16, 2023 at 13:51
  • $\begingroup$ @BlueHairedMeerkat The question has been edited so that opening the $k$ treasures in a row now completes the problem, even if you didn't know $k$. $\endgroup$
    – Silverfish
    Commented Oct 17, 2023 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.