Vorige Pagina About the Author

' Generates Diamond Inlays of order 8 for Odd Numbers
' Suitable for Concentric Lozenge Squares of order 15

' Tested with Office 365 under Windows 10

Sub aDiamond8()

    Dim a1(113), a(225), b1(225), b(225), c(225)
 
    y = MsgBox("Locked", vbCritical, "Routine Diamond8")
    End

    Sheets("Klad1").Select

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

    For i1 = 0 To 112                                         'Odd Numbers
        a1(i1 + 1) = 2 * i1 + 1: b1(a1(i1 + 1)) = a1(i1 + 1)
    Next i1
    m1 = 1: m2 = 113: s1 = 1695: p2 = 226

    a(113) = 113: b(a(113)) = a(113)
    
    For j218 = m1 To m2
    If b(a1(j218)) = 0 Then b(a1(j218)) = a1(j218): c(218) = a1(j218) Else GoTo 2180
    a(218) = a1(j218)
   
    a(8) = p2 - a(218): If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 80
   
    For j204 = m1 To m2
    If b(a1(j204)) = 0 Then b(a1(j204)) = a1(j204): c(204) = a1(j204) Else GoTo 2040
    a(204) = a1(j204)
   
    a(24) = p2 - a(204): If b(a(24)) = 0 Then b(a(24)) = a(24): c(24) = a(24) Else GoTo 240

    For j190 = m1 To m2
    If b(a1(j190)) = 0 Then b(a1(j190)) = a1(j190): c(190) = a1(j190) Else GoTo 1900
    a(190) = a1(j190)
   
    a(40) = p2 - a(190): If b(a(40)) = 0 Then b(a(40)) = a(40): c(40) = a(40) Else GoTo 400
   
    a(176) = 4 * s1 / 15 - a(190) - a(204) - a(218)
    If a(176) < a1(m1) Or a(176) > a1(m2) Then GoTo 1760:
    If b1(a(176)) = 0 Then GoTo 1760
    If b(a(176)) = 0 Then b(a(176)) = a(176): c(176) = a(176) Else GoTo 1760

    a(56) = p2 - a(176): If b(a(56)) = 0 Then b(a(56)) = a(56): c(56) = a(56) Else GoTo 560

    For j202 = m2 To m1 Step -1
    If b(a1(j202)) = 0 Then b(a1(j202)) = a1(j202): c(202) = a1(j202) Else GoTo 2020
    a(202) = a1(j202)
   
    a(22) = p2 - a(202): If b(a(22)) = 0 Then b(a(22)) = a(22): c(22) = a(22) Else GoTo 220

    For j188 = m2 To m1 Step -1
    If b(a1(j188)) = 0 Then b(a1(j188)) = a1(j188): c(188) = a1(j188) Else GoTo 1880
    a(188) = a1(j188)
   
    a(38) = p2 - a(188): If b(a(38)) = 0 Then b(a(38)) = a(38): c(38) = a(38) Else GoTo 380
    
    For j174 = m2 To m1 Step -1
    If b(a1(j174)) = 0 Then b(a1(j174)) = a1(j174): c(174) = a1(j174) Else GoTo 1740
    a(174) = a1(j174)
   
    a(54) = p2 - a(174): If b(a(54)) = 0 Then b(a(54)) = a(54): c(54) = a(54) Else GoTo 540

    a(160) = 4 * s1 / 15 - a(174) - a(188) - a(202)
    If a(160) < a1(m1) Or a(160) > a1(m2) Then GoTo 1600:
    If b1(a(160)) = 0 Then GoTo 1600
    If b(a(160)) = 0 Then b(a(160)) = a(160): c(160) = a(160) Else GoTo 1600

    a(70) = p2 - a(160): If b(a(70)) = 0 Then b(a(70)) = a(70): c(70) = a(70) Else GoTo 700

    For j186 = m1 To m2
    If b(a1(j186)) = 0 Then b(a1(j186)) = a1(j186): c(186) = a1(j186) Else GoTo 1860
    a(186) = a1(j186)
   
    a(36) = p2 - a(186): If b(a(36)) = 0 Then b(a(36)) = a(36): c(36) = a(36) Else GoTo 360

    For j172 = m1 To m2
    If b(a1(j172)) = 0 Then b(a1(j172)) = a1(j172): c(172) = a1(j172) Else GoTo 1720
    a(172) = a1(j172)
   
    a(52) = p2 - a(172): If b(a(52)) = 0 Then b(a(52)) = a(52): c(52) = a(52) Else GoTo 520

    For j158 = m1 To m2
    If b(a1(j158)) = 0 Then b(a1(j158)) = a1(j158): c(158) = a1(j158) Else GoTo 1580
    a(158) = a1(j158)
   
    a(68) = p2 - a(158): If b(a(68)) = 0 Then b(a(68)) = a(68): c(68) = a(68) Else GoTo 680

    a(144) = 4 * s1 / 15 - a(158) - a(172) - a(186)
    If a(144) < a1(m1) Or a(144) > a1(m2) Then GoTo 1440:
    If b1(a(144)) = 0 Then GoTo 1440
    If b(a(144)) = 0 Then b(a(144)) = a(144): c(144) = a(144) Else GoTo 1440

    a(84) = p2 - a(144): If b(a(84)) = 0 Then b(a(84)) = a(84): c(84) = a(84) Else GoTo 840

    a(170) = 4 * s1 / 15 - a(186) - a(202) - a(218)
    If a(170) < a1(m1) Or a(170) > a1(m2) Then GoTo 1700:
    If b1(a(170)) = 0 Then GoTo 1700
    If b(a(170)) = 0 Then b(a(170)) = a(170): c(170) = a(170) Else GoTo 1700

    a(50) = p2 - a(170): If b(a(50)) = 0 Then b(a(50)) = a(50): c(50) = a(50) Else GoTo 500

    a(156) = 4 * s1 / 15 - a(172) - a(188) - a(204)
    If a(156) < a1(m1) Or a(156) > a1(m2) Then GoTo 1560:
    If b1(a(156)) = 0 Then GoTo 1560
    If b(a(156)) = 0 Then b(a(156)) = a(156): c(156) = a(156) Else GoTo 1560

    a(66) = p2 - a(156): If b(a(66)) = 0 Then b(a(66)) = a(66): c(66) = a(66) Else GoTo 660

    a(142) = 4 * s1 / 15 - a(158) - a(174) - a(190)
    If a(142) < a1(m1) Or a(142) > a1(m2) Then GoTo 1420:
    If b1(a(142)) = 0 Then GoTo 1420
    If b(a(142)) = 0 Then b(a(142)) = a(142): c(142) = a(142) Else GoTo 1420
    
    a(82) = p2 - a(142): If b(a(82)) = 0 Then b(a(82)) = a(82): c(82) = a(82) Else GoTo 820

    a(128) = 4 * s1 / 15 - a(142) - a(156) - a(170)
    If a(128) < a1(m1) Or a(128) > a1(m2) Then GoTo 1280:
    If b1(a(128)) = 0 Then GoTo 1280
    If b(a(128)) = 0 Then b(a(128)) = a(128): c(128) = a(128) Else GoTo 1280

    a(98) = p2 - a(128): If b(a(98)) = 0 Then b(a(98)) = a(98): c(98) = a(98) Else GoTo 980

    For j162 = m1 To m2
    If b(a1(j162)) = 0 Then b(a1(j162)) = a1(j162): c(162) = a1(j162) Else GoTo 1620
    a(162) = a1(j162)
   
    a(154) = p2 - a(162): If b(a(154)) = 0 Then b(a(154)) = a(154): c(154) = a(154) Else GoTo 1540

    For j148 = m1 To m2
    If b(a1(j148)) = 0 Then b(a1(j148)) = a1(j148): c(148) = a1(j148) Else GoTo 1480
    a(148) = a1(j148)
   
    a(138) = p2 - a(148): If b(a(138)) = 0 Then b(a(138)) = a(138): c(138) = a(138) Else GoTo 1380

    For j134 = m1 To m2
    If b(a1(j134)) = 0 Then b(a1(j134)) = a1(j134): c(134) = a1(j134) Else GoTo 1340
    a(134) = a1(j134)
   
    a(122) = p2 - a(134): If b(a(122)) = 0 Then b(a(122)) = a(122): c(122) = a(122) Else GoTo 1220

    a(120) = 4 * s1 / 15 - a(134) - a(148) - a(162)
    If a(120) < a1(m1) Or a(120) > a1(m2) Then GoTo 1200:
    If b1(a(120)) = 0 Then GoTo 1200
    If b(a(120)) = 0 Then b(a(120)) = a(120): c(120) = a(120) Else GoTo 1200

    a(106) = p2 - a(120): If b(a(106)) = 0 Then b(a(106)) = a(106): c(106) = a(106) Else GoTo 1060

    For j146 = m2 To m1 Step -1
    If b(a1(j146)) = 0 Then b(a1(j146)) = a1(j146): c(146) = a1(j146) Else GoTo 1460
    a(146) = a1(j146)
   
    a(140) = p2 - a(146): If b(a(140)) = 0 Then b(a(140)) = a(140): c(140) = a(140) Else GoTo 1400

    For j132 = m2 To m1 Step -1
    If b(a1(j132)) = 0 Then b(a1(j132)) = a1(j132): c(132) = a1(j132) Else GoTo 1320
    a(132) = a1(j132)
   
    a(124) = p2 - a(132): If b(a(124)) = 0 Then b(a(124)) = a(124): c(124) = a(124) Else GoTo 1240

    For j118 = m2 To m1 Step -1
    If b(a1(j118)) = 0 Then b(a1(j118)) = a1(j118): c(118) = a1(j118) Else GoTo 1180
    a(118) = a1(j118)
   
    a(108) = p2 - a(118): If b(a(108)) = 0 Then b(a(108)) = a(108): c(108) = a(108) Else GoTo 1080

    a(104) = 4 * s1 / 15 - a(118) - a(132) - a(146)
    If a(104) < a1(m1) Or a(104) > a1(m2) Then GoTo 1040:
    If b1(a(104)) = 0 Then GoTo 1040
    If b(a(104)) = 0 Then b(a(104)) = a(104): c(104) = a(104) Else GoTo 1040

    a(92) = p2 - a(104): If b(a(92)) = 0 Then b(a(92)) = a(92): c(92) = a(92) Else GoTo 920

    For j130 = m2 To m1 Step -1
    If b(a1(j130)) = 0 Then b(a1(j130)) = a1(j130): c(130) = a1(j130) Else GoTo 1300
    a(130) = a1(j130)
   
    a(126) = p2 - a(130): If b(a(126)) = 0 Then b(a(126)) = a(126): c(126) = a(126) Else GoTo 1260

    For j116 = m1 To m2
    If b(a1(j116)) = 0 Then b(a1(j116)) = a1(j116): c(116) = a1(j116) Else GoTo 1160
    a(116) = a1(j116)
   
    a(110) = p2 - a(116): If b(a(110)) = 0 Then b(a(110)) = a(110): c(110) = a(110) Else GoTo 1100

    For j102 = m1 To m2
    If b(a1(j102)) = 0 Then b(a1(j102)) = a1(j102): c(102) = a1(j102) Else GoTo 1020
    a(102) = a1(j102)
   
    a(94) = p2 - a(102): If b(a(94)) = 0 Then b(a(94)) = a(94): c(94) = a(94) Else GoTo 940
    
    a(88) = 4 * s1 / 15 - a(102) - a(116) - a(130)
    If a(88) < a1(m1) Or a(88) > a1(m2) Then GoTo 880:
    If b1(a(88)) = 0 Then GoTo 880
    If b(a(88)) = 0 Then b(a(88)) = a(88): c(88) = a(88) Else GoTo 880

    a(78) = p2 - a(88): If b(a(78)) = 0 Then b(a(78)) = a(78): c(78) = a(78) Else GoTo 780

    a(114) = 4 * s1 / 15 - a(130) - a(146) - a(162)
    If a(114) < a1(m1) Or a(114) > a1(m2) Then GoTo 1140:
    If b1(a(114)) = 0 Then GoTo 1140
    If b(a(114)) = 0 Then b(a(114)) = a(114): c(114) = a(114) Else GoTo 1140

    a(112) = p2 - a(114): If b(a(112)) = 0 Then b(a(112)) = a(112): c(112) = a(112) Else GoTo 1120

    a(100) = 4 * s1 / 15 - a(116) - a(132) - a(148)
    If a(100) < a1(m1) Or a(100) > a1(m2) Then GoTo 1000:
    If b1(a(100)) = 0 Then GoTo 1000
    If b(a(100)) = 0 Then b(a(100)) = a(100): c(100) = a(100) Else GoTo 1000

    a(96) = p2 - a(100): If b(a(96)) = 0 Then b(a(96)) = a(96): c(96) = a(96) Else GoTo 960

    a(86) = 4 * s1 / 15 - a(102) - a(118) - a(134)
    If a(86) < a1(m1) Or a(86) > a1(m2) Then GoTo 860:
    If b1(a(86)) = 0 Then GoTo 860
    If b(a(86)) = 0 Then b(a(86)) = a(86): c(86) = a(86) Else GoTo 860

    a(80) = p2 - a(86): If b(a(80)) = 0 Then b(a(80)) = a(80): c(80) = a(80) Else GoTo 800

    a(72) = 4 * s1 / 15 - a(88) - a(104) - a(120)
    If a(72) < a1(m1) Or a(72) > a1(m2) Then GoTo 720:
    If b1(a(72)) = 0 Then GoTo 720
    If b(a(72)) = 0 Then b(a(72)) = a(72): c(72) = a(72) Else GoTo 720

    a(64) = p2 - a(72): If b(a(64)) = 0 Then b(a(64)) = a(64): c(64) = a(64) Else GoTo 640

    a(129) = -12*s1/15 +0.5*a(72)+0.5*a(86)+a(100)-0.5*a(88)-0.5*a(102)-0.5*a(130)+0.5*a(104)+0.5*a(118)+a(132)+0.5*a(146) + 
                       +0.5*a(148)-0.5*a(128)+1.5*a(142)+0.5 *a(170)+1.5*a(158)+0.5*a(186)+1.5*a(174)+0.5*a(202)+0.5*a(176) + 
                       +2*a(190)+0.5 *a(204)+a(218)

    If a(129) < a1(m1) Or a(129) > a1(m2) Or CInt(a(129)) <> a(129) Then GoTo 1290:
    If b1(a(129)) = 0 Then GoTo 1290
    If b(a(129)) = 0 Then b(a(129)) = a(129): c(129) = a(129) Else GoTo 1290

    a(97) = p2 - a(129): If b(a(97)) = 0 Then b(a(97)) = a(97): c(97) = a(97) Else GoTo 970

    a(127) = - 9*s1/15-.5*a(72)-.5*a(86)-.5*a(88)-.5*a(102)-.5*a(130)+.5*a(104)+.5*a(118)+a(132)+.5*a(146)+.5*a(148) +
                      +.5*a(128)+.5*a(142)+.5*a(170)+a(144)+.5*a(158)+.5*a(186)+a(160)+.5*a(174)+.5*a(202)+1.5*a(176) + 
                      +   a(190)+.5*a(204)+a(218)

    If a(127) < a1(m1) Or a(127) > a1(m2) Or CInt(a(127)) <> a(127) Then GoTo 1270:
    If b1(a(127)) = 0 Then GoTo 1270
    If b(a(127)) = 0 Then b(a(127)) = a(127): c(127) = a(127) Else GoTo 1270

    a(99) = p2 - a(127): If b(a(99)) = 0 Then b(a(99)) = a(99): c(99) = a(99) Else GoTo 990

    For j161 = m1 To m2
    If b(a1(j161)) = 0 Then b(a1(j161)) = a1(j161): c(161) = a1(j161) Else GoTo 1610
    a(161) = a1(j161)
   
    a(65) = p2 - a(161): If b(a(65)) = 0 Then b(a(65)) = a(65): c(65) = a(65) Else GoTo 650

    For j159 = m1 To m2
    If b(a1(j159)) = 0 Then b(a1(j159)) = a1(j159): c(159) = a1(j159) Else GoTo 1590
    a(159) = a1(j159)
   
    a(69) = p2 - a(159): If b(a(69)) = 0 Then b(a(69)) = a(69): c(69) = a(69) Else GoTo 690

    For j157 = m1 To m2
    If b(a1(j157)) = 0 Then b(a1(j157)) = a1(j157): c(157) = a1(j157) Else GoTo 1570
    a(157) = a1(j157)
   
    a(67) = p2 - a(157): If b(a(67)) = 0 Then b(a(67)) = a(67): c(67) = a(67) Else GoTo 670

    a(155) = 3*s1/15-a(157)-a(159)-a(161)-a(86)-a(102)-a(118)-a(134)-a(158)+a(172)+a(174)+2*a(188)+a(202)+a(204)
    If a(155) < a1(m1) Or a(155) > a1(m2) Or CInt(a(155)) <> a(155) Then GoTo 1550:
    If b1(a(155)) = 0 Then GoTo 1550
    If b(a(155)) = 0 Then b(a(155)) = a(155): c(155) = a(155) Else GoTo 1550

    a(71) = p2 - a(155): If b(a(71)) = 0 Then b(a(71)) = a(71): c(71) = a(71) Else GoTo 710

    For j147 = m1 To m2
    If b(a1(j147)) = 0 Then b(a1(j147)) = a1(j147): c(147) = a1(j147) Else GoTo 1470
    a(147) = a1(j147)
   
    a(139) = p2 - a(147): If b(a(139)) = 0 Then b(a(139)) = a(139): c(139) = a(139) Else GoTo 1390

    For j145 = m2 To m1 Step -1
    If b(a1(j145)) = 0 Then b(a1(j145)) = a1(j145): c(145) = a1(j145) Else GoTo 1450
    a(145) = a1(j145)
   
    a(81) = p2 - a(145): If b(a(81)) = 0 Then b(a(81)) = a(81): c(81) = a(81) Else GoTo 810

    For j143 = m2 To m1 Step -1
    If b(a1(j143)) = 0 Then b(a1(j143)) = a1(j143): c(143) = a1(j143) Else GoTo 1430
    a(143) = a1(j143)
   
    a(83) = p2 - a(143): If b(a(83)) = 0 Then b(a(83)) = a(83): c(83) = a(83) Else GoTo 830

    a(141) = s1/15-a(143)-a(145)-a(100)-a(116)-a(132)-a(148)+2*a(158)+a(172)+a(186)+a(174)+a(190)
    If a(141) < a1(m1) Or a(141) > a1(m2) Or CInt(a(141)) <> a(141) Then GoTo 1410:
    If b1(a(141)) = 0 Then GoTo 1410
    If b(a(141)) = 0 Then b(a(141)) = a(141): c(141) = a(141) Else GoTo 1410

    a(85) = p2 - a(141): If b(a(85)) = 0 Then b(a(85)) = a(85): c(85) = a(85) Else GoTo 850

    a(115) =   4*s1/15-a(143)-2*a(145)+a(86)-2*a(100)+a(102)-a(116)-a(130)+a(118)-a(132)+a(134)-a(148)+2*a(158)+a(172) +
                      +a(186)-a(160)-a(188)-a(202)+a(190)

    If a(115) < a1(m1) Or a(115) > a1(m2) Then GoTo 1150:
    If b1(a(115)) = 0 Then GoTo 1150
    If b(a(115)) = 0 Then b(a(115)) = a(115): c(115) = a(115) Else GoTo 1150

    a(111) = p2 - a(115): If b(a(111)) = 0 Then b(a(111)) = a(111): c(111) = a(111) Else GoTo 1110

    For j131 = m2 To m1 Step -1
    If b(a1(j131)) = 0 Then b(a1(j131)) = a1(j131): c(131) = a1(j131) Else GoTo 1310
    a(131) = a1(j131)
   
    a(125) = p2 - a(131): If b(a(125)) = 0 Then b(a(125)) = a(125): c(125) = a(125) Else GoTo 1250
  
    a(101) =   8*s1/15-a(131)-a(157)-a(159)-2*a(161)+a(72)-2*a(86)+a(88)-a(102)-a(116)+a(104)-a(118)-a(146)+a(120) +
                      -a(134)-a(158)+a(172)+a(174)+2*a(188)+a(202)-a(176)-a(190)-a(218)

    If a(101) < a1(m1) Or a(101) > a1(m2) Then GoTo 1010:
    If b1(a(101)) = 0 Then GoTo 1010
    If b(a(101)) = 0 Then b(a(101)) = a(101): c(101) = a(101) Else GoTo 1760

    a(95) = p2 - a(101): If b(a(95)) = 0 Then b(a(95)) = a(95): c(95) = a(95) Else GoTo 950

    For j117 = m1 To m2
    If b(a1(j117)) = 0 Then b(a1(j117)) = a1(j117): c(117) = a1(j117) Else GoTo 1170
    a(117) = a1(j117)
   
    a(109) = p2 - a(117): If b(a(109)) = 0 Then b(a(109)) = a(109): c(109) = a(109) Else GoTo 1090

    For j175 = m1 To m2
    If b(a1(j175)) = 0 Then b(a1(j175)) = a1(j175): c(175) = a1(j175) Else GoTo 1750
    a(175) = a1(j175)
   
    a(55) = p2 - a(175): If b(a(55)) = 0 Then b(a(55)) = a(55): c(55) = a(55) Else GoTo 550

    For j173 = m2 To m1 Step -1
    If b(a1(j173)) = 0 Then b(a1(j173)) = a1(j173): c(173) = a1(j173) Else GoTo 1730
    a(173) = a1(j173)
   
    a(53) = p2 - a(173): If b(a(53)) = 0 Then b(a(53)) = a(53): c(53) = a(53) Else GoTo 530

    For j171 = m2 To m1 Step -1
    If b(a1(j171)) = 0 Then b(a1(j171)) = a1(j171): c(171) = a1(j171) Else GoTo 1710
    a(171) = a1(j171)
   
    a(51) = p2 - a(171): If b(a(51)) = 0 Then b(a(51)) = a(51): c(51) = a(51) Else GoTo 510

For j177 = 2 To 224 Step 2  'Border 9 x 9 (even)
a(177) = j177

a(49) = p2 - a(177)

a(169) = 9 * s1 / 15 - a(170) - a(171) - a(172) - a(173) - a(174) - a(175) - a(176) - a(177)
If a(169) < 2 Or a(169) > 224 Then GoTo 1770
If a(169) = a(49) Or a(169) = a(177) Then GoTo 1770

a(57) = p2 - a(169)        'even

    a(87) =  12*s1/15-a(117)-a(147)-a(171)-a(173)-a(175)-2*a(177)-2*a(72)-a(88)-a(102)-a(104)-a(132)-a(120)-a(162) +
                     -a(172)+a(186)-a(174)+a(202)+a(190)+a(204)+2*a(218)
 
    If a(87) < a1(m1) Or a(87) > a1(m2) Then GoTo 870:
    If b1(a(87)) = 0 Then GoTo 870
    If b(a(87)) = 0 Then b(a(87)) = a(87): c(87) = a(87) Else GoTo 870

    a(79) = p2 - a(87): If b(a(79)) = 0 Then b(a(79)) = a(79): c(79) = a(79) Else GoTo 790

'   Complete Diamond with independent pairs

    For j203 = m2 To m1 Step -1
    If b(a1(j203)) = 0 Then b(a1(j203)) = a1(j203): c(203) = a1(j203) Else GoTo 2030
    a(203) = a1(j203)
   
    a(23) = p2 - a(203): If b(a(23)) = 0 Then b(a(23)) = a(23): c(23) = a(23) Else GoTo 230

    For j189 = m2 To m1 Step -1
    If b(a1(j189)) = 0 Then b(a1(j189)) = a1(j189): c(189) = a1(j189) Else GoTo 1890
    a(189) = a1(j189)
   
    a(39) = p2 - a(189): If b(a(39)) = 0 Then b(a(39)) = a(39): c(39) = a(39) Else GoTo 390

    For j187 = m1 To m2
    If b(a1(j187)) = 0 Then b(a1(j187)) = a1(j187): c(187) = a1(j187) Else GoTo 1870
    a(187) = a1(j187)
   
    a(37) = p2 - a(187): If b(a(37)) = 0 Then b(a(37)) = a(37): c(37) = a(37) Else GoTo 370

    For j133 = m1 To m2
    If b(a1(j133)) = 0 Then b(a1(j133)) = a1(j133): c(133) = a1(j133) Else GoTo 1330
    a(133) = a1(j133)
   
    a(123) = p2 - a(133): If b(a(123)) = 0 Then b(a(123)) = a(123): c(123) = a(123) Else GoTo 1230

    For j119 = m1 To m2
    If b(a1(j119)) = 0 Then b(a1(j119)) = a1(j119): c(119) = a1(j119) Else GoTo 1190
    a(119) = a1(j119)
   
    a(107) = p2 - a(119): If b(a(107)) = 0 Then b(a(107)) = a(107): c(107) = a(107) Else GoTo 1070

    For j103 = m1 To m2
    If b(a1(j103)) = 0 Then b(a1(j103)) = a1(j103): c(103) = a1(j103) Else GoTo 1030
    a(103) = a1(j103)
   
    a(93) = p2 - a(103): If b(a(93)) = 0 Then b(a(93)) = a(93): c(93) = a(93) Else GoTo 930

'                               Exclude solutions with identical numbers

                                GoSub 1800: If fl1 = 0 Then GoTo 5
    
                                n9 = n9 + 1
                                GoSub 2650              'Print results (squares)
 '                              GoSub 2645              'Print results (selected numbers)
                                End                     'First Square
5
     
     b(c(93)) = 0: c(93) = 0
930  b(c(103)) = 0: c(103) = 0
1030 Next j103

     b(c(107)) = 0: c(107) = 0
1070 b(c(119)) = 0: c(119) = 0
1190 Next j119

     b(c(123)) = 0: c(123) = 0
1230 b(c(133)) = 0: c(133) = 0
1330 Next j133
     
     b(c(37)) = 0: c(37) = 0
370  b(c(187)) = 0: c(187) = 0
1870 Next j187

     b(c(39)) = 0: c(39) = 0
390  b(c(189)) = 0: c(189) = 0
1890 Next j189

     b(c(23)) = 0: c(23) = 0
230  b(c(203)) = 0: c(203) = 0
2030 Next j203
     
     b(c(79)) = 0: c(79) = 0
790  b(c(87)) = 0: c(87) = 0
870

1770 Next j177

     b(c(51)) = 0: c(51) = 0
510  b(c(171)) = 0: c(171) = 0
1710 Next j171

     b(c(53)) = 0: c(53) = 0
530  b(c(173)) = 0: c(173) = 0
1730 Next j173

     b(c(55)) = 0: c(55) = 0
550  b(c(175)) = 0: c(175) = 0
1750 Next j175

     b(c(109)) = 0: c(109) = 0
1090 b(c(117)) = 0: c(117) = 0
1170 Next j117

     b(c(95)) = 0: c(95) = 0
950  b(c(101)) = 0: c(101) = 0
1010 b(c(125)) = 0: c(125) = 0
1250 b(c(131)) = 0: c(131) = 0
1310 Next j131

     b(c(111)) = 0: c(111) = 0
1110 b(c(115)) = 0: c(115) = 0
1150 b(c(85)) = 0: c(85) = 0
850  b(c(141)) = 0: c(141) = 0
1410 b(c(83)) = 0: c(83) = 0
830  b(c(143)) = 0: c(143) = 0
1430 Next j143

     b(c(81)) = 0: c(81) = 0
810 b(c(145)) = 0: c(145) = 0
1450 Next j145

     b(c(139)) = 0: c(139) = 0
1390 b(c(147)) = 0: c(147) = 0
1470 Next j147

     b(c(71)) = 0: c(71) = 0
710  b(c(155)) = 0: c(155) = 0
1550 b(c(67)) = 0: c(67) = 0
670  b(c(157)) = 0: c(157) = 0
1570 Next j157

     b(c(69)) = 0: c(69) = 0
690  b(c(159)) = 0: c(159) = 0
1590 Next j159

     b(c(65)) = 0: c(65) = 0
650  b(c(161)) = 0: c(161) = 0
1610 Next j161

     b(c(99)) = 0: c(99) = 0
990  b(c(127)) = 0: c(127) = 0
1270 b(c(97)) = 0: c(97) = 0
970  b(c(129)) = 0: c(129) = 0
1290 b(c(64)) = 0: c(64) = 0
640  b(c(72)) = 0: c(72) = 0
720  b(c(80)) = 0: c(80) = 0
800  b(c(86)) = 0: c(86) = 0
860  b(c(96)) = 0: c(96) = 0
960  b(c(100)) = 0: c(100) = 0
1000 b(c(112)) = 0: c(112) = 0
1120 b(c(114)) = 0: c(114) = 0
1140 b(c(78)) = 0: c(78) = 0
780  b(c(88)) = 0: c(88) = 0
880  b(c(94)) = 0: c(94) = 0
940  b(c(102)) = 0: c(102) = 0
1020 Next j102

     b(c(110)) = 0: c(110) = 0
1100 b(c(116)) = 0: c(116) = 0
1160 Next j116

     b(c(126)) = 0: c(126) = 0
1260 b(c(130)) = 0: c(130) = 0
1300 Next j130

      b(c(92)) = 0: c(92) = 0
920  b(c(104)) = 0: c(104) = 0
1040 b(c(108)) = 0: c(108) = 0
1080 b(c(118)) = 0: c(118) = 0
1180 Next j118

     b(c(124)) = 0: c(124) = 0
1240 b(c(132)) = 0: c(132) = 0
1320 Next j132

     b(c(140)) = 0: c(140) = 0
1400 b(c(146)) = 0: c(146) = 0
1460 Next j146

     b(c(106)) = 0: c(106) = 0
1060 b(c(120)) = 0: c(120) = 0
1200 b(c(122)) = 0: c(122) = 0
1220 b(c(134)) = 0: c(134) = 0
1340 Next j134

     b(c(138)) = 0: c(138) = 0
1380 b(c(148)) = 0: c(148) = 0
1480 Next j148

     b(c(154)) = 0: c(154) = 0
1540  b(c(162)) = 0: c(162) = 0
1620 Next j162

     b(c(98)) = 0: c(98) = 0
980  b(c(128)) = 0: c(128) = 0
1280 b(c(82)) = 0: c(82) = 0
820  b(c(142)) = 0: c(142) = 0
1420 b(c(66)) = 0: c(66) = 0
660  b(c(156)) = 0: c(156) = 0
1560 b(c(50)) = 0: c(50) = 0
500  b(c(170)) = 0: c(170) = 0
1700 b(c(84)) = 0: c(84) = 0
840  b(c(144)) = 0: c(144) = 0
1440 b(c(68)) = 0: c(68) = 0
680  b(c(158)) = 0: c(158) = 0
1580 Next j158

     b(c(52)) = 0: c(52) = 0
520  b(c(172)) = 0: c(172) = 0
1720 Next j172

     b(c(36)) = 0: c(36) = 0
360  b(c(186)) = 0: c(186) = 0
1860 Next j186

     b(c(70)) = 0: c(70) = 0
700  b(c(160)) = 0: c(160) = 0
1600 b(c(54)) = 0: c(54) = 0
540  b(c(174)) = 0: c(174) = 0
1740 Next j174
     
     b(c(38)) = 0: c(38) = 0
380  b(c(188)) = 0: c(188) = 0
1880 Next j188

     b(c(22)) = 0: c(22) = 0
220  b(c(202)) = 0: c(202) = 0
2020 Next j202

     b(c(56)) = 0: c(56) = 0
560  b(c(176)) = 0: c(176) = 0
1760 b(c(40)) = 0: c(40) = 0
400  b(c(190)) = 0: c(190) = 0
1900 Next j190

     b(c(24)) = 0: c(24) = 0
240  b(c(204)) = 0: c(204) = 0
2040 Next j204

     b(c(8)) = 0: c(8) = 0
80   b(c(218)) = 0: c(218) = 0
2180 Next j218
    
    t2 = Timer
    
    t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions"
    y = MsgBox(t10, 0, "Routine Diamond8")

End

'    Double Check Identical Numbers a()

1800 fl1 = 1
     For i1 = 1 To 225
        a20 = a(i1): If a20 = 0 Then GoTo 1810
        For i2 = (1 + i1) To 225
            If a20 = a(i2) Then fl1 = 0: Return
        Next i2
1810 Next i1
     Return

'   Print results (selected numbers)

2645 For i1 = 1 To 225
         Cells(n9, i1).Value = a(i1)
     Next i1
     Cells(n9, 226).Value = n9
     Return

'    Print results (squares)

2650 n2 = n2 + 1
     If n2 = 3 Then
         n2 = 1: k1 = k1 + 16: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 16
     End If

     Cells(k1, k2 + 1).Select
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
   
     i3 = 0
     For i1 = 1 To 15
         For i2 = 1 To 15
         i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1

     Return
     
End Sub


Vorige Pagina About the Author