You push number 3 and itself and the one next to it (2) turns on. If you press number 2 itself and both those next to it switches from their current state. So it’ll just be an on/off system.
I was thinking I’d be using a branch system to check if those next to the button is switched on and then make it the opposite.
If you just have this count of buttons, I would use cases for every button with a following branch which is handling the following functions ( switching on/off the buttons). This is much faster to create your own scaleable algorithm. But ony if you dont have to scale up your button table.