I learned this puzzle from a friend in work. He posed it one morning before everyone had had their coffee and ended up costing a small handful of engineers a whole morning of productivity as we each solved it. I’ve been meaning to post about it here for a while. Here’s the formulation as best I can describe it:

You have in front of you one of those tables you get in Asian restaurants with the rotating centre—what one of our product managers described as a lazy susan, though I’ve never heard that phrase from anyone else. Picture the restaurant from the beginning of Indiana Jones and the Temple of Doom if you really want to set the scene.

On the table are four glasses, each of which is either standing upright or turned upside down. They’re evenly spaced around the table, in a square. You sit at the table blindfolded. Your aim is to turn the glasses such that they are either all upright or all upside down, subject to the following rules.

You are allowed to inspect two of the glasses, by touch, at a time. You can choose to inspect either the two immediately in front of you (i.e., a side of the square) or one in front of you and the one opposite it (i.e., a diagonal). After inspecting the glasses you are allowed to turn either glass, both glasses or neither glass.

Once you’ve inspected and possibly turned two glasses the table is rotated a random amount so that you don’t know which glass is which. You then have the same choices about inspecting and turning glasses as before. Then the tables is rotated again. It goes on like this for as long as you need to solve the puzzle.

If at any point you get all the glasses upright or all upside down you’ll be told that you’ve won. You don’t need to be able to know that you’ve solved it. You aren’t told at the start what configuration the glasses are in, though you can assume they don’t start in a solved state.

Find a way to reliably solve this puzzle that will be guaranteed to work in a finite number of moves regardless of the initial conditions or how lucky you are with rotations of the table. In particular this means that you can’t just keep spinning the table and turning upright every glass you touch in the hope that you’ll get them all eventually.