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?