A parker square here refers to a 9x9 grid containing integers. After squaring all the integers, the total of each row, each column and each diagonal is the same. (All cells in the grid cannot contain the same number).
https://www.youtube.com/watch?v=aOT_bG-vWyg A 5 minute video on the topic
I'm trying to approach this problem but I need some help optimizing my current solution, which is pretty amateur.
First, I named all the cells in the 9x9 grid as variables a-i Then, I calculate the sum of the squares of each column , row and diagonal separately and check if all of them are equal once.
My code is here below in Python, any suggestions?
for a in range(1,10):
for b in range(1,10):
for c in range(1,10):
for d in range(1,10):
for e in range(1,10):
for f in range(1,10):
for g in range(1,10):
for h in range(1,10):
for i in range(1,10):
j=a**2+b**2+c**2
k=d**2+e**2+f**2
l=g**2+h**2+i**2
m=a**2+d**2+g**2
n=b**2+e**2+h**2
o=c**2+f**2+i**2
p=a**2+e**2+i**2
q=c**2+e**2+g**2
if j==k and k==l and l==m and m==n and n==o and o==p and p==q:
print(a)
print(b)
print(c)
print(d)
print(e)
print(f)
print(g)
print(h)
print(i)
break