## On the Subject of Simon Stores

Calculators at the ready...

This module consists of nine buttons, six of which have the colours: (R)ed, (G)reen, (B)lue, (C)yan, (M)agenta, and (Y)ellow.

These buttons will flash in an increasing sequence, starting with the centre button, in which each flashing colour corresponds to an operator in the tables below.

Apply each operation successively until the end of the sequence and use the result to determine the sequence of coloured buttons to press for each stage.

If at any point an operator yields-

- a value greater than 364, then subtract 365 from the value until it is less than 365.
- a value less than -364, then add 365 to the value until it is greater than -365.

### Section 1: Determining Initial Values

To determine the number to be entered into the sequence of operators, interpret the following pairs of digits in the serial number as *two-digit base-36 numbers* and take them modulo 365:

- For stage 1, use the 3rd and 4th digits.
- For stage 2, use the 5th and 6th digits.
- For stage 3, use the 1st and 2nd digits.

### Section 2: Operation Tables

In each stage, each color is associated with an operation, expressed here as a function:

- n is the current step of the sequence.
- D is the sum of the individual base-36 digits of the serial number.

Stage 1 | Stage 2 | Stage 3 | |
---|---|---|---|

R | R(x) = x + D | R(x) = x + a_{n-1} + n^{2} |
R(x) = x + b_{n-1} - a_{n-1} |

G | G(x) = x - D | G(x) = 2x - a_{n-1} |
G(x) = x - 2b_{n-1} |

B | B(x) = 2x - D | B(x) = 2x - a_{0} - 4n^{2} |
B(x) = x + b_{0} - a_{3} |

C | C(x) = D - x - 8n | C(x) = x + a_{1} |
C(x) = x - b_{n-1} + a_{n-1} |

M | M(x) = 3n^{3} - 2x |
M(x) = x + a_{2} - D |
M(x) = x - 2a_{n-1} |

Y | Y(x) = x + D - 6n | Y(x) = x + a_{3} - a_{n-1} |
Y(x) = x + b_{4} - a_{0} |