Vorige Pagina About the Author

' Generates order 9 Associated Lozenge Squares of Subtraction (s9 = 369, Res9 = 41)
' Diamond Inalys (s4 = 164, s5 = 205)

' Tested with Office 365 under Windows 10

Sub DiaInlay9()

    Dim a1(81), a(81), b1(81), b(81), c(81)
    Dim b9(9), Res9(21)

y = MsgBox("Locked", vbCritical, "Routine DiaInlay9")
    End

    n2 = 0: n3 = 0: n9 = 0: k1 = 1: k2 = 1
   
    Sheets("Klad1").Select
    
    t1 = Timer

'   Define variables and Parameters
    
    GoSub 2000
 
 '  Initiate Variables
 
    a(41) = 41: b(41) = 41                              'Center

    m34 = 31: m60 = 59: m52 = 65: m44 = 29:             'Diamond 4 x 4

    m59 = 77: m51 = 3: m43 = 81: m35 = 35:              'Diamond 5 x 5
    m69 = 57: m61 = 7: m53 = 67: m45 = 13:

'   Generate Diamond 4 x 4 (Associated Magic Square)

    For j44 = m44 To m2 Step 2                                          'a(44)
    If b(a1(j44)) = 0 Then b(a1(j44)) = a1(j44): c(44) = a1(j44) Else GoTo 440
    a(44) = a1(j44)
       
    a(38) = p9 - a(44): If b(a(38)) = 0 Then b(a(38)) = a(38): c(38) = a(38) Else GoTo 380
         
    For j52 = m52 To m2 Step 2                                         'a(52)
    If b(a1(j52)) = 0 Then b(a1(j52)) = a1(j52): c(52) = a1(j52) Else GoTo 520
    a(52) = a1(j52)
        
    a(30) = p9 - a(52): If b(a(30)) = 0 Then b(a(30)) = a(30): c(30) = a(30) Else GoTo 300
        
    For j60 = m60 To m2 Step 2                                         'a(60)
    If b(a1(j60)) = 0 Then b(a1(j60)) = a1(j60): c(60) = a1(j60) Else GoTo 600
    a(60) = a1(j60)
        
    a(68) = s4 - a(60) - a(52) - a(44)
    If a(68) < a1(m1) Or a(68) > a1(m2) Then GoTo 680
    If b1(a(68)) = 0 Then GoTo 680
    If CInt(a(68) / 2) = a(68) / 2 Then GoTo 680
    If b(a(68)) = 0 Then b(a(68)) = a(68): c(68) = a(68) Else GoTo 680
        
    a(22) = p9 - a(60): If b(a(22)) = 0 Then b(a(22)) = a(22): c(22) = a(22) Else GoTo 220
    a(14) = p9 - a(68): If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 140

    For j34 = m34 To m2 Step 2                                         'a(34)
    If b(a1(j34)) = 0 Then b(a1(j34)) = a1(j34): c(34) = a1(j34) Else GoTo 340
    a(34) = a1(j34)

    a(42) = s4 - a(34) - a(52) - a(44)
    If a(42) < a1(m1) Or a(42) > a1(m2) Then GoTo 420
    If b1(a(42)) = 0 Then GoTo 420
    If CInt(a(42) / 2) = a(42) / 2 Then GoTo 420
    If b(a(42)) = 0 Then b(a(42)) = a(42): c(42) = a(42) Else GoTo 420
    
    a(50) = s4 - a(34) - a(60) - a(44)
    If a(50) < a1(m1) Or a(50) > a1(m2) Then GoTo 500
    If b1(a(50)) = 0 Then GoTo 500
    If CInt(a(50) / 2) = a(50) / 2 Then GoTo 500
    If b(a(50)) = 0 Then b(a(50)) = a(50): c(50) = a(50) Else GoTo 500
    
    a(58) = s4 - a(50) - a(42) - a(34)
    If a(58) < a1(m1) Or a(58) > a1(m2) Then GoTo 580
    If b1(a(58)) = 0 Then GoTo 580
    If CInt(a(58) / 2) = a(58) / 2 Then GoTo 580
    If b(a(58)) = 0 Then b(a(58)) = a(58): c(58) = a(58) Else GoTo 580
    
    a(24) = p9 - a(58): If b(a(24)) = 0 Then b(a(24)) = a(24): c(24) = a(24) Else GoTo 240
    a(32) = p9 - a(50): If b(a(32)) = 0 Then b(a(32)) = a(32): c(32) = a(32) Else GoTo 320
    a(40) = p9 - a(42): If b(a(40)) = 0 Then b(a(40)) = a(40): c(40) = a(40) Else GoTo 400
    a(48) = p9 - a(34): If b(a(48)) = 0 Then b(a(48)) = a(48): c(48) = a(48) Else GoTo 480

'       Generate Diamond 5 x 5 (Associated Magic Square)

    For j45 = m45 To m2 Step 2                                             'a(45)
    If b(a1(j45)) = 0 Then b(a1(j45)) = a1(j45): c(45) = a1(j45) Else GoTo 450
    a(45) = a1(j45)
    
    a(37) = p9 - a(45)
    If a(37) < a1(m1) Or a(37) > a1(m2) Then GoTo 370
    If b1(a(37)) = 0 Then GoTo 370
    If b(a(37)) = 0 Then b(a(37)) = a(37): c(37) = a(37) Else GoTo 370

    For j53 = m53 To m2 Step 2                                             'a(53)
    If b(a1(j53)) = 0 Then b(a1(j53)) = a1(j53): c(53) = a1(j53) Else GoTo 530
    a(53) = a1(j53)
    
    a(29) = p9 - a(53)
    If a(29) < a1(m1) Or a(29) > a1(m2) Then GoTo 290
    If b1(a(29)) = 0 Then GoTo 290
    If b(a(29)) = 0 Then b(a(29)) = a(29): c(29) = a(29) Else GoTo 290

    For j61 = m61 To m2 Step 2                                             'a(61)
    If b(a1(j61)) = 0 Then b(a1(j61)) = a1(j61): c(61) = a1(j61) Else GoTo 610
    a(61) = a1(j61)

    a(21) = p9 - a(61)
    If a(21) < a1(m1) Or a(21) > a1(m2) Then GoTo 210
    If b1(a(21)) = 0 Then GoTo 210
    If b(a(21)) = 0 Then b(a(21)) = a(21): c(21) = a(21) Else GoTo 210

    For j69 = m69 To m2 Step 2                                             'a(69)
    If b(a1(j69)) = 0 Then b(a1(j69)) = a1(j69): c(69) = a1(j69) Else GoTo 690
    a(69) = a1(j69)

    a(13) = p9 - a(69)
    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

    a(77) = s5 - a(69) - a(61) - a(53) - a(45)
    If a(77) < a1(m1) Or a(77) > a1(m2) Then GoTo 770
    If b1(a(77)) = 0 Then GoTo 770
    If CInt(a(77) / 2) = a(77) / 2 Then GoTo 770
    If b(a(77)) = 0 Then b(a(77)) = a(77): c(77) = a(77) Else GoTo 770
    
    a(5) = p9 - a(77)
    If a(5) < a1(m1) Or a(5) > a1(m2) Then GoTo 50
    If b1(a(5)) = 0 Then GoTo 50
    If b(a(5)) = 0 Then b(a(5)) = a(5): c(5) = a(5) Else GoTo 50
    
    For j35 = m35 To m2 Step 2                                             'a(35)
    If b(a1(j35)) = 0 Then b(a1(j35)) = a1(j35): c(35) = a1(j35) Else GoTo 350
    a(35) = a1(j35)

    a(47) = p9 - a(35)
    If a(47) < a1(m1) Or a(47) > a1(m2) Then GoTo 470
    If b1(a(47)) = 0 Then GoTo 470
    If b(a(47)) = 0 Then b(a(47)) = a(47): c(47) = a(47) Else GoTo 470

    For j43 = m43 To m2 Step 2                                             'a(43)
    If b(a1(j43)) = 0 Then b(a1(j43)) = a1(j43): c(43) = a1(j43) Else GoTo 430
    a(43) = a1(j43)

    a(39) = p9 - a(43)
    If a(39) < a1(m1) Or a(39) > a1(m2) Then GoTo 390
    If b1(a(39)) = 0 Then GoTo 390
    If b(a(39)) = 0 Then b(a(39)) = a(39): c(39) = a(39) Else GoTo 390

    For j51 = m51 To m2 Step 2                                             'a(51)
    If b(a1(j51)) = 0 Then b(a1(j51)) = a1(j51): c(51) = a1(j51) Else GoTo 510
    a(51) = a1(j51)

    a(31) = p9 - a(51)
    If a(31) < a1(m1) Or a(31) > a1(m2) Then GoTo 310
    If b1(a(31)) = 0 Then GoTo 310
    If b(a(31)) = 0 Then b(a(31)) = a(31): c(31) = a(31) Else GoTo 310

    For j59 = m59 To m2 Step 2                                             'a(59)
    If b(a1(j59)) = 0 Then b(a1(j59)) = a1(j59): c(59) = a1(j59) Else GoTo 590
    a(59) = a1(j59)

    a(23) = p9 - a(59)
    If a(23) < a1(m1) Or a(23) > a1(m2) Then GoTo 230
    If b1(a(23)) = 0 Then GoTo 230
    If b(a(23)) = 0 Then b(a(23)) = a(23): c(23) = a(23) Else GoTo 230

    a(67) = s5 - a(59) - a(51) - a(43) - a(35)
    If a(67) < a1(m1) Or a(67) > a1(m2) Then GoTo 670
    If b1(a(67)) = 0 Then GoTo 670
    If CInt(a(67) / 2) = a(67) / 2 Then GoTo 670
    If b(a(67)) = 0 Then b(a(67)) = a(67): c(67) = a(67) Else GoTo 670
    
    a(15) = p9 - a(67)
    If a(15) < a1(m1) Or a(15) > a1(m2) Then GoTo 150
    If b1(a(15)) = 0 Then GoTo 150
    If b(a(15)) = 0 Then b(a(15)) = a(15): c(15) = a(15) Else GoTo 150
    
    a(25) = s5 / 5 + a(67) - a(35) + a(77) - a(45)
    If a(25) < a1(m1) Or a(25) > a1(m2) Then GoTo 250
    If b1(a(25)) = 0 Then GoTo 250
    If CInt(a(25) / 2) = a(25) / 2 Then GoTo 250
    If b(a(25)) = 0 Then b(a(25)) = a(25): c(25) = a(25) Else GoTo 250
    
    a(33) = s5 / 5 + a(59) - a(43) + a(69) - a(53)
    If a(33) < a1(m1) Or a(33) > a1(m2) Then GoTo 330
    If b1(a(33)) = 0 Then GoTo 330
    If CInt(a(33) / 2) = a(33) / 2 Then GoTo 330
    If b(a(33)) = 0 Then b(a(33)) = a(33): c(33) = a(33) Else GoTo 330
    
    a(49) = p9 - a(33)
    If a(49) < a1(m1) Or a(49) > a1(m2) Then GoTo 490
    If b1(a(49)) = 0 Then GoTo 490
    If b(a(49)) = 0 Then b(a(49)) = a(49): c(49) = a(49) Else GoTo 490
    
    a(57) = p9 - a(25)
    If a(57) < a1(m1) Or a(57) > a1(m2) Then GoTo 570:
    If b1(a(57)) = 0 Then GoTo 570
    If b(a(57)) = 0 Then b(a(57)) = a(57): c(57) = a(57) Else GoTo 570

'Complete Columns 4, 5, 6

    For jj78 = m78 To m2 - 1 Step 2                                    'a(78)
    If b(a1(jj78)) = 0 Then b(a1(jj78)) = a1(jj78): c(78) = a1(jj78) Else GoTo 2780
    a(78) = a1(jj78)
    
    a(4) = p9 - a(78)
    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
    
    a(76) = s9 - a(4) - a(13) - a(22) - a(31) - a(40) - a(49) - a(58) - a(67)
    If a(76) < a1(m1) Or a(76) > a1(m2) Then GoTo 2760
    If b1(a(76)) = 0 Then GoTo 2760
    If CInt(a(76) / 2) <> a(76) / 2 Then GoTo 2760
    If b(a(76)) = 0 Then b(a(76)) = a(76): c(76) = a(76) Else GoTo 2760
    
    a(6) = p9 - a(76)
    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
    
i10 = 13: GoSub 1000: If Res9(i10) <> 41 Then GoTo 2055
   
    'Complete Rows 4, 5, 6
    
    For jj36 = m36 To m2 - 1 Step 2                                    'a(36)
    If b(a1(jj36)) = 0 Then b(a1(jj36)) = a1(jj36): c(36) = a1(jj36) Else GoTo 2360
    a(36) = a1(jj36)
    
    a(46) = p9 - a(36)
    If a(46) < a1(m1) Or a(46) > a1(m2) Then GoTo 2460
    If b1(a(46)) = 0 Then GoTo 2460
    If b(a(46)) = 0 Then b(a(46)) = a(46): c(46) = a(46) Else GoTo 2460
    
    a(54) = s9 - a(46) - a(47) - a(48) - a(49) - a(50) - a(51) - a(52) - a(53)
    If a(54) < a1(m1) Or a(54) > a1(m2) Then GoTo 2540
    If b1(a(54)) = 0 Then GoTo 2540
    If CInt(a(54) / 2) <> a(54) / 2 Then GoTo 2540
    If b(a(54)) = 0 Then b(a(54)) = a(54): c(54) = a(54) Else GoTo 2540
    
    a(28) = p9 - a(54)
    If a(28) < a1(m1) Or a(28) > a1(m2) Then GoTo 2280
    If b1(a(28)) = 0 Then GoTo 2280
    If b(a(28)) = 0 Then b(a(28)) = a(28): c(28) = a(28) Else GoTo 2280
    
i10 = 4: GoSub 1000: If Res9(i10) <> 41 Then GoTo 2275
   
    'Complete Columns 3, 7
    
    For jj79 = m79 To m2 - 1 Step 2                                    'a(79)
    If b(a1(jj79)) = 0 Then b(a1(jj79)) = a1(jj79): c(79) = a1(jj79) Else GoTo 2790
    a(79) = a1(jj79)
    
    a(3) = p9 - a(79)
    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 jj70 = m70 To m2 - 1 Step 2                                    'a(70)
    If b(a1(jj70)) = 0 Then b(a1(jj70)) = a1(jj70): c(70) = a1(jj70) Else GoTo 2700
    a(70) = a1(jj70)
    
    a(12) = p9 - a(70)
    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
    
    For jj16 = m16 To m2 - 1 Step 2                                    'a(16)
    If b(a1(jj16)) = 0 Then b(a1(jj16)) = a1(jj16): c(16) = a1(jj16) Else GoTo 2160
    a(16) = a1(jj16)
    
    a(66) = p9 - a(16)
    If a(66) < a1(m1) Or a(66) > a1(m2) Then GoTo 2660
    If b1(a(66)) = 0 Then GoTo 2660
    If b(a(66)) = 0 Then b(a(66)) = a(66): c(66) = a(66) Else GoTo 2660
    
    a(7) = s9 - a(16) - a(25) - a(34) - a(43) - a(52) - a(61) - a(70) - a(79)
    If a(7) < a1(m1) Or a(7) > a1(m2) Then GoTo 2070
    If b1(a(7)) = 0 Then GoTo 2070
    If CInt(a(7) / 2) <> a(7) / 2 Then GoTo 2070
    If b(a(7)) = 0 Then b(a(7)) = a(7): c(7) = a(7) Else GoTo 2070
    
    a(75) = p9 - a(7)
    If a(75) < a1(m1) Or a(75) > a1(m2) Then GoTo 2750
    If b1(a(75)) = 0 Then GoTo 2750
    If b(a(75)) = 0 Then b(a(75)) = a(75): c(75) = a(75) Else GoTo 2750
    
i10 = 12: GoSub 1000: If Res9(i10) <> 41 Then GoTo 2745

    'Complete Rows 3, 7
    
    For jj27 = m27 To m2 - 1 Step 2                                    'a(27)
    If b(a1(jj27)) = 0 Then b(a1(jj27)) = a1(jj27): c(27) = a1(jj27) Else GoTo 2270
    a(27) = a1(jj27)
    
    a(55) = p9 - a(27)
    If a(55) < a1(m1) Or a(55) > a1(m2) Then GoTo 2550
    If b1(a(55)) = 0 Then GoTo 2550
    If b(a(55)) = 0 Then b(a(55)) = a(55): c(55) = a(55) Else GoTo 2550
    
    For jj26 = m26 To m2 - 1 Step 2                                    'a(26)
    If b(a1(jj26)) = 0 Then b(a1(jj26)) = a1(jj26): c(26) = a1(jj26) Else GoTo 2260
    a(26) = a1(jj26)
    
    a(56) = p9 - a(26)
    If a(56) < a1(m1) Or a(56) > a1(m2) Then GoTo 2560
    If b1(a(56)) = 0 Then GoTo 2560
    If b(a(56)) = 0 Then b(a(56)) = a(56): c(56) = a(56) Else GoTo 2560
    
    For jj20 = m20 To m2 - 1 Step 2                                    'a(20)
    If b(a1(jj20)) = 0 Then b(a1(jj20)) = a1(jj20): c(20) = a1(jj20) Else GoTo 2200
    a(20) = a1(jj20)
    
    a(62) = p9 - a(20)
    If a(62) < a1(m1) Or a(62) > a1(m2) Then GoTo 2620
    If b1(a(62)) = 0 Then GoTo 2620
    If b(a(62)) = 0 Then b(a(62)) = a(62): c(62) = a(62) Else GoTo 2620
    
    a(19) = s9 - a(20) - a(21) - a(22) - a(23) - a(24) - a(25) - a(26) - a(27)
    If a(19) < a1(m1) Or a(19) > a1(m2) Then GoTo 2190
    If b1(a(19)) = 0 Then GoTo 2190
    If CInt(a(19) / 2) <> a(19) / 2 Then GoTo 2190
    If b(a(19)) = 0 Then b(a(19)) = a(19): c(19) = a(19) Else GoTo 2190
    
    a(63) = p9 - a(19)
    If a(63) < a1(m1) Or a(63) > a1(m2) Then GoTo 2630
    If b1(a(63)) = 0 Then GoTo 2630
    If b(a(63)) = 0 Then b(a(63)) = a(63): c(63) = a(63) Else GoTo 2630
    
i10 = 3: GoSub 1000: If Res9(i10) <> 41 Then GoTo 2625
    
    For jj81 = m81 To m2 - 1 Step 2                                    'a(81)
    If b(a1(jj81)) = 0 Then b(a1(jj81)) = a1(jj81): c(81) = a1(jj81) Else GoTo 2810
    a(81) = a1(jj81)
    
    a(1) = p9 - a(81)
    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 jj80 = m80 To m2 - 1 Step 2                                    'a(80)
    If b(a1(jj80)) = 0 Then b(a1(jj80)) = a1(jj80): c(80) = a1(jj80) Else GoTo 2800
    a(80) = a1(jj80)
    
    a(2) = p9 - a(80)
    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 jj74 = m74 To m2 - 1 Step 2                                    'a(74)
    If b(a1(jj74)) = 0 Then b(a1(jj74)) = a1(jj74): c(74) = a1(jj74) Else GoTo 2740
    a(74) = a1(jj74)
    
    a(8) = p9 - a(74)
    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
    
    a(73) = s9 - a(74) - a(75) - a(76) - a(77) - a(78) - a(79) - a(80) - a(81)
    If a(73) < a1(m1) Or a(73) > a1(m2) Then GoTo 2730
    If b1(a(73)) = 0 Then GoTo 2730
    If CInt(a(73) / 2) <> a(73) / 2 Then GoTo 2730
    If b(a(73)) = 0 Then b(a(73)) = a(73): c(73) = a(73) Else GoTo 2730
    
    a(9) = p9 - a(73)
    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

i10 = 9: GoSub 1000: If Res9(i10) <> 41 Then GoTo 2085

    For jj64 = m64 To m2 - 1 Step 2                                    'a(64)
    If b(a1(jj64)) = 0 Then b(a1(jj64)) = a1(jj64): c(64) = a1(jj64) Else GoTo 2640
    a(64) = a1(jj64)
    
    a(18) = p9 - a(64)
    If a(18) < a1(m1) Or a(18) > a1(m2) Then GoTo 2180
    If b1(a(18)) = 0 Then GoTo 2180
    If b(a(18)) = 0 Then b(a(18)) = a(18): c(18) = a(18) Else GoTo 2180
    
    a(10) = s9 - a(1) - a(19) - a(28) - a(37) - a(46) - a(55) - a(64) - a(73)
    If a(10) < a1(m1) Or a(10) > a1(m2) Then GoTo 2100
    If b1(a(10)) = 0 Then GoTo 2100
    If CInt(a(10) / 2) <> a(10) / 2 Then GoTo 2100
    If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 2100
    
    a(72) = p9 - a(10)
    If a(72) < a1(m1) Or a(72) > a1(m2) Then GoTo 2720
    If b1(a(72)) = 0 Then GoTo 2720
    If b(a(72)) = 0 Then b(a(72)) = a(72): c(72) = a(72) Else GoTo 2720

i10 = 10: GoSub 1000: If Res9(i10) <> 41 Then GoTo 5

    a(71) = (10 * s9 / 9 - a(44) + a(47) - a(53) + a(56) - a(62) - a(64) - a(66) - a(67) - a(68) - a(69) - a(70) - a(72) + a(74) - a(80)) / 2

    If a(71) < a1(m1) Or a(71) > a1(m2) Or CInt(a(71)) <> a(71) Then GoTo 2710
    If b1(a(71)) = 0 Then GoTo 2710
    If CInt(a(71) / 2) <> a(71) / 2 Then GoTo 2710
    If b(a(71)) = 0 Then b(a(71)) = a(71): c(71) = a(71) Else GoTo 2710
    
    a(11) = p9 - a(71)
    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(65) = 7 * s9 / 9 + a(11) - a(64) - a(66) - a(67) - a(68) - a(69) - a(70) - a(72)
    If a(65) < a1(m1) Or a(65) > a1(m2) Then GoTo 2650
    If b1(a(65)) = 0 Then GoTo 2650
    If CInt(a(65) / 2) <> a(65) / 2 Then GoTo 2650
    If b(a(65)) = 0 Then b(a(65)) = a(65): c(65) = a(65) Else GoTo 2650
    
    a(17) = p9 - a(65)
    If a(17) < a1(m1) Or a(17) > a1(m2) Then GoTo 2170
    If b1(a(17)) = 0 Then GoTo 2170
    If b(a(17)) = 0 Then b(a(17)) = a(17): c(17) = a(17) Else GoTo 2170

i10 = 11: GoSub 1000: If Res9(i10) <> 41 Then GoTo 5
i10 = 8: GoSub 1000: If Res9(i10) <> 41 Then GoTo 5

n9 = n9 + 1: GoSub 3650:

5

     b(c(17)) = 0: c(17) = 0
2170 b(c(65)) = 0: c(65) = 0
2650 b(c(11)) = 0: c(11) = 0
2110 b(c(71)) = 0: c(71) = 0
2710 b(c(72)) = 0: c(72) = 0
2720 b(c(10)) = 0: c(10) = 0
2100 b(c(18)) = 0: c(18) = 0
2180 b(c(64)) = 0: c(64) = 0
2640 Next jj64
     m64 = 2
    
2085 b(c(9)) = 0: c(9) = 0
2090 b(c(73)) = 0: c(73) = 0
2730 b(c(8)) = 0: c(8) = 0
2080 b(c(74)) = 0: c(74) = 0
2740 Next jj74
     m74 = 2
    
     b(c(2)) = 0: c(2) = 0
2020 b(c(80)) = 0: c(80) = 0
2800 Next jj80
     m80 = 2
    
     b(c(1)) = 0: c(1) = 0
2010 b(c(81)) = 0: c(81) = 0
2810 Next jj81
     m81 = 2

2625 b(c(63)) = 0: c(63) = 0
2630 b(c(19)) = 0: c(19) = 0
2190 b(c(62)) = 0: c(62) = 0
2620 b(c(20)) = 0: c(20) = 0
2200 Next jj20
     m20 = 2

     b(c(56)) = 0: c(56) = 0
2560 b(c(26)) = 0: c(26) = 0
2260 Next jj26
     m26 = 2

     b(c(55)) = 0: c(55) = 0
2550 b(c(27)) = 0: c(27) = 0
2270 Next jj27
     m27 = 2

2745 b(c(75)) = 0: c(75) = 0
2750 b(c(7)) = 0: c(7) = 0
2070 b(c(66)) = 0: c(66) = 0
2660 b(c(16)) = 0: c(16) = 0
2160 Next jj16
     m16 = 2

     b(c(12)) = 0: c(12) = 0
2120 b(c(70)) = 0: c(70) = 0
2700 Next jj70
     m70 = 2

     b(c(3)) = 0: c(3) = 0
2030 b(c(79)) = 0: c(79) = 0
2790 Next jj79
     m79 = 2

2275 b(c(28)) = 0: c(28) = 0
2280 b(c(54)) = 0: c(54) = 0
2540 b(c(46)) = 0: c(46) = 0
2460 b(c(36)) = 0: c(36) = 0
2360 Next jj36
     m36 = 2

2055 b(c(6)) = 0: c(6) = 0
2060 b(c(76)) = 0: c(76) = 0
2760 b(c(4)) = 0: c(4) = 0
2040 b(c(78)) = 0: c(78) = 0
2780 Next jj78
     m78 = 2

    b(c(57)) = 0: c(57) = 0
570 b(c(49)) = 0: c(49) = 0
490 b(c(33)) = 0: c(33) = 0
330 b(c(25)) = 0: c(25) = 0
250
    b(c(15)) = 0: c(15) = 0
150 b(c(67)) = 0: c(67) = 0
670 b(c(23)) = 0: c(23) = 0
230 b(c(59)) = 0: c(59) = 0
590 Next j59
    m59 = 1

    b(c(31)) = 0: c(31) = 0
310 b(c(51)) = 0: c(51) = 0
510 Next j51
    m51 = 1

    b(c(39)) = 0: c(39) = 0
390 b(c(43)) = 0: c(43) = 0
430 Next j43
    m43 = 1

    b(c(47)) = 0: c(47) = 0
470 b(c(35)) = 0: c(35) = 0
350 Next j35
    m35 = 1
   
    b(c(5)) = 0: c(5) = 0
50  b(c(77)) = 0: c(77) = 0
770 b(c(13)) = 0: c(13) = 0
130 b(c(69)) = 0: c(69) = 0
690 Next j69
    m69 = 1

    b(c(21)) = 0: c(21) = 0
210 b(c(61)) = 0: c(61) = 0
610 Next j61
    m61 = 1
    
    b(c(29)) = 0: c(29) = 0
290 b(c(53)) = 0: c(53) = 0
530 Next j53
    m53 = 1

    b(c(37)) = 0: c(37) = 0
370 b(c(45)) = 0: c(45) = 0
450 Next j45
    m45 = 1
    
    b(c(48)) = 0: c(48) = 0
480 b(c(40)) = 0: c(40) = 0
400 b(c(32)) = 0: c(32) = 0
320 b(c(24)) = 0: c(24) = 0
240 b(c(58)) = 0: c(58) = 0
580 b(c(50)) = 0: c(50) = 0
500 b(c(42)) = 0: c(42) = 0
420 b(c(34)) = 0: c(34) = 0
340 Next j34
    m34 = 1
    
    b(c(14)) = 0: c(14) = 0
140 b(c(22)) = 0: c(22) = 0
220 b(c(68)) = 0: c(68) = 0
680 b(c(60)) = 0: c(60) = 0
600 Next j60
    m60 = 1

    b(c(30)) = 0: c(30) = 0
300 b(c(52)) = 0: c(52) = 0
520 Next j52
    m52 = 1

    b(c(38)) = 0: c(38) = 0
380 b(c(44)) = 0: c(44) = 0
440 Next j44
    m44 = 1

   t2 = Timer
    
   t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s9)
   y = MsgBox(t10, 0, "Routine DiaInlay9")

End

'    Define Variables

2000 m1 = 1: m2 = 81: r9 = 41:
     s9 = 369: p9 = 82
     s4 = 2 * p9
     s5 = 5 * p9 / 2

     For i1 = m1 To m2
         a1(i1) = i1
     Next i1
     
     Erase b1
     For i1 = m1 To m2
         b1(a1(i1)) = a1(i1)
     Next i1
     Return

'    Print results (selected numbers)

3645 For i1 = 1 To 81
         Cells(n9, i1).Value = a(i1)
     Next i1
    
     Return

'   Print results (squares)

3650 n2 = n2 + 1
     If n2 = 5 Then
         n2 = 1: k1 = k1 + 10: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 10
     End If
     
''   Cells(1, 1).Value = n9
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = CStr(n9)
    
     i3 = 0
     For i1 = 1 To 9
         For i2 = 1 To 9
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1
    
     Return

'   determine Residuum line i10

1000

    Select Case i10
    
'       Rows
    
        Case 1:
                b9(1) = a(1): b9(2) = a(2): b9(3) = a(3): b9(4) = a(4): b9(5) = a(5): b9(6) = a(6): b9(7) = a(7): b9(8) = a(8): b9(9) = a(9):
                GoSub 1200
        Case 2:
                b9(1) = a(10): b9(2) = a(11): b9(3) = a(12): b9(4) = a(13): b9(5) = a(14): b9(6) = a(15): b9(7) = a(16): b9(8) = a(17): b9(9) = a(18):
                GoSub 1200
        Case 3:
                b9(1) = a(19): b9(2) = a(20): b9(3) = a(21): b9(4) = a(22): b9(5) = a(23): b9(6) = a(24): b9(7) = a(25): b9(8) = a(26): b9(9) = a(27):
                GoSub 1200
        Case 4:
                b9(1) = a(28): b9(2) = a(29): b9(3) = a(30): b9(4) = a(31): b9(5) = a(32): b9(6) = a(33): b9(7) = a(34): b9(8) = a(35): b9(9) = a(36):
                GoSub 1200
        Case 5:
                b9(1) = a(37): b9(2) = a(38): b9(3) = a(39): b9(4) = a(40): b9(5) = a(41): b9(6) = a(42): b9(7) = a(43): b9(8) = a(44): b9(9) = a(45):
                GoSub 1200
        Case 6:
                b9(1) = a(46): b9(2) = a(47): b9(3) = a(48): b9(4) = a(49): b9(5) = a(50): b9(6) = a(51): b9(7) = a(52): b9(8) = a(53): b9(9) = a(54):
                GoSub 1200
        Case 7:
                b9(1) = a(55): b9(2) = a(56): b9(3) = a(57): b9(4) = a(58): b9(5) = a(59): b9(6) = a(60): b9(7) = a(61): b9(8) = a(62): b9(9) = a(63):
                GoSub 1200
        Case 8:
                b9(1) = a(64): b9(2) = a(65): b9(3) = a(66): b9(4) = a(67): b9(5) = a(68): b9(6) = a(69): b9(7) = a(70): b9(8) = a(71): b9(9) = a(72):
                GoSub 1200
        Case 9:
                b9(1) = a(73): b9(2) = a(74): b9(3) = a(75): b9(4) = a(76): b9(5) = a(77): b9(6) = a(78): b9(7) = a(79): b9(8) = a(80): b9(9) = a(81):
                GoSub 1200
        
'       Columns
       
        Case 10:
                b9(1) = a(1): b9(2) = a(10): b9(3) = a(19): b9(4) = a(28): b9(5) = a(37): b9(6) = a(46): b9(7) = a(55): b9(8) = a(64): b9(9) = a(73):
                GoSub 1200
        Case 11:
                b9(1) = a(2): b9(2) = a(11): b9(3) = a(20): b9(4) = a(29): b9(5) = a(38): b9(6) = a(47): b9(7) = a(56): b9(8) = a(65): b9(9) = a(74):
                GoSub 1200
        Case 12:
                b9(1) = a(3): b9(2) = a(12): b9(3) = a(21): b9(4) = a(30): b9(5) = a(39): b9(6) = a(48): b9(7) = a(57): b9(8) = a(66): b9(9) = a(75):
                GoSub 1200
        Case 13:
                b9(1) = a(4): b9(2) = a(13): b9(3) = a(22): b9(4) = a(31): b9(5) = a(40): b9(6) = a(49): b9(7) = a(58): b9(8) = a(67): b9(9) = a(76):
                GoSub 1200
        Case 14:
                b9(1) = a(5): b9(2) = a(14): b9(3) = a(23): b9(4) = a(32): b9(5) = a(41): b9(6) = a(50): b9(7) = a(59): b9(8) = a(68): b9(9) = a(77):
                GoSub 1200
        Case 15:
                b9(1) = a(6): b9(2) = a(15): b9(3) = a(24): b9(4) = a(33): b9(5) = a(42): b9(6) = a(51): b9(7) = a(60): b9(8) = a(69): b9(9) = a(78):
                GoSub 1200
        Case 16:
                b9(1) = a(7): b9(2) = a(16): b9(3) = a(25): b9(4) = a(34): b9(5) = a(43): b9(6) = a(52): b9(7) = a(61): b9(8) = a(70): b9(9) = a(79):
                GoSub 1200
        Case 17:
                b9(1) = a(8): b9(2) = a(17): b9(3) = a(26): b9(4) = a(35): b9(5) = a(44): b9(6) = a(53): b9(7) = a(62): b9(8) = a(71): b9(9) = a(80):
                GoSub 1200
        Case 18:
                b9(1) = a(9): b9(2) = a(18): b9(3) = a(27): b9(4) = a(36): b9(5) = a(45): b9(6) = a(54): b9(7) = a(63): b9(8) = a(72): b9(9) = a(81):
                GoSub 1200
        
'       Diagonals
        
        Case 19:
                b9(1) = a(1): b9(2) = a(11): b9(3) = a(21): b9(4) = a(31): b9(5) = a(41): b9(6) = a(51): b9(7) = a(61): b9(8) = a(71): b9(9) = a(81):
                GoSub 1200
        Case 20:
                b9(1) = a(9): b9(2) = a(17): b9(3) = a(25): b9(4) = a(33): b9(5) = a(41): b9(6) = a(49): b9(7) = a(57): b9(8) = a(65): b9(9) = a(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

Vorige Pagina About the Author