# 5x5 grid with a special colouring

Can you paint the cells of a 5x5 grid in 5 colours such that for each cell its colour and the colour of its orthogonal (horizontal and vertical) neighbours are all different?

abcde
cdeab
eabcd
bcdea
deabc

Now in Technicolor, so you can see it for yourself:

• And the same applies for the diagonal neighbours independently. And the edges "wrap". Commented Oct 27, 2023 at 14:03
• This is correct, well done! Love the technicolor :) Commented Oct 27, 2023 at 14:04
• I wonder why, mathematically, rot13(ebgngvat nopqr ol gjb naq guerr) yield valid solutions. Does it have anything to do with rot13(zbqhyne nevguzrgvp)? Commented Oct 27, 2023 at 14:15
• @Someone I think it's more that they're effectively mirrors of the same operation. if you were to flip the board over horizontally and relabel the colors I'm pretty sure one would come out as the other Commented Oct 27, 2023 at 14:22
• Yeah, they're interchangeable, and reflections of each other. But I'm having trouble finding a non-trivial non-bonus solution. Commented Oct 27, 2023 at 14:23

# Trivial Solution (similar to others')

And of course, it also grabs the bonus:

Let a, b, c, d, e be the colors. Then:
| a | b | c | d | e |
| d | e | a | b | c |
| b | c | d | e | a |
| e | a | b | c | d |
| c | d | e | a | b |

How I got there:

If you take abcde, place it in the first row, and then right-shift it by three for each row, you get this system.

• Oh, I misread the question. Might as well look for another solution… Commented Oct 27, 2023 at 14:10
• I made it more readable but unfortunately tables don't work in spoilers. Commented Oct 27, 2023 at 14:10
• Alright, actual solution now. Commented Oct 27, 2023 at 14:15
• Is this the same solution as the accepted one? Are there any other solutions (perhaps without the bonus)? Commented Oct 27, 2023 at 14:16
• They're not the same, but they have a similar idea to each other and my first solution—rot13(gnxr n ebj bs gur svir pbybef naq fuvsg gurz nebhaq). Commented Oct 27, 2023 at 14:17

Initially I assumed this was a Latin square question (but that was not actually mentioned). I got the following symmetrical solution:

• This doesn't work, sorry. It wasn't a latin square question, but it turned into one :) Commented Oct 28, 2023 at 9:45
• That was my original solution, but I misread the question. Commented Oct 28, 2023 at 16:30
• @DmitryKamenetsky Well this is disappointing. I have received two downvotes for my answer even though none of my colored squares have a horizontal or vertical neighbour of the same color. Plus I did use 5 colors as requested. I feel I have correctly answered the question that was asked. Commented Oct 28, 2023 at 19:44
• @WeatherVane Okay! I see the difference now. I had interpreted the question to only mean that each cell would be colored different from its orthogonal neighbours but now I see that also the 4 orthogonal neighbours must all be distinctly colored. Commented Oct 28, 2023 at 23:29
• @DmitryKamenetsky Thanks! Sometimes it’s hard to word things simply and clearly. I thought about how I would word your question and I couldn’t think of a simple way to express it. Commented Oct 29, 2023 at 6:09