The rules of Merlin's Machine are as follows:
A 3 x 3 grid of touch buttons that light up are started in a random sequence.
When a button is pressed then itself and the neighbouring lights are switch on/off, accordingly.
The diagram shows the buttons labelled, for example, row 1 column 1 (r1 c1) as 11.
To solve I've used the following definitions:
Set X = {1,2,3}, Set S = {0,1}.
The cross product Ω = X x X, ie Ω = {(1,1),(1,2),(1,3),....,(3,3)}
Mapping α : n ↔ t⋅3+n-3, (t,n) ∈ Ω
Set C = {x(α) → c ∈ S}, eg C = {1,0,1,0,1,1,0,0,1}, the machines current state.
Binary operations (s,m),(t,n) ∈ Ω, Ω ~ Ω = (s+t-2,m+n-2),
c
*(ω) if c(ω) = 0 then c(ω) = 1 else c(ω) = 0
The algorithm goes a bit like this:
[loop till game complete]
Pressed ω ∈ Ω,
∀ Ω if ω ~ Ω
then c
*(ω)
∀ c ∈ C if c = 0 then [game complete]
[repeat]
To get random C then generate random r (0<r<512) such that
∀ c ∈ C, c → bitwise r.
Any Q's press the big envelope below and give me a shout.