For a long time there was an attempt to create an elusive 3x3 square of integers meeting two criteria:
a. all integers should be distinct squares.
b.They should add to the same value along all rows, columns and diagonals.
Apparently, no one succeeded to create such a magic square. The closest to the above goal was a set of 3 distinct squares and 3 couples of identical square numbers like a, b, c, d, d, e, e, f & f.
Each of the 3 rows, 3 columns and one diagonal sum up to the same value - the other diagonal does not.
Find such solution, keeping in mind that all the numbers are odd and the sum is a 4-digit number.
The square is some version of following
(including rotation, reflection or exchanged rows):
29^2 1^2 47^2
41^2 37^2 1^2
23^2 41^2 29^2
with the sum being 3015
Here is the output and the code:
lord@rabbit 13100 % qqq
841 1 2209
1681 1369 1
529 1681 841
841 529 1681
2209 841 1
1 1681 1369
841 529 2209
2209 1369 1
529 1681 1369
841 1681 529
1 1369 1681
2209 1 841
841 2209 1
529 841 1681
1681 1 1369
841 2209 529
529 1369 1681
2209 1 1369
1369 1 1681
1681 841 529
1 2209 841
1369 1 2209
1681 1369 529
529 2209 841
1369 529 1681
2209 841 529
1 2209 1369
1369 1681 1
1 841 2209
1681 529 841
1369 1681 529
1 1369 2209
2209 529 841
1369 2209 1
529 841 2209
1681 529 1369
program qqq
implicit none
integer a(9),i1,i2,i3,i4,i5,
1 i6,i7,i8,i9,line1,line2,
1line3,line4,line5,line6,line7,i,j,dups,k
do 1 i1=1,99,2
a(1)=i1**2
do 2 i2=1,99,2
a(2)=i2**2
do 3 i3=1,99,2
a(3)=i3**2
line1=a(1)+a(2)+a(3)
do 4 i4=1,99,2
a(4)=i4**2
do 5 i5=1,99,2
a(5)=i5**2
do 6 i6=1,99,2
a(6)=i6**2
line2=a(4)+a(5)+a(6)
if (line2.ne.line1)go to 6
do 7 i7=1,99,2
a(7)=i7**2
line4=a(1)+a(4)+a(7)
if (line4.ne.line2)go to 7
do 8 i8=1,99,2
a(8)=i8**2
line5=a(2)+a(5)+a(8)
if (line5.ne.line4)go to 8
do 9 i9=1,99,2
a(9)=i9**2
line6=a(3)+a(6)+a(9)
if (line6.ne.line5)go to 9
line7=a(1)+a(5)+a(9)
if (line7.ne.line6)go to 9
dups=0
do i=1,8
do j=i+1,9
if(a(i).eq.a(j))dups=dups+1
if(i.eq.8.and.j.eq.9.and.dups.eq.3)then
print*
print 10,(a(k),k=1,9)
10 format(3(i4,x))
endif
enddo
enddo
9 enddo
8 enddo
7 enddo
6 enddo
5 enddo
4 enddo
3 enddo
2 enddo
1 enddo
end
Edited on November 25, 2022, 9:13 pm