# Create a 5x5 Modulo Grid

Create a 5x5 grid.

A1 A2 a3 a4 a5

B1 B2 b3 b4 b5

c1 c2 c3 c4 c5

d1 d2 d3 d4 d5

e1 e2 e3 e4 e5


Seed A1, A2, B1 and B2 with numbers that allow the grid to be completed with following criteria:

• Except in the first to columns, every cell must be the modulo of the 2 cells left to it.
• Except in the first two rows, every cell must be the modulo of the 2 cells above it.

• No more than one cell is allowed to be 0.

• Numbers may repeat in the grid

I.e.

• c3 = a3%b3 = c1%c2
• e5 = e3%e4 = c5%d5
• ...

The solution with the lowest sum of initial numbers wins.

Bonus Question:

Can you choose 4 different numbers to start with? (That adds a hell of complexity :)

• b5 = b3 % b4, but how does it work vertically for b5? – Marius Oct 20 '16 at 9:43
• Thanks for the feedback. Updated description for better clarity. – Zsolt Szilagy Oct 20 '16 at 9:47
• Is there an implicit requirement that the numbers are non-negative? I guess it depends on how you define modulo with negative numbers, but bc at least tells me -5 % -8 is -5 (and not say 3) – Foon Oct 20 '16 at 21:08

Based on Jamal Senjaya answer: Sum is 34

 [ 5  8  5  3  2]
[ 8 13  8  5  3]
[ 5  8  5  3  2]
[ 3  5  3  2  1]
[ 2  3  2  1  0]

You can create other solutions by using other Fibonacci numbers as start. For example:

 [ 8 13  8  5  3]
[13 21 13  8  5]
[ 8 13  8  5  3]
[ 5  8  5  3  2]
[ 3  5  3  2  1]

• I honestly can't think of a better solution, so this might be the winner. Could you apply that approach to the bonus question, so we have everything in one place? – Zsolt Szilagy Oct 20 '16 at 11:53

For the standard question we can

just start with 0 in the bottom right, with 1 above and to it's left and add - this forms diagonals of Fibonacci numbers:

   34   21   13    8    5

21   13    8    5    3

13    8    5    3    2

8    5    3    2    1

5    3    2    1    0

This should be minimal sum, for $192$

For the bonus we can

change one of the bottom or right 2s to a 3 and sum again, here is changing the bottom one:

   50   29   21    8    5

31   18   13    5    3

19   11    8    3    2

12    7    5    2    1

7    4    3    1    0

As pointed out by @wl another way to construct the bonus (and almost certainly with minimal score) is to

shift the left-most column, or top most row, of the first solution up the Fibonacci scale by one place:

   55   21   13    8    5

34   13    8    5    3

21    8    5    3    2

13    5    3    2    1

8    3    2    1    0

For $242$ instead of the previous $268$

• For the bonus question just replace each number in the first column or row with the next highest Fibonacci number: 55, 34, 21, 13, 8 – w l Oct 20 '16 at 10:03
• @wl Ah yes that will make minimum bonus I think - I just did it another way (but for more cost) – Jonathan Allan Oct 20 '16 at 10:08

Sum is 55

 [8  13  8  5  3]
[13 21  13 8  5]
[8  13  8  5  3]
[5   8  5  3  2]
[3   5  3  2  1]

One solution but it may not be optimal:

 34 21 13  8  5
21 13  8  5  3
13  8  5  3  2
8  5  3  2  1
5  3  2  1  0  

.

Started with 0 and 1 in the bottom right corner and moved my way up. (notice the symmetry).