# 5x5 Table which number in every cell = last digit of (sum of its neighbor)

 [1 . 6 . 7]
[. . . 0 .]
[3 . . . .]
[. . . . 1]
[. 7 . 8 .]


fill the dots on the table above with 1 digit numbers, so:

Number in every cell = last digit of (sum of its neighbors (including diagonals))
or
Number in every cell = The remainder of the sum of its neighbors divided by 10

Here are the examples

 [0,1,6,4,8]   [1,2,1,3,2]   [1,0,9,0,1]
[4,5,6,0,4]   [4,5,1,0,9]   [6,5,9,5,6]
[4,4,0,6,6]   [3,3,0,7,7]   [5,5,0,5,5]
[1,0,4,5,1]   [1,0,9,5,6]   [9,0,1,0,9]
[2,1,4,4,0]   [8,7,9,8,9]   [4,5,1,5,4]


use the fact here to solve this puzzle.

Note : I think this puzzle can be solved without computer, but I am not sure.

• Each cell is both the last digit of the sum and the remainder of the sum of its neighbor (neighbor or neighbors)? – Alenanno Oct 11 '16 at 8:42
• @Alenanno : Both have same meaning. Just take last digit of the sum. – Jamal Senjaya Oct 11 '16 at 8:46
• @JamalSenjaya: It's even more trivial than the previous one. I wonder why you're putting them up here. – user27395 Oct 11 '16 at 8:48
• @ArbitraryKangaroo The previous one is to prove, this one is to fill the blanks. You can use the facts from the previous one to solve this puzzle without computer. – Jamal Senjaya Oct 11 '16 at 8:58
• @JamalSenjaya: Using computer to solve this is like using FLT to prove $2^{\frac{1}{n}}$ is irrational. This can be solved instantly by hand, if you see my previous matrix, and how the parity change. – user27395 Oct 11 '16 at 8:59

My answer to your previous question about these grids showed that there are only two "independent" grids of this type mod 5, and all others are linear combinations of them. By looking at the middle numbers on the top and left sides we can see what combination we need. We could do the same mechanical thing for mod 2, but actually it's just as easy to work it out by hand. I think there are actually two solutions mod 2, leading to two solutions mod 10 to your problem:

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

and

1 7 6 8 7
9 5 6 0 9
3 3 0 7 7
1 5 4 0 1
3 7 4 8 9

This is my code in Haskell to generate all table with this properties

import Data.List

{-
a b c d e
f g h i j
k l m n o
p q r s t
u v w x y
-}

ldig xx = mod (sum xx) 10

jawab =  [[[a,b,c,d,e],[f,g,h,i,j],[k,l,m,n,o],[p,q,r,s,t],[u,v,w,x,y]]|
let hm = [0..9],
a<-hm,b<-hm,f<-hm,g<-hm,
a == ldig [b,f,g],
c<-hm,h<-hm,
b == ldig[a,f,g,h,c],
d<-hm, i <-hm,
c == ldig [b,g,h,i,d],
e<-hm, j<-hm,
d == ldig [c,h,i,e,j],
e == ldig [d,i,j],
k<-hm,l<-hm,
f == ldig [a,b,g,k,l],
m<-hm,
g == ldig [a,b,c,f,h,k,l,m],
n<-hm,
h == ldig [b,c,d,g,i,l,m,n],
o<-hm,
i == ldig [c,d,e,h,j,m,n,o],
j == ldig [d,e,i,n,o],
p<-hm,q<-hm,
k == ldig [f,g,l,p,q],
r<-hm,
l == ldig [f,g,h,k,m,p,q,r],
s<-hm,
m == ldig [g,h,i,l,n,q,r,s],
t<-hm,
n == ldig [h,i,j,m,o,r,s,t],
o == ldig [i,j,n,s,t],
u<-hm,v<-hm,
p == ldig [k,l,q,u,v],
w<-hm,
q == ldig [k,l,m,p,r,u,v,w],
x<-hm,
r == ldig [l,m,n,q,s,v,w,x],
y<-hm,
s == ldig [m,n,o,r,t,w,x,y],
t == ldig [n,o,s,x,y],
u == ldig [p,q,v],
v == ldig [p,q,r,u,w],
w == ldig [q,r,s,v,x],
x == ldig [r,s,t,w,y],
y == ldig [s,t,x]]


After get all result and find the fact that middle cell is always 0, and many other facts, we still can optimize the code above.