# Coloring the Chess Board

We have 8x8 Chess board like grid (8x8 2D matrix) and we are trying to color every single square/cell. But the rules are interesting;

• You may start from any square you want and color that square for the beginning.
• You can continue coloring another square in the grid which is $$4$$ or $$5$$ squares away from the square you started and colored from and so on (vertically or horizontally).
• You cannot color the same square you colored before or come back again on that.

What is the maximum amount of squares you can color with the given rule above?

• Am I right in thinking this is an 8 x 8 x 8 cube? I think that may need to be included in the question if so – AHKieran Dec 4 '18 at 13:49
• @AHKieran this is 8x8 Grid, not a cube. what makes you think like that? Oo – Oray Dec 4 '18 at 13:50
• sorry i meant an 8 x 8 x A cuboid, so the grids are extruded upwards A times? – AHKieran Dec 4 '18 at 13:51
• perhaps some sort of diagram example would be useful? – AHKieran Dec 4 '18 at 13:52
• Oray, you are misusing the word "Grid". Grid refers to the whole array of squares, whereas you seem to be using it to refer to a single square. – Jaap Scherphuis Dec 4 '18 at 13:52

## 4 Answers

The one-dimensional problem can be solved as follows:

|2|4|6|8|1|3|5|7|

Since we start and end at a central square, we can use the same strategy on the Y-axis and colour one row at a time. In the end we'll have coloured all 64 squares.

Using chessboard coordinates:

e5 a5 f5 b5 g5 c5 h5 d5
d1 h1 c1 g1 b1 f1 a1 e1
e6 a6 f6 b6 g6 c6 h6 d6
d2 h2 c2 g2 b2 f2 a2 e2
e7 a7 f7 b7 g7 c7 h7 d7
d3 h3 c3 g3 b3 f3 a3 e3
e8 a8 f8 b8 g8 c8 h8 d8
d4 h4 c4 g4 b4 f4 a4 e4

• Er... you can't cross squares that have already been colored. – Excited Raichu Dec 4 '18 at 14:10
• @ExcitedRaichu Yes you can. Oray at first misread your question in the comments, but then corrected himself a minute or so later. – Jaap Scherphuis Dec 4 '18 at 14:11
• @JaapScherphuis ah, I definitely didn't see the edit, I was busy typing my answer (with no crossing) – Excited Raichu Dec 4 '18 at 14:12
• @jafe This is a lovely solution. I was trying to go around in 4x4 squares, filling two rows simultaneously, but was always left with two or more unreachable squares. – Jaap Scherphuis Dec 4 '18 at 14:16
• So the answer is "64". You answer implies that you're gunning for 64, but, I think you should actually say 64. – Stephen Quan Dec 5 '18 at 4:16

I think I can get:

63 out of 64 squares coloured

Method:

You start in one of the centre lines, 4 in from the left, and move left 4, right 5, left 4, right 5 etc until the whole line is filled.
Then you repeat this vertically, starting from the square you last filled in the row, until the whole column is filled.
Repeating this ends up with a cross in middle 2 rows/columns. After this, repeating this line filling method creates a window like shape with the outside squares also filled.
At this point I managed to go around and fill the inner squares, but I could not move from the last one I filled to the the one remaining square so ended on 63.

I can do

17, without even crossing a colored square

by

using chessboard coordinates, e4 - e8 - a8 - a3 - f3 - f7 - b7 - b2 - g2 - g6 - c6 - c1 - h1 - h5 - d5 - d1

All 64;

order is as follows:

[02,04,06,08,10,12,14,16]

[32,30,28,26,24,22,20,18]

[34,36,38,40,42,44,46,48]

[64,62,60,58,56,54,52,50]

[01,03,05,07,09,11,13,15]

[31,29,27,25,23,21,19,17]

[33,35,37,39,41,43,45,47]

[63,61,59,57,55,53,51,49]

sorry about the formatting