' Generates order 9 Semi Magic Squares of Subtraction (s9 = 369, Res9 = 41)
' Associated Corner Squares (s4 = 164, s5 = 205)
' Suitable for transformation to Associated Magic Squares of Subtraction with order 4 and 5 Square Inlays
' Tested with Office 365 under Windows 10
Sub SqrInlay9()
Dim a1(81), a(81), a9(81), b1(81), b(81), c(81)
Dim b9(9), Res9(21)
y = MsgBox("Locked", vbCritical, "Routine SqrInlay9")
End
Sheets("Klad1").Select
n5 = 0: n9 = 0: k1 = 1: k2 = 1
t1 = Timer
For j101 = 1 To 81
' Pre Select j16
m11 = j101: If m11 = 41 Then GoTo 1500
' Read Pairs
Pr3 = 82: Cntr3 = 41: nvar = 81
s4 = 2 * Pr3 'MC4
s5 = 5 * Cntr3 'MC5
s9 = 9 * Cntr3 'MC9
For j1 = 1 To nvar
x = j1: a1(j1) = x: b1(x) = x
Next j1
m1 = 1: m2 = nvar
' Generate Associated Corner Square 4 x 4
b(Cntr3) = Cntr3 'Block Center Element
For j16 = m11 To m11 'a(16)
If b(a1(j16)) = 0 Then b(a1(j16)) = a1(j16): c(16) = a1(j16) Else GoTo 160
a(16) = a1(j16)
For j15 = m1 To m2 'a(15)
If b(a1(j15)) = 0 Then b(a1(j15)) = a1(j15): c(15) = a1(j15) Else GoTo 150
a(15) = a1(j15)
For j14 = m1 To m2 'a(14)
If b(a1(j14)) = 0 Then b(a1(j14)) = a1(j14): c(14) = a1(j14) Else GoTo 140
a(14) = a1(j14)
a(13) = s4 - a(14) - a(15) - a(16)
If a(13) < a1(m1) Or a(13) > a1(m2) Then GoTo 130
If b1(a(13)) = 0 Then GoTo 130
If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 130
For j12 = m1 To m2 'a(12)
If b(a1(j12)) = 0 Then b(a1(j12)) = a1(j12): c(12) = a1(j12) Else GoTo 120
a(12) = a1(j12)
a(11) = s4 - a(12) - a(15) - a(16)
If a(11) < a1(m1) Or a(11) > a1(m2) Then GoTo 70
If b1(a(11)) = 0 Then GoTo 70
a(10) = s4 - a(12) - a(14) - a(16)
If a(10) < a1(m1) Or a(10) > a1(m2) Then GoTo 70
If b1(a(10)) = 0 Then GoTo 70
a(9) = s4 - a(10) - a(11) - a(12)
If a(9) < a1(m1) Or a(9) > a1(m2) Then GoTo 70
If b1(a(9)) = 0 Then GoTo 70
a(8) = 0.5 * s4 - a(9): a(7) = 0.5 * s4 - a(10): a(6) = 0.5 * s4 - a(11):
a(5) = 0.5 * s4 - a(12): a(4) = 0.5 * s4 - a(13): a(3) = 0.5 * s4 - a(14):
a(2) = 0.5 * s4 - a(15): a(1) = 0.5 * s4 - a(16):
n45 = 16: GoSub 820 'Check Identical Numbers
If fl1 = 0 Then GoTo 70
a9(1) = a(1): a9(2) = a(2): a9(3) = a(3): a9(4) = a(4):
a9(10) = a(5): a9(11) = a(6): a9(12) = a(7): a9(13) = a(8):
a9(19) = a(9): a9(20) = a(10): a9(21) = a(11): a9(22) = a(12):
a9(28) = a(13): a9(29) = a(14): a9(30) = a(15): a9(31) = a(16):
n53 = 16: GoSub 910 'Remove used integers a() from available integers b1()
Erase b, c: GoTo 200
70 b(c(12)) = 0: c(12) = 0
120 Next j12
b(c(13)) = 0: c(13) = 0
130 b(c(14)) = 0: c(14) = 0
140 Next j14
b(c(15)) = 0: c(15) = 0
150 Next j15
b(c(16)) = 0: c(16) = 0
160 Next j16
Erase b1, b, c: GoTo 1500 'Not Found, Next j101
' Determine Border Sections 4 x 5 (2 ea)
200 n10 = 0 'Continue
b(Cntr3) = Cntr3 'Block Center Element
For j20 = m1 To m2 'a(20)
If b1(a1(j20)) = 0 Then GoTo 3200
If b(a1(j20)) = 0 Then b(a1(j20)) = a1(j20): c(20) = a1(j20) Else GoTo 3200
a(20) = a1(j20)
a(1) = 2 * s5 / 5 - a(20): If b(a(1)) = 0 Then b(a(1)) = a(1): c(1) = a(1) Else GoTo 3010
For j19 = m1 To m2 'a(19)
If b1(a1(j19)) = 0 Then GoTo 3190
If b(a1(j19)) = 0 Then b(a1(j19)) = a1(j19): c(19) = a1(j19) Else GoTo 3190
a(19) = a1(j19)
a(2) = 2 * s5 / 5 - a(19): If b(a(2)) = 0 Then b(a(2)) = a(2): c(2) = a(2) Else GoTo 3020
For j18 = m1 To m2 'a(18)
If b1(a1(j18)) = 0 Then GoTo 3180
If b(a1(j18)) = 0 Then b(a1(j18)) = a1(j18): c(18) = a1(j18) Else GoTo 3180
a(18) = a1(j18)
a(3) = 2 * s5 / 5 - a(18): If b(a(3)) = 0 Then b(a(3)) = a(3): c(3) = a(3) Else GoTo 3030
For j17 = m1 To m2 'a(17)
If b1(a1(j17)) = 0 Then GoTo 3170
If b(a1(j17)) = 0 Then b(a1(j17)) = a1(j17): c(17) = a1(j17) Else GoTo 3170
a(17) = a1(j17)
a(16) = s5 - a(17) - a(18) - a(19) - a(20)
If a(16) < a1(m1) Or a(16) > a1(m2) Then GoTo 3160
If b1(a(16)) = 0 Then GoTo 3160
If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 3160
a(5) = 2 * s5 / 5 - a(16): If b(a(5)) = 0 Then b(a(5)) = a(5): c(5) = a(5) Else GoTo 3050
a(4) = 2 * s5 / 5 - a(17): If b(a(4)) = 0 Then b(a(4)) = a(4): c(4) = a(4) Else GoTo 3040
For j15 = m1 To m2 'a(15)
If b1(a1(j15)) = 0 Then GoTo 3150
If b(a1(j15)) = 0 Then b(a1(j15)) = a1(j15): c(15) = a1(j15) Else GoTo 3150
a(15) = a1(j15)
a(11) = -s5 + a(15) + a(17) + a(18) + a(19) + 2 * a(20)
If a(11) < a1(m1) Or a(11) > a1(m2) Then GoTo 3110
If b1(a(11)) = 0 Then GoTo 3110
If b(a(11)) = 0 Then b(a(11)) = a(11): c(11) = a(11) Else GoTo 3110
a(10) = 2 * s5 / 5 - a(11): If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 3100
a(6) = 2 * s5 / 5 - a(15): If b(a(6)) = 0 Then b(a(6)) = a(6): c(6) = a(6) Else GoTo 3060
For j14 = m1 To m2 'a(14)
If b1(a1(j14)) = 0 Then GoTo 3140
If b(a1(j14)) = 0 Then b(a1(j14)) = a1(j14): c(14) = a1(j14) Else GoTo 3140
a(14) = a1(j14)
a(13) = 2 * s5 - 2 * a(14) - 2 * a(15) - a(18) - 2 * a(19) - 2 * a(20)
If a(13) < a1(m1) Or a(13) > a1(m2) Then GoTo 3130
If b1(a(13)) = 0 Then GoTo 3130
If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 3130
a(12) = a(14) - a(17) + a(19)
If a(12) < a1(m1) Or a(12) > a1(m2) Then GoTo 3120
If b1(a(12)) = 0 Then GoTo 3120
If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 3120
a(9) = 2 * s5 / 5 - a(12): If b(a(9)) = 0 Then b(a(9)) = a(9): c(9) = a(9) Else GoTo 3090
a(8) = 2 * s5 / 5 - a(13): If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 3080
a(7) = 2 * s5 / 5 - a(14): If b(a(7)) = 0 Then b(a(7)) = a(7): c(7) = a(7) Else GoTo 3070
'' If n10 = 1 Then
'' a9(41) = s9 - a(17) - a(13) - a(9) - a(5) - a9(9) - a9(17) - a9(25) - a9(33)
'' If a9(41) < a1(m1) Or a9(41) > a1(m2) Then GoTo 5:
'' If b1(a9(41)) = 0 Then GoTo 5
'' If b(a9(41)) <> 0 Then GoTo 5
'' End If
n10 = n10 + 1
If n10 = 1 Then
a9(5) = a(1): a9(6) = a(2): a9(7) = a(3): a9(8) = a(4): a9(9) = a(5):
a9(14) = a(6): a9(15) = a(7): a9(16) = a(8): a9(17) = a(9): a9(18) = a(10):
a9(23) = a(11): a9(24) = a(12): a9(25) = a(13): a9(26) = a(14): a9(27) = a(15):
a9(32) = a(16): a9(33) = a(17): a9(34) = a(18): a9(35) = a(19): a9(36) = a(20):
i10 = 1: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
i10 = 2: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
i10 = 3: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
i10 = 4: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
n53 = 20: GoSub 910 'Remove used integers a() from available integers b1()
Erase b, c: GoTo 3200
Else
a9(37) = a(1): a9(38) = a(6): a9(39) = a(11): a9(40) = a(16):
a9(46) = a(2): a9(47) = a(7): a9(48) = a(12): a9(49) = a(17):
a9(55) = a(3): a9(56) = a(8): a9(57) = a(13): a9(58) = a(18):
a9(64) = a(4): a9(65) = a(9): a9(66) = a(14): a9(67) = a(19):
a9(73) = a(5): a9(74) = a(10): a9(75) = a(15): a9(76) = a(20):
i10 = 10: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
i10 = 11: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
i10 = 12: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
i10 = 13: GoSub 1000: If Res9(i10) <> 41 Then n10 = n10 - 1: GoTo 5
n53 = 20: GoSub 910 'Remove used integers a() from available integers b1()
Erase b, c: GoTo 2000
End If
5
b(c(7)) = 0: c(7) = 0
3070 b(c(8)) = 0: c(8) = 0
3080 b(c(9)) = 0: c(9) = 0
3090 b(c(12)) = 0: c(12) = 0
3120 b(c(13)) = 0: c(13) = 0
3130 b(c(14)) = 0: c(14) = 0
3140 Next j14
b(c(6)) = 0: c(6) = 0
3060 b(c(10)) = 0: c(10) = 0
3100 b(c(11)) = 0: c(11) = 0
3110 b(c(15)) = 0: c(15) = 0
3150 Next j15
b(c(4)) = 0: c(4) = 0
3040 b(c(5)) = 0: c(5) = 0
3050 b(c(16)) = 0: c(16) = 0
3160 b(c(17)) = 0: c(17) = 0
3170 Next j17
b(c(3)) = 0: c(3) = 0
3030 b(c(18)) = 0: c(18) = 0
3180 Next j18
b(c(2)) = 0: c(2) = 0
3020 b(c(19)) = 0: c(19) = 0
3190 Next j19
b(c(1)) = 0: c(1) = 0
3010 b(c(20)) = 0: c(20) = 0
3200 Next j20
Erase b1, b, c: GoTo 1500 'Not Found, Next j101
' Generate Associated Magic Square 5 x 5
2000 'Continue
'' a(25) = a9(41): b(a(25)) = a(25)
a(13) = 0.2 * s5: b(a(13)) = a(13)
For j25 = m1 To m2 'a(25)
If b1(a1(j25)) = 0 Then GoTo 2250
If b(a1(j25)) = 0 Then b(a1(j25)) = a1(j25): c(25) = a1(j25) Else GoTo 2250
a(25) = a1(j25)
Cells(2, 1).Value = j25
a(1) = 0.4 * s5 - a(25)
If a(1) < a1(m1) Or a(1) > a1(m2) Then GoTo 2010
If b1(a(1)) = 0 Then GoTo 2010
If b(a(1)) = 0 Then b(a(1)) = a(1): c(1) = a(1) Else GoTo 2010
For j24 = m1 To m2 'a(24)
If b1(a1(j24)) = 0 Then GoTo 2240
If b(a1(j24)) = 0 Then b(a1(j24)) = a1(j24): c(24) = a1(j24) Else GoTo 2240
a(24) = a1(j24)
a(2) = 0.4 * s5 - a(24)
If a(2) < a1(m1) Or a(2) > a1(m2) Then GoTo 2020
If b1(a(2)) = 0 Then GoTo 2020
If b(a(2)) = 0 Then b(a(2)) = a(2): c(2) = a(2) Else GoTo 2020
For j23 = m1 To m2 'a(23)
If b1(a1(j23)) = 0 Then GoTo 2230
If b(a1(j23)) = 0 Then b(a1(j23)) = a1(j23): c(23) = a1(j23) Else GoTo 2230
a(23) = a1(j23)
a(3) = 0.4 * s5 - a(23)
If a(3) < a1(m1) Or a(3) > a1(m2) Then GoTo 2030
If b1(a(3)) = 0 Then GoTo 2030
If b(a(3)) = 0 Then b(a(3)) = a(3): c(3) = a(3) Else GoTo 2030
For j22 = m1 To m2 'a(22)
If b1(a1(j22)) = 0 Then GoTo 2220
If b(a1(j22)) = 0 Then b(a1(j22)) = a1(j22): c(22) = a1(j22) Else GoTo 2220
a(22) = a1(j22)
a(21) = s5 - a(22) - a(23) - a(24) - a(25)
If a(21) < a1(m1) Or a(21) > a1(m2) Then GoTo 2210
If b1(a(21)) = 0 Then GoTo 2210
If b(a(21)) = 0 Then b(a(21)) = a(21): c(21) = a(21) Else GoTo 2210
a(5) = 0.4 * s5 - a(21)
If a(5) < a1(m1) Or a(5) > a1(m2) Then GoTo 2050
If b1(a(5)) = 0 Then GoTo 2050
If b(a(5)) = 0 Then b(a(5)) = a(5): c(5) = a(5) Else GoTo 2050
a(4) = 0.4 * s5 - a(22)
If a(4) < a1(m1) Or a(4) > a1(m2) Then GoTo 2040
If b1(a(4)) = 0 Then GoTo 2040
If b(a(4)) = 0 Then b(a(4)) = a(4): c(4) = a(4) Else GoTo 2040
''Check line 5
a9(41) = a(25): a9(42) = a(24): a9(43) = a(23): a9(44) = a(22): a9(45) = a(21):
i10 = 5: GoSub 1000: If Res9(i10) <> 41 Then GoTo 2035
For j20 = m1 To m2 'a(20)
If b1(a1(j20)) = 0 Then GoTo 2200
If b(a1(j20)) = 0 Then b(a1(j20)) = a1(j20): c(20) = a1(j20) Else GoTo 2200
a(20) = a1(j20)
a(6) = 2 * s5 / 5 - a(20)
If a(6) < a1(m1) Or a(6) > a1(m2) Then GoTo 2060
If b1(a(6)) = 0 Then GoTo 2060
If b(a(6)) = 0 Then b(a(6)) = a(6): c(6) = a(6) Else GoTo 2060
For j19 = m1 To m2 'a(19)
If b1(a1(j19)) = 0 Then GoTo 2190
If b(a1(j19)) = 0 Then b(a1(j19)) = a1(j19): c(19) = a1(j19) Else GoTo 2190
a(19) = a1(j19)
a(7) = 0.4 * s5 - a(19)
If a(7) < a1(m1) Or a(7) > a1(m2) Then GoTo 2070
If b1(a(7)) = 0 Then GoTo 2070
If b(a(7)) = 0 Then b(a(7)) = a(7): c(7) = a(7) Else GoTo 2070
For j18 = m1 To m2 'a(18)
If b1(a1(j18)) = 0 Then GoTo 2180
If b(a1(j18)) = 0 Then b(a1(j18)) = a1(j18): c(18) = a1(j18) Else GoTo 2180
a(18) = a1(j18)
a(8) = 0.4 * s5 - a(18)
If a(8) < a1(m1) Or a(8) > a1(m2) Then GoTo 2080
If b1(a(8)) = 0 Then GoTo 2080
If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 2080
For j17 = m1 To m2 'a(17)
If b1(a1(j17)) = 0 Then GoTo 2170
If b(a1(j17)) = 0 Then b(a1(j17)) = a1(j17): c(17) = a1(j17) Else GoTo 2170
a(17) = a1(j17)
a(16) = s5 - a(17) - a(18) - a(19) - a(20)
If a(16) < a1(m1) Or a(16) > a1(m2) Then GoTo 2160
If b1(a(16)) = 0 Then GoTo 2160
If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 2160
a(15) = s5 / 5 + a(16) - a(20) + a(21) - a(25)
If a(15) < a1(m1) Or a(15) > a1(m2) Then GoTo 2150
If b1(a(15)) = 0 Then GoTo 2150
If b(a(15)) = 0 Then b(a(15)) = a(15): c(15) = a(15) Else GoTo 2150
a(14) = s5 / 5 + a(17) - a(19) + a(22) - a(24)
If a(14) < a1(m1) Or a(14) > a1(m2) Then GoTo 2140
If b1(a(14)) = 0 Then GoTo 2140
If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 2140
a(12) = 0.4 * s5 - a(14)
If a(12) < a1(m1) Or a(12) > a1(m2) Then GoTo 2120
If b1(a(12)) = 0 Then GoTo 2120
If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 2120
a(11) = 0.4 * s5 - a(15)
If a(11) < a1(m1) Or a(11) > a1(m2) Then GoTo 2110:
If b1(a(11)) = 0 Then GoTo 2110
If b(a(11)) = 0 Then b(a(11)) = a(11): c(11) = a(11) Else GoTo 2110
a(10) = 2 * s5 / 5 - a(16)
If a(10) < a1(m1) Or a(10) > a1(m2) Then GoTo 2100:
If b1(a(10)) = 0 Then GoTo 2100
If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 2100
a(9) = 0.4 * s5 - a(17)
If a(9) < a1(m1) Or a(9) > a1(m2) Then GoTo 2090
If b1(a(9)) = 0 Then GoTo 2090
If b(a(9)) = 0 Then b(a(9)) = a(9): c(9) = a(9) Else GoTo 2090
n45 = 25: GoSub 820
If fl1 = 0 Then GoTo 2005
' Assign a() to a9()
a9(41) = a(25): a9(42) = a(24): a9(43) = a(23): a9(44) = a(22): a9(45) = a(21):
a9(50) = a(20): a9(51) = a(19): a9(52) = a(18): a9(53) = a(17): a9(54) = a(16):
a9(59) = a(15): a9(60) = a(14): a9(61) = a(13): a9(62) = a(12): a9(63) = a(11):
a9(68) = a(10): a9(69) = a(9): a9(70) = a(8): a9(71) = a(7): a9(72) = a(6):
a9(77) = a(5): a9(78) = a(4): a9(79) = a(3): a9(80) = a(2): a9(81) = a(1):
GoSub 800 'Double Check Identical Integers a9()
If fl1 = 0 Then GoTo 2005
n99 = 0
For i10 = 1 To 20
GoSub 1000: If Res9(i10) = 41 Then n99 = n99 + 1
Next i10
If n99 < 19 Then GoTo 2005
n9 = n9 + 1: GoSub 650 'Print Composed Squares a9()
Erase b1, b, c: GoTo 1500 'Print only first square
2005
b(c(9)) = 0: c(9) = 0
2090 b(c(10)) = 0: c(10) = 0
2100 b(c(11)) = 0: c(11) = 0
2110 b(c(12)) = 0: c(12) = 0
2120 b(c(14)) = 0: c(14) = 0
2140 b(c(15)) = 0: c(15) = 0
2150 b(c(16)) = 0: c(16) = 0
2160 b(c(17)) = 0: c(17) = 0
2170 Next j17
b(c(8)) = 0: c(8) = 0
2080 b(c(18)) = 0: c(18) = 0
2180 Next j18
b(c(7)) = 0: c(7) = 0
2070 b(c(19)) = 0: c(19) = 0
2190 Next j19
b(c(6)) = 0: c(6) = 0
2060 b(c(20)) = 0: c(20) = 0
2200 Next j20
2035 b(c(4)) = 0: c(4) = 0
2040 b(c(5)) = 0: c(5) = 0
2050 b(c(21)) = 0: c(21) = 0
2210 b(c(22)) = 0: c(22) = 0
2220 Next j22
b(c(3)) = 0: c(3) = 0
2030 b(c(23)) = 0: c(23) = 0
2230 Next j23
b(c(2)) = 0: c(2) = 0
2020 b(c(24)) = 0: c(24) = 0
2240 Next j24
b(c(1)) = 0: c(1) = 0
2010 b(c(25)) = 0: c(25) = 0
2250 Next j25
Erase b1, b, c
1500 Next j101
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions"
y = MsgBox(t10, 0, "Routine SqrInlay9")
End
' Print results (squares)
650 n5 = n5 + 1
If n5 = 5 Then
n5 = 1: k1 = k1 + 10: k2 = 1
Else
If n9 > 1 Then k2 = k2 + 10
End If
'' Cells(k1, k2 + 1).Select
Cells(k1, k2 + 1).Font.Color = -4165632
Cells(k1, k2 + 1).Value = j101
Cells(k1, k2 + 2).Value = n99
i3 = 0
For i1 = 1 To 9
For i2 = 1 To 9
i3 = i3 + 1
Cells(k1 + i1, k2 + i2).Value = a9(i3)
Next i2
Next i1
Return
' Double Check Identical Numbers a9()
800 fl1 = 1
For i1 = 1 To 81
a20 = a9(i1): If a20 = 0 Then GoTo 810
For i2 = (1 + i1) To 81
If a20 = a9(i2) Then fl1 = 0: Return
Next i2
810 Next i1
Return
' Double Check Identical Numbers a()
820 fl1 = 1
For i1 = 1 To n45
a20 = a(i1)
For i2 = (1 + i1) To n45
If a20 = a(i2) Then fl1 = 0: Return
Next i2
Next i1
Return
' Remove used integers a() from available integers b1()
910 For i1 = 1 To n53
b1(a(i1)) = 0
Next i1
Return
' determine Residuum line i10
1000
Select Case i10
' Rows
Case 1:
b9(1) = a9(1): b9(2) = a9(2): b9(3) = a9(3): b9(4) = a9(4): b9(5) = a9(5): b9(6) = a9(6): b9(7) = a9(7): b9(8) = a9(8): b9(9) = a9(9):
GoSub 1200
Case 2:
b9(1) = a9(10): b9(2) = a9(11): b9(3) = a9(12): b9(4) = a9(13): b9(5) = a9(14): b9(6) = a9(15): b9(7) = a9(16): b9(8) = a9(17): b9(9) = a9(18):
GoSub 1200
Case 3:
b9(1) = a9(19): b9(2) = a9(20): b9(3) = a9(21): b9(4) = a9(22): b9(5) = a9(23): b9(6) = a9(24): b9(7) = a9(25): b9(8) = a9(26): b9(9) = a9(27):
GoSub 1200
Case 4:
b9(1) = a9(28): b9(2) = a9(29): b9(3) = a9(30): b9(4) = a9(31): b9(5) = a9(32): b9(6) = a9(33): b9(7) = a9(34): b9(8) = a9(35): b9(9) = a9(36):
GoSub 1200
Case 5:
b9(1) = a9(37): b9(2) = a9(38): b9(3) = a9(39): b9(4) = a9(40): b9(5) = a9(41): b9(6) = a9(42): b9(7) = a9(43): b9(8) = a9(44): b9(9) = a9(45):
GoSub 1200
Case 6:
b9(1) = a9(46): b9(2) = a9(47): b9(3) = a9(48): b9(4) = a9(49): b9(5) = a9(50): b9(6) = a9(51): b9(7) = a9(52): b9(8) = a9(53): b9(9) = a9(54):
GoSub 1200
Case 7:
b9(1) = a9(55): b9(2) = a9(56): b9(3) = a9(57): b9(4) = a9(58): b9(5) = a9(59): b9(6) = a9(60): b9(7) = a9(61): b9(8) = a9(62): b9(9) = a9(63):
GoSub 1200
Case 8:
b9(1) = a9(64): b9(2) = a9(65): b9(3) = a9(66): b9(4) = a9(67): b9(5) = a9(68): b9(6) = a9(69): b9(7) = a9(70): b9(8) = a9(71): b9(9) = a9(72):
GoSub 1200
Case 9:
b9(1) = a9(73): b9(2) = a9(74): b9(3) = a9(75): b9(4) = a9(76): b9(5) = a9(77): b9(6) = a9(78): b9(7) = a9(79): b9(8) = a9(80): b9(9) = a9(81):
GoSub 1200
' Columns
Case 10:
b9(1) = a9(1): b9(2) = a9(10): b9(3) = a9(19): b9(4) = a9(28): b9(5) = a9(37): b9(6) = a9(46): b9(7) = a9(55): b9(8) = a9(64): b9(9) = a9(73):
GoSub 1200
Case 11:
b9(1) = a9(2): b9(2) = a9(11): b9(3) = a9(20): b9(4) = a9(29): b9(5) = a9(38): b9(6) = a9(47): b9(7) = a9(56): b9(8) = a9(65): b9(9) = a9(74):
GoSub 1200
Case 12:
b9(1) = a9(3): b9(2) = a9(12): b9(3) = a9(21): b9(4) = a9(30): b9(5) = a9(39): b9(6) = a9(48): b9(7) = a9(57): b9(8) = a9(66): b9(9) = a9(75):
GoSub 1200
Case 13:
b9(1) = a9(4): b9(2) = a9(13): b9(3) = a9(22): b9(4) = a9(31): b9(5) = a9(40): b9(6) = a9(49): b9(7) = a9(58): b9(8) = a9(67): b9(9) = a9(76):
GoSub 1200
Case 14:
b9(1) = a9(5): b9(2) = a9(14): b9(3) = a9(23): b9(4) = a9(32): b9(5) = a9(41): b9(6) = a9(50): b9(7) = a9(59): b9(8) = a9(68): b9(9) = a9(77):
GoSub 1200
Case 15:
b9(1) = a9(6): b9(2) = a9(15): b9(3) = a9(24): b9(4) = a9(33): b9(5) = a9(42): b9(6) = a9(51): b9(7) = a9(60): b9(8) = a9(69): b9(9) = a9(78):
GoSub 1200
Case 16:
b9(1) = a9(7): b9(2) = a9(16): b9(3) = a9(25): b9(4) = a9(34): b9(5) = a9(43): b9(6) = a9(52): b9(7) = a9(61): b9(8) = a9(70): b9(9) = a9(79):
GoSub 1200
Case 17:
b9(1) = a9(8): b9(2) = a9(17): b9(3) = a9(26): b9(4) = a9(35): b9(5) = a9(44): b9(6) = a9(53): b9(7) = a9(62): b9(8) = a9(71): b9(9) = a9(80):
GoSub 1200
Case 18:
b9(1) = a9(9): b9(2) = a9(18): b9(3) = a9(27): b9(4) = a9(36): b9(5) = a9(45): b9(6) = a9(54): b9(7) = a9(63): b9(8) = a9(72): b9(9) = a9(81):
GoSub 1200
' Diagonals
Case 19:
b9(1) = a9(1): b9(2) = a9(11): b9(3) = a9(21): b9(4) = a9(31): b9(5) = a9(41): b9(6) = a9(51): b9(7) = a9(61): b9(8) = a9(71): b9(9) = a9(81):
GoSub 1200
Case 20:
b9(1) = a9(9): b9(2) = a9(17): b9(3) = a9(25): b9(4) = a9(33): b9(5) = a9(41): b9(6) = a9(49): b9(7) = a9(57): b9(8) = a9(65): b9(9) = a9(73):
GoSub 1200
End Select
Return
1200
For i2 = 1 To 8
For i1 = i2 To 9
If b9(i2) < b9(i1) Then
x = b9(i1)
b9(i1) = b9(i2)
b9(i2) = x
End If
Next i1
Next i2
Res9(i10) = b9(1) - b9(2) + b9(3) - b9(4) + b9(5) - b9(6) + b9(7) - b9(8) + b9(9)
Return
End Sub