'Self Orthogonal Latin Diagonal Squares
' Transformation to Idempotent Squares (Substitution)
' Tested with Office 365 under Windows 11
Sub SelfOrth8d()
Dim a1(8), a2(64), a(64)
y = MsgBox("Locked", vbCritical, "Routine SelfOrth8a")
End
n2 = 0: n9 = 0: k1 = 1: k2 = 1
s1 = 28: s2 = 7: s4 = 14
Sheets("Klad1").Select
t1 = Timer
ShtNm1 = "BaseLns8a"
For j100 = 1 To 176 ''5808 'Input Squares (Transformations)
Cells(1, 1).Value = j100
' Read Input Square
For i1 = 1 To 64
a2(i1) = Sheets(ShtNm1).Cells(j100, i1).Value
Next i1
Tag1 = Sheets(ShtNm1).Cells(j100, 65).Value 'Base Sqr
Tag2 = Sheets(ShtNm1).Cells(j100, 66).Value 'Aspect
Tag3 = Sheets(ShtNm1).Cells(j100, 67).Value 'xfmr
' Read Diagonal
i2 = 0
For i1 = 1 To 64 Step 9
i2 = i2 + 1
a1(i2) = a2(i1)
Next i1
' transform Square
For i1 = 1 To 64
a0 = a2(i1)
For i2 = 1 To 8
If a0 = a1(i2) Then
a(i1) = i2 - 1: Exit For
End If
Next i2
Next i1
n9 = n9 + 1: GoSub 2650 'Print Transformed Square'
1000 Next j100
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
y = MsgBox(t10, 0, "Routine SelfOrth8c")
End
' Print results (selected numbers)
2645 For i1 = 1 To 64
Cells(n9, i1).Value = a(i1)
Next i1
Cells(n9, 65).Value = n9
Cells(1, 66).Value = n9
Return
' Print results (squares)
2650 n2 = n2 + 1
If n2 = 5 Then
n2 = 1: k1 = k1 + 9: k2 = 1
Else
If n9 > 1 Then k2 = k2 + 9
End If
Cells(k1, k2 + 1).Font.Color = -4165632
Cells(k1, k2 + 1).Value = n9
Cells(k1, k2 + 2).Value = Tag1
Cells(k1, k2 + 3).Value = Tag2
Cells(k1, k2 + 4).Value = Tag3
'' Cells(k1, k2 + 7).Value = s4 'Option
i3 = 0
For i1 = 1 To 8
For i2 = 1 To 8
i3 = i3 + 1
Cells(k1 + i1, k2 + i2).Value = a(i3)
Next i2
Next i1
Return
End Sub