How should I have solved this interesting problem?

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.

Thank you for your help
Amy
x
Last edited on
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.

Interesting! Thank you. Do you think breadth first search would work?
I had a look at how to solve the lights out problem. http://www.logicgamesonline.com/lightsout/tutorial.html gives an interesting insight into the 'chasing the lights technique'.

How could I adapt the technique to take into account the 'dim' lights?
Help would be grateful
Amy
x
You should be able to use the technique to reduce all rows except the bottom to empty, just think how you would turn a dim light off using only the button below it.

Once you can do this, then consider whatever you press on the top row will directly correspond to what you have left on the bottom.

How many different ways can you press the buttons on the top row? Could you brute force try every combination?
Topic archived. No new replies allowed.