# 16 Buttons, Turn them all Red or Green?

There's 16 buttons arranged in a 4 by 4 square. They are coloured either red, or green. They appear like this (red being 1, green being 0)

1010
0101
1100
0011

Each press will switch all the buttons diagonal of it, and the button on the exact opposite of it (for example the one exact opposite of the one in the top left corner is the bottom right.) Not to mention itself.

An example of pressing would be, if you press the first 1 on the second row, the following would happen:

They changes happen in this order:

• The button you press changes
• The buttons diagonal of it by 1 button changes
• The opposite button changes

You're mission is to switch it all to either 1 or 0, in the minimum moves required. What is this minimum amount and what moves are in the required sequence?

• what about the 4 center buttons they would change their diagonal and their opposite in the same turn does it switch or cancel out leaving it what it was? Commented Oct 30, 2014 at 13:29
• My gut feeling is that it can't be done (source: I love flip puzzles), but I don't have time to prove/disprove it right now
– Joe
Commented Oct 30, 2014 at 13:30
• @Bozman since they happen in a given order, I'd imagine a button can change then change back during the same keypress
– Joe
Commented Oct 30, 2014 at 13:54
• @Bozman I knew people would have asked that, it's why I added the order like Joe mentioned. Commented Oct 30, 2014 at 13:59
• @Joe I guess someone'll have to figure that out. Commented Oct 30, 2014 at 14:00

To turn them all to red press buttons:

2, 3, 7, 9, 10, 12, 14, 15 (8 buttons)

To turn them all green press the buttons:

2, 3, 6, 9, 11, 12, 14, 15 (8 buttons)

Buttons are numbered 1 to 4 along the top row, then next row 5 to 8, etc. ITs probably a logical way of doing it but felt it should be explicitly stated.

To demonstrate the first solution:

Pressing button 2

1110
1111
1100
0001


Pressing button 3

1100
1010
1100
0101


Pressing button 7

1001
1000
1101
0101


Pressing button 9

1001
1101
0101
0001


Pressing button 10

1001
0101
0001
1011


Pressing button 12

1001
1111
0000
1001


Pressing button 14

1011
1111
1010
1101


Pressing button 15

1111
1111
1111
1111


The second solution is identical to the first except that you are flipping the selection of the middle four buttons (6,7,10,11) because they will flip the whole board. If you add these to flip then you will have pressed some buttons twice and that is the same as pressing them not at all. Thus you add 6 and 11 and remove 7 and 10.

Further notes:

If you consider the board to be a chess board (ie white and black squares) then a button on a white square will only ever change buttons on the white squares and likewise black buttons only change black buttons. This means that it can be split into two separate problems if you so choose.

• Nice! I'll have to get the proof of the other answer before I can accept this, because it says 8, which is shorter. Commented Oct 30, 2014 at 14:36
• Mine is an 8 move solution (well with my further edit actually two eight move solutions). Commented Oct 30, 2014 at 14:36
• Oh I just noticed that. I miscounted. Commented Oct 30, 2014 at 14:39
• I've just done some tidy up to save people from needing to count and to make things a bit clearer (such as the two solutions I found). Commented Oct 30, 2014 at 14:42
• Bonus Question: Will this type of puzzle ALWAYS be possible to complete? Commented Oct 30, 2014 at 14:48

This is a puzzle of two halves, one on each set of diagonals

 1 1
1 1
1 0
0 1

0 0
0 0
1 0
0 1


For the first half (- means select and now off, x means select and now on):

1 1       0 0       0 0       0 x       0 0      0 0
1 1       - 1       0 0       1 1       1 1      0 0
1 0       0 0       0 x       0 1       1 0      - 0
0 1       0 1       1 0       0 0       x 0      0 0


And for the second:

 0 0       0 0       x 0      0 0
0 0       1 1       0 0      0 0
1 0       1 x       1 1      0 0
0 1       0 0       0 1      0 -


For a total of 8 moves.

For the total board:

1010      0000      0000      00x0      0000      0000      0000      0x00      0000
0101      0x01      0000      0101      0101      0000      1010      0000      0000
1100      0100      01x0      0110      1100      -100      010x      0101      0000
0011      0011      0110      0010      0x10      0010      0000      0010      00-0


And just for kicks, here's the all-on solution:

1010      10-0      1000      1010      1x10      1011      1011      1011      1111
0101      0000      0101      0101      1111      11-1      0101      1111      1111
1100      1100      -100      1110      1110      1111      1-11      101-      1111
0011      0111      0011      0x11      0101      0101      1111      1101      11x1


And why not, here's steps that ensure you can finish any puzzle. Since each button only affects other buttons on it's diagonal (ala black squares on a chess board), the diagrams will be for 1/2 boards. And every starting position can be thought of as a combination of these three configurations:

0 1      0 1      1 0      0 0      0 0
0 0      1 1      - 1      0 1      0 0
0 0      x 0      0 0      0 1      0 -
0 0      1 0      1 0      1 x      0 0

1 0      1 1      1 0      0 0      0 0
0 0      0 x      0 1      0 1      0 0
0 0      1 1      0 0      0 1      0 -
0 0      0 0      x 0      1 x      0 0

0 0      0 x      0 1      1 0    Which is the position above
1 0      0 1      1 0      - 0
0 0      0 0      x 0      0 0
0 0      1 0      0 0      0 0

• This is shorter than the other answer, however I do not understand it. Please shore each individual move and the board that appears. Commented Oct 30, 2014 at 14:31
• Please format this answer like Chris' Commented Oct 30, 2014 at 14:38
• @warspyking: It might be harder to read than mine but this is showing individual moves. It is just that he is only showing values for half the board at a time (since it can be split up). The first half is hitting buttons 6,11,3,14,9 and the second is hitting 2, 12 and 15. I'm happy to verify this is the same answer as (one of) mine. Commented Oct 30, 2014 at 14:38
• @warspyking, why not just give it a try jsfiddle.net/q93pknd8 ;P Commented Oct 30, 2014 at 14:42
• That's fine. I just thought since we can split the puzzle, it would be easier to think of it in halves. Commented Oct 30, 2014 at 14:56