Hello, recently, I was given this problem to solve. How should I have attempted it?
Below is the problem and my thoughts to solving the problem:
A security system consists of a 5×5 keypad of buttons. Each button has a light
which can be either off, dim or bright. When a button is pressed its light moves to the next state (off→dim, dim→bright and bright→off) as do the lights on any buttons touching it horizontally and vertically. The system is unlocked when all the lights are off.
So, what I think I should do to have solved it:
Set a 5*5 matrix and everytime a letter is selected, it is converted into the appropriate matrix.
Then have a function which sets the button/light to the correct setting: 0 = off; 1=dim; 2-bright;
The final stage is what I am confused about. How would I find the combinations that are possible? How would I implement it? Should I use breadth first search?
I would love to know your opinions and ideas.
This is very similar to a game called lights out, you should probably read up on the solution algorithms for that, I've not thought about it too hard, but it should be pretty simple to adapt them to this game.