Consider n points on a unit circle with numbers k = 0, 1, ..., n-1. Initially point k makes an angle of 360 · k / n degrees to the x-axis, measured in counter-clockwise direction. We are going to perform two different kind of operations on that set of points:
- rotation by 360 / n degrees in clockwise direction
- reflection with respect to the x-axis
The following picture shows an example of these operations:
Given a sequence of operations, we are interested in the shortest sequence of operations which gives the same result, i.e., the position of every single point is the same after performing either of those sequences of operations.
The sequence is given as a string consisting of the characters \'r\' and \'m\' which represent clockwise rotation and reflection respectively ("to the right" and "mirror"). Multiple consecutive occurrences of the same character are collected into the representation
4 r2 100 m1 r100 m1 54 r218 m3 r1 0
r2 r1 m1