Four glasses puzzle

A blindfolded person is seated next to the Lazy Susan and is required to re-arrange the glasses so that they are all up or all down, either arrangement being acceptable, which will be signalled by the ringing of a bell.

The puzzle is to devise an algorithm which allows the blindfolded person to ensure that all glasses have the same orientation (either up or down) in a finite number of turns.

[3] An algorithm that guarantees the bell will ring in at most five turns is as follows:[2] The puzzle can be generalised to n glasses instead of four.

For five or more glasses there is no algorithm that guarantees the bell will ring in a finite number of turns.

An algorithm can be found to ring the bell in a finite number of turns as long as k ≥ (1 − 1/p)n where p is the greatest prime factor of n.[2]

A four glasses puzzle solution.

? denote glasses in either state: face u p or dow n . Ticks denote solved arrangements. In each step, only distinct arrangements are shown.

In step 3, if a glass is face down, it is turned face up; otherwise, either glass is turned face down.