Vorige Pagina About the Author

' Generates Order 8 Medjig - and Order 16 Bimagic Squares

' Tested with Office 365 under Windows 10

Sub MgcSqr16a()

Dim a(256), b(256), c(256), s(128)

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

n2 = 0: n9 = 0: k1 = 1: k2 = 1
m1 = 1: m2 = 4: s1 = 40: s2 = 120: s3 = 1260: p1 = s1 / 8
s16a = 2056: s16b = 351576

'   Read b() (Test Run)

''i3 = 0
''For i1 = 22 To 37
''For i2 = 2 To 17
        
''        i3 = i3 + 1
''        b(i3) = Sheets("Composite16").Cells(i1, i2).Value

''Next i2
''Next i1

    ShtNm1 = "Complete8"    'Order 8 Bimagic Squares, Pan Magic, Complete
''  ShtNm1 = "Att17641"     'Order 8 Bimagic Squares, Four Way V-ZigZag 

'   Generate Bi,agic Squares
    
    Sheets("Klad1").Select
    
    t1 = Timer

For j100 = 2 To 10497
Cells(1, 1).Value = j100

n16 = Sheets(ShtNm1).Cells(j100, 66).Value
If n16 = 0 Then GoTo 1000                   'Deactivate for Inventarisation step 1
  
i1 = -1: i2 = 0
For i0 = 1 To 64

    x = Sheets(ShtNm1).Cells(j100, i0).Value - 1
    
    i1 = i1 + 2: i3 = i2 * 16 + i1
    If i1 = 15 Then i2 = i2 + 2: i1 = -1

    b(i3) = x: b(i3 + 1) = x
    b(i3 + 16) = x: b(i3 + 17) = x
    
Next i0

n10 = 0: n11 = 0: n12 = 0

For j256 = m1 To m2                                                 'a(256)
a(256) = j256
For j255 = m1 To m2                                                 'a(255)
a(255) = j255
If a(255) = a(256) Then GoTo 2550

For j254 = m1 To m2                                                 'a(254)
a(254) = j254
For j253 = m1 To m2                                                 'a(253)
a(253) = j253
If a(253) = a(254) Then GoTo 2530

For j252 = m1 To m2                                                 'a(252)
a(252) = j252

a(251) = s1 / 4 - a(252) - a(253) - a(254): If a(251) < m1 Or a(251) > m2 Then GoTo 2520:
If a(251) = a(252) Then GoTo 2520

For j250 = m1 To m2                                               'a(250)
a(250) = j250

a(249) = s1 / 4 - a(250) - a(255) - a(256): If a(249) < m1 Or a(249) > m2 Then GoTo 2500:
If a(249) = a(250) Then GoTo 2500

For j248 = m1 To m2                                                 'a(248)
a(248) = j248
For j247 = m1 To m2                                                 'a(247)
a(247) = j247
If a(247) = a(248) Then GoTo 2470

For j246 = m1 To m2                                                 'a(246)
a(246) = j246
For j245 = m1 To m2                                                 'a(245)
a(245) = j245
If a(245) = a(246) Then GoTo 2450

For j244 = m1 To m2                                                 'a(244)
a(244) = j244

a(243) = s1 / 4 - a(244) - a(245) - a(246): If a(243) < m1 Or a(243) > m2 Then GoTo 2440:
If a(243) = a(244) Then GoTo 2440
a(242) = -a(244) - a(246) - a(248) + a(250) + a(252) + a(254) + a(256):
If a(242) < m1 Or a(242) > m2 Then GoTo 2440:
a(241) = s1 / 4 + a(244) + a(246) - a(247) - a(250) - a(252) - a(254) - a(256):
If a(241) < m1 Or a(241) > m2 Then GoTo 2440:
If a(241) = a(242) Then GoTo 2440

m11 = 241: m21 = 256: GoSub 2700: If fl1 = 0 Then GoTo 2440       'Check row 1

For j240 = m1 To m2                                               'a(240)
a(240) = j240
If a(240) = a(255) Or a(240) = a(256) Then GoTo 2400

a(239) = s1 / 4 - a(240) - a(255) - a(256):                              If a(239) < m1 Or a(239) > m2 Then GoTo 2400:
If a(239) = a(240) Or a(239) = a(255) Or a(239) = a(256) Then GoTo 2400
a(238) = a(240) - a(254) + a(256):                                       If a(238) < m1 Or a(238) > m2 Then GoTo 2400:
If a(238) = a(253) Or a(238) = a(254) Then GoTo 2400
a(237) = s1 / 4 - a(240) - a(253) - a(256):                              If a(237) < m1 Or a(237) > m2 Then GoTo 2400:
If a(237) = a(238) Or a(237) = a(253) Or a(237) = a(254) Then GoTo 2400
a(236) = a(240) - a(252) + a(256):                                       If a(236) < m1 Or a(236) > m2 Then GoTo 2400:
If a(236) = a(251) Or a(236) = a(252) Then GoTo 2400
a(235) = -a(240) + a(252) + a(253) + a(254) - a(256):                    If a(235) < m1 Or a(235) > m2 Then GoTo 2400:
If a(235) = a(236) Or a(235) = a(251) Or a(235) = a(252) Then GoTo 2400
a(234) = a(240) - a(250) + a(256):                                       If a(234) < m1 Or a(234) > m2 Then GoTo 2400:
If a(234) = a(249) Or a(234) = a(250) Then GoTo 2400
a(233) = -a(240) + a(250) + a(255):                                      If a(233) < m1 Or a(233) > m2 Then GoTo 2400:
If a(233) = a(234) Or a(233) = a(249) Or a(233) = a(250) Then GoTo 2400
a(232) = a(240) - a(248) + a(256):                                       If a(232) < m1 Or a(232) > m2 Then GoTo 2400:
If a(232) = a(247) Or a(232) = a(248) Then GoTo 2400
a(231) = s1 / 4 - a(240) - a(247) - a(256):                              If a(231) < m1 Or a(231) > m2 Then GoTo 2400:
If a(231) = a(232) Or a(231) = a(247) Or a(231) = a(248) Then GoTo 2400
a(230) = a(240) - a(246) + a(256):                                       If a(230) < m1 Or a(230) > m2 Then GoTo 2400:
If a(230) = a(245) Or a(230) = a(246) Then GoTo 2400
a(229) = s1 / 4 - a(240) - a(245) - a(256):                              If a(229) < m1 Or a(229) > m2 Then GoTo 2400:
If a(229) = a(230) Or a(229) = a(245) Or a(229) = a(246) Then GoTo 2400
a(228) = a(240) - a(244) + a(256):                                       If a(228) < m1 Or a(228) > m2 Then GoTo 2400:
If a(228) = a(243) Or a(228) = a(244) Then GoTo 2400
a(227) = -a(240) + a(244) + a(245) + a(246) - a(256):                    If a(227) < m1 Or a(227) > m2 Then GoTo 2400:
If a(227) = a(228) Or a(227) = a(243) Or a(227) = a(244) Then GoTo 2400
a(226) = a(240) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254):   If a(226) < m1 Or a(226) > m2 Then GoTo 2400:
If a(226) = a(241) Or a(226) = a(242) Then GoTo 2400
a(225) = -a(240) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254):  If a(225) < m1 Or a(225) > m2 Then GoTo 2400:
If a(225) = a(226) Or a(225) = a(241) Or a(225) = a(242) Then GoTo 2400

m11 = 225: m21 = 240: GoSub 2700: If fl1 = 0 Then GoTo 2400              'Check row 2

For j224 = m1 To m2                                                      'a(224)
a(224) = j224

a(223) = -a(224) + a(255) + a(256):                                      If a(223) < m1 Or a(223) > m2 Then GoTo 2240:
If a(223) = a(224) Then GoTo 2240
a(222) = a(224) + a(254) - a(256):                                       If a(222) < m1 Or a(222) > m2 Then GoTo 2240:
a(221) = -a(224) + a(253) + a(256):                                      If a(221) < m1 Or a(221) > m2 Then GoTo 2240:
If a(221) = a(222) Then GoTo 2240
a(220) = a(224) + a(252) - a(256):                                       If a(220) < m1 Or a(220) > m2 Then GoTo 2240:
a(219) = s1 / 4 - a(224) - a(252) - a(253) - a(254) + a(256):            If a(219) < m1 Or a(219) > m2 Then GoTo 2240:
If a(219) = a(220) Then GoTo 2240
a(218) = a(224) + a(250) - a(256):                                       If a(218) < m1 Or a(218) > m2 Then GoTo 2240:
a(217) = s1 / 4 - a(224) - a(250) - a(255):                              If a(217) < m1 Or a(217) > m2 Then GoTo 2240:
If a(217) = a(218) Then GoTo 2240
a(216) = a(224) + a(248) - a(256):                                       If a(216) < m1 Or a(216) > m2 Then GoTo 2240:
a(215) = -a(224) + a(247) + a(256):                                      If a(215) < m1 Or a(215) > m2 Then GoTo 2240:
If a(215) = a(216) Then GoTo 2240
a(214) = a(224) + a(246) - a(256):                                       If a(214) < m1 Or a(214) > m2 Then GoTo 2240:
a(213) = -a(224) + a(245) + a(256):                                      If a(213) < m1 Or a(213) > m2 Then GoTo 2240:
If a(213) = a(214) Then GoTo 2240
a(212) = a(224) + a(244) - a(256):                                       If a(212) < m1 Or a(212) > m2 Then GoTo 2240:
a(211) = s1 / 4 - a(224) - a(244) - a(245) - a(246) + a(256):            If a(211) < m1 Or a(211) > m2 Then GoTo 2240:
If a(211) = a(212) Then GoTo 2240
a(210) = a(224) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254):   If a(210) < m1 Or a(210) > m2 Then GoTo 2240:
a(209) = s1 / 4 - a(224) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254):
If a(209) < m1 Or a(209) > m2 Then GoTo 2240:
If a(209) = a(210) Then GoTo 2240

m11 = 209: m21 = 224: GoSub 2700: If fl1 = 0 Then GoTo 2240             'Check row 3

For j208 = m1 To m2                                                     'a(208)
a(208) = j208
If a(208) = a(223) Or a(208) = a(224) Then GoTo 2080

a(207) = s1 / 4 - a(208) - a(255) - a(256):                             If a(207) < m1 Or a(207) > m2 Then GoTo 2080:
If a(207) = a(208) Or a(207) = a(223) Or a(207) = a(224) Then GoTo 2080
a(206) = a(208) - a(254) + a(256):                                      If a(206) < m1 Or a(206) > m2 Then GoTo 2080:
If a(206) = a(221) Or a(206) = a(222) Then GoTo 2080
a(205) = s1 / 4 - a(208) - a(253) - a(256):                             If a(205) < m1 Or a(205) > m2 Then GoTo 2080:
If a(205) = a(206) Or a(205) = a(221) Or a(205) = a(222) Then GoTo 2080
a(204) = a(208) - a(252) + a(256):                                      If a(204) < m1 Or a(204) > m2 Then GoTo 2080:
If a(204) = a(219) Or a(204) = a(220) Then GoTo 2080
a(203) = -a(208) + a(252) + a(253) + a(254) - a(256):                   If a(203) < m1 Or a(203) > m2 Then GoTo 2080:
If a(203) = a(204) Or a(203) = a(219) Or a(203) = a(220) Then GoTo 2080
a(202) = a(208) - a(250) + a(256):                                      If a(202) < m1 Or a(202) > m2 Then GoTo 2080:
If a(202) = a(217) Or a(202) = a(218) Then GoTo 2080
a(201) = -a(208) + a(250) + a(255):                                     If a(201) < m1 Or a(201) > m2 Then GoTo 2080:
If a(201) = a(202) Or a(201) = a(217) Or a(201) = a(218) Then GoTo 2080
a(200) = a(208) - a(248) + a(256):                                      If a(200) < m1 Or a(200) > m2 Then GoTo 2080:
If a(200) = a(215) Or a(200) = a(216) Then GoTo 2080
a(199) = s1 / 4 - a(208) - a(247) - a(256):                             If a(199) < m1 Or a(199) > m2 Then GoTo 2080:
If a(199) = a(200) Or a(199) = a(215) Or a(199) = a(216) Then GoTo 2080
a(198) = a(208) - a(246) + a(256):                                      If a(198) < m1 Or a(198) > m2 Then GoTo 2080:
If a(198) = a(213) Or a(198) = a(214) Then GoTo 2080
a(197) = s1 / 4 - a(208) - a(245) - a(256):                             If a(197) < m1 Or a(197) > m2 Then GoTo 2080:
If a(197) = a(198) Or a(197) = a(213) Or a(197) = a(214) Then GoTo 2080
a(196) = a(208) - a(244) + a(256):                                      If a(196) < m1 Or a(196) > m2 Then GoTo 2080:
If a(196) = a(211) Or a(196) = a(212) Then GoTo 2080
a(195) = -a(208) + a(244) + a(245) + a(246) - a(256):                   If a(195) < m1 Or a(195) > m2 Then GoTo 2080:
If a(195) = a(196) Or a(195) = a(211) Or a(195) = a(212) Then GoTo 2080
a(194) = a(208) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254):  If a(194) < m1 Or a(194) > m2 Then GoTo 2080:
If a(194) = a(209) Or a(194) = a(210) Then GoTo 2080
a(193) = -a(208) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254): If a(193) < m1 Or a(193) > m2 Then GoTo 2080:
If a(193) = a(194) Or a(193) = a(209) Or a(193) = a(210) Then GoTo 2080

m11 = 193: m21 = 208: GoSub 2700: If fl1 = 0 Then GoTo 2080             'Check row 4

For j192 = m1 To m2                                                     'a(192)
a(192) = j192

a(191) = -a(192) + a(255) + a(256):                                     If a(191) < m1 Or a(191) > m2 Then GoTo 1920:
If a(191) = a(192) Then GoTo 1920
a(190) = a(192) + a(254) - a(256):                                      If a(190) < m1 Or a(190) > m2 Then GoTo 1920:
a(189) = -a(192) + a(253) + a(256):                                     If a(189) < m1 Or a(189) > m2 Then GoTo 1920:
If a(189) = a(190) Then GoTo 1920
a(188) = a(192) + a(252) - a(256):                                      If a(188) < m1 Or a(188) > m2 Then GoTo 1920:
a(187) = s1 / 4 - a(192) - a(252) - a(253) - a(254) + a(256):           If a(187) < m1 Or a(187) > m2 Then GoTo 1920:
If a(187) = a(188) Then GoTo 1920
a(186) = a(192) + a(250) - a(256):                                      If a(186) < m1 Or a(186) > m2 Then GoTo 1920:
a(185) = s1 / 4 - a(192) - a(250) - a(255):                             If a(185) < m1 Or a(185) > m2 Then GoTo 1920:
If a(185) = a(186) Then GoTo 1920
a(184) = a(192) + a(248) - a(256):                                      If a(184) < m1 Or a(184) > m2 Then GoTo 1920:
a(183) = -a(192) + a(247) + a(256):                                     If a(183) < m1 Or a(183) > m2 Then GoTo 1920:
If a(183) = a(184) Then GoTo 1920
a(182) = a(192) + a(246) - a(256):                                      If a(182) < m1 Or a(182) > m2 Then GoTo 1920:
a(181) = -a(192) + a(245) + a(256):                                     If a(181) < m1 Or a(181) > m2 Then GoTo 1920:
If a(181) = a(182) Then GoTo 1920
a(180) = a(192) + a(244) - a(256):                                      If a(180) < m1 Or a(180) > m2 Then GoTo 1920:
a(179) = s1 / 4 - a(192) - a(244) - a(245) - a(246) + a(256):           If a(179) < m1 Or a(179) > m2 Then GoTo 1920:
If a(179) = a(180) Then GoTo 1920
a(178) = a(192) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254):  If a(178) < m1 Or a(178) > m2 Then GoTo 1920:
a(177) = s1 / 4 - a(192) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254):
If a(177) < m1 Or a(177) > m2 Then GoTo 1920:
If a(177) = a(178) Then GoTo 1920

m11 = 177: m21 = 192: GoSub 2700: If fl1 = 0 Then GoTo 1920       'Check row 5

a(176) = s1 / 4 - a(192) - a(208) - a(224):                             If a(176) < m1 Or a(176) > m2 Then GoTo 1920:
If a(176) = a(191) Or a(176) = a(192) Then GoTo 1920
a(175) = a(192) + a(208) + a(224) - a(255) - a(256):                    If a(175) < m1 Or a(175) > m2 Then GoTo 1920:
If a(175) = a(176) Or a(175) = a(191) Or a(175) = a(192) Then GoTo 1920
a(174) = s1 / 4 - a(192) - a(208) - a(224) - a(254) + a(256):           If a(174) < m1 Or a(174) > m2 Then GoTo 1920:
If a(174) = a(189) Or a(174) = a(190) Then GoTo 1920
a(173) = a(192) + a(208) + a(224) - a(253) - a(256):                    If a(173) < m1 Or a(173) > m2 Then GoTo 1920:
If a(173) = a(174) Or a(173) = a(189) Or a(173) = a(190) Then GoTo 1920
a(172) = s1 / 4 - a(192) - a(208) - a(224) - a(252) + a(256):           If a(172) < m1 Or a(172) > m2 Then GoTo 1920:
If a(172) = a(187) Or a(172) = a(188) Then GoTo 1920
a(171) = -s1 / 4 + a(192) + a(208) + a(224) + a(252) + a(253) + a(254) - a(256):
If a(171) < m1 Or a(171) > m2 Then GoTo 1920:
If a(171) = a(172) Or a(171) = a(187) Or a(171) = a(188) Then GoTo 1920
a(170) = s1 / 4 - a(192) - a(208) - a(224) - a(250) + a(256):           If a(170) < m1 Or a(170) > m2 Then GoTo 1920:
If a(170) = a(185) Or a(170) = a(186) Then GoTo 1920
a(169) = -s1 / 4 + a(192) + a(208) + a(224) + a(250) + a(255):          If a(169) < m1 Or a(169) > m2 Then GoTo 1920:
If a(169) = a(170) Or a(169) = a(185) Or a(169) = a(186) Then GoTo 1920
a(168) = s1 / 4 - a(192) - a(208) - a(224) - a(248) + a(256):           If a(168) < m1 Or a(168) > m2 Then GoTo 1920:
If a(168) = a(183) Or a(168) = a(184) Then GoTo 1920
a(167) = a(192) + a(208) + a(224) - a(247) - a(256):                    If a(167) < m1 Or a(167) > m2 Then GoTo 1920:
If a(167) = a(168) Or a(167) = a(183) Or a(167) = a(184) Then GoTo 1920
a(166) = s1 / 4 - a(192) - a(208) - a(224) - a(246) + a(256):           If a(166) < m1 Or a(166) > m2 Then GoTo 1920:
If a(166) = a(181) Or a(166) = a(182) Then GoTo 1920
a(165) = a(192) + a(208) + a(224) - a(245) - a(256):                    If a(165) < m1 Or a(165) > m2 Then GoTo 1920:
If a(165) = a(166) Or a(165) = a(181) Or a(165) = a(182) Then GoTo 1920
a(164) = s1 / 4 - a(192) - a(208) - a(224) - a(244) + a(256):           If a(164) < m1 Or a(164) > m2 Then GoTo 1920:
If a(164) = a(179) Or a(164) = a(180) Then GoTo 1920
a(163) = -s1 / 4 + a(192) + a(208) + a(224) + a(244) + a(245) + a(246) - a(256):
If a(163) < m1 Or a(163) > m2 Then GoTo 1920:
If a(163) = a(164) Or a(163) = a(179) Or a(163) = a(180) Then GoTo 1920
a(162) = s1 / 4 - a(192) - a(208) - a(224) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254):
If a(162) < m1 Or a(162) > m2 Then GoTo 1920:
If a(162) = a(177) Or a(162) = a(178) Then GoTo 1920
a(161) = -s1 / 4 + a(192) + a(208) + a(224) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254):
If a(161) < m1 Or a(161) > m2 Then GoTo 1920:
If a(161) = a(162) Or a(161) = a(177) Or a(161) = a(178) Then GoTo 1920

m11 = 161: m21 = 176: GoSub 2700: If fl1 = 0 Then GoTo 1920             'Check row 6

For j160 = m1 To m2                                                     'a(160)
a(160) = j160

a(159) = -a(160) + a(255) + a(256):                                     If a(159) < m1 Or a(159) > m2 Then GoTo 1600:
If a(159) = a(160) Then GoTo 1600
a(158) = a(160) + a(254) - a(256):                                      If a(158) < m1 Or a(158) > m2 Then GoTo 1600:
a(157) = -a(160) + a(253) + a(256):                                     If a(157) < m1 Or a(157) > m2 Then GoTo 1600:
If a(157) = a(158) Then GoTo 1600
a(156) = a(160) + a(252) - a(256):                                      If a(156) < m1 Or a(156) > m2 Then GoTo 1600:
a(155) = s1 / 4 - a(160) - a(252) - a(253) - a(254) + a(256):           If a(155) < m1 Or a(155) > m2 Then GoTo 1600:
If a(155) = a(156) Then GoTo 1600
a(154) = a(160) + a(250) - a(256):                                      If a(154) < m1 Or a(154) > m2 Then GoTo 1600:
a(153) = s1 / 4 - a(160) - a(250) - a(255):                             If a(153) < m1 Or a(153) > m2 Then GoTo 1600:
If a(153) = a(154) Then GoTo 1600
a(152) = a(160) + a(248) - a(256):                                      If a(152) < m1 Or a(152) > m2 Then GoTo 1600:
a(151) = -a(160) + a(247) + a(256):                                     If a(151) < m1 Or a(151) > m2 Then GoTo 1600:
If a(151) = a(152) Then GoTo 1600
a(150) = a(160) + a(246) - a(256):                                      If a(150) < m1 Or a(150) > m2 Then GoTo 1600:
a(149) = -a(160) + a(245) + a(256):                                     If a(149) < m1 Or a(149) > m2 Then GoTo 1600:
If a(149) = a(150) Then GoTo 1600
a(148) = a(160) + a(244) - a(256):                                      If a(148) < m1 Or a(148) > m2 Then GoTo 1600:
a(147) = s1 / 4 - a(160) - a(244) - a(245) - a(246) + a(256):           If a(147) < m1 Or a(147) > m2 Then GoTo 1600:
If a(147) = a(148) Then GoTo 1600
a(146) = a(160) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254):  If a(146) < m1 Or a(146) > m2 Then GoTo 1600:
a(145) = s1 / 4 - a(160) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254):
If a(145) < m1 Or a(145) > m2 Then GoTo 1600:
If a(145) = a(146) Then GoTo 1600

m11 = 145: m21 = 160: GoSub 2700: If fl1 = 0 Then GoTo 1600             'Check row 7

a(144) = s1 / 4 - a(160) - a(240) - a(256):                             If a(144) < m1 Or a(144) > m2 Then GoTo 1600:
If a(144) = a(159) Or a(144) = a(160) Then GoTo 1600
a(143) = a(160) + a(240) - a(255):                                      If a(143) < m1 Or a(143) > m2 Then GoTo 1600:
If a(143) = a(144) Or a(143) = a(159) Or a(143) = a(160) Then GoTo 1600
a(142) = s1 / 4 - a(160) - a(240) - a(254):                             If a(142) < m1 Or a(142) > m2 Then GoTo 1600:
If a(142) = a(157) Or a(142) = a(158) Then GoTo 1600
a(141) = a(160) + a(240) - a(253):                                      If a(141) < m1 Or a(141) > m2 Then GoTo 1600:
If a(141) = a(142) Or a(141) = a(157) Or a(141) = a(158) Then GoTo 1600
a(140) = s1 / 4 - a(160) - a(240) - a(252):                             If a(140) < m1 Or a(140) > m2 Then GoTo 1600:
If a(140) = a(155) Or a(140) = a(156) Then GoTo 1600
a(139) = -s1 / 4 + a(160) + a(240) + a(252) + a(253) + a(254):          If a(139) < m1 Or a(139) > m2 Then GoTo 1600:
If a(139) = a(140) Or a(139) = a(155) Or a(139) = a(156) Then GoTo 1600
a(138) = s1 / 4 - a(160) - a(240) - a(250):                             If a(138) < m1 Or a(138) > m2 Then GoTo 1600:
If a(138) = a(153) Or a(138) = a(154) Then GoTo 1600
a(137) = -s1 / 4 + a(160) + a(240) + a(250) + a(255) + a(256):          If a(137) < m1 Or a(137) > m2 Then GoTo 1600:
If a(137) = a(138) Or a(137) = a(153) Or a(137) = a(154) Then GoTo 1600
a(136) = s1 / 4 - a(160) - a(240) - a(248):                             If a(136) < m1 Or a(136) > m2 Then GoTo 1600:
If a(136) = a(151) Or a(136) = a(152) Then GoTo 1600
a(135) = a(160) + a(240) - a(247):                                      If a(135) < m1 Or a(135) > m2 Then GoTo 1600:
If a(135) = a(136) Or a(135) = a(151) Or a(135) = a(152) Then GoTo 1600
a(134) = s1 / 4 - a(160) - a(240) - a(246):                             If a(134) < m1 Or a(134) > m2 Then GoTo 1600:
If a(134) = a(149) Or a(134) = a(150) Then GoTo 1600
a(133) = a(160) + a(240) - a(245):                                      If a(133) < m1 Or a(133) > m2 Then GoTo 1600:
If a(133) = a(134) Or a(133) = a(149) Or a(133) = a(150) Then GoTo 1600
a(132) = s1 / 4 - a(160) - a(240) - a(244):                             If a(132) < m1 Or a(132) > m2 Then GoTo 1600:
If a(132) = a(147) Or a(132) = a(148) Then GoTo 1600
a(131) = -s1 / 4 + a(160) + a(240) + a(244) + a(245) + a(246):          If a(131) < m1 Or a(131) > m2 Then GoTo 1600:
If a(131) = a(132) Or a(131) = a(147) Or a(131) = a(148) Then GoTo 1600
a(130) = s1 / 4 - a(160) - a(240) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254) - a(256):
If a(130) < m1 Or a(130) > m2 Then GoTo 1600:
If a(130) = a(145) Or a(130) = a(146) Then GoTo 1600
a(129) = -s1 / 4 + a(160) + a(240) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254) + a(256):
If a(129) < m1 Or a(129) > m2 Then GoTo 1600:
If a(129) = a(130) Or a(129) = a(145) Or a(129) = a(146) Then GoTo 1600

m11 = 129: m21 = 144: GoSub 2700: If fl1 = 0 Then GoTo 1600             'Check row 8

For j128 = m1 To m2                                                     'a(128)
a(128) = j128

a(127) = -a(128) + a(255) + a(256):                                     If a(127) < m1 Or a(127) > m2 Then GoTo 1280:
If a(127) = a(128) Then GoTo 1280
a(126) = a(128) + a(254) - a(256):                                      If a(126) < m1 Or a(126) > m2 Then GoTo 1280:
a(125) = -a(128) + a(253) + a(256):                                     If a(125) < m1 Or a(125) > m2 Then GoTo 1280:
If a(125) = a(126) Then GoTo 1280
a(124) = a(128) + a(252) - a(256):                                      If a(124) < m1 Or a(124) > m2 Then GoTo 1280:
a(123) = s1 / 4 - a(128) - a(252) - a(253) - a(254) + a(256):           If a(123) < m1 Or a(123) > m2 Then GoTo 1280:
If a(123) = a(124) Then GoTo 1280
a(122) = a(128) + a(250) - a(256):                                      If a(122) < m1 Or a(122) > m2 Then GoTo 1280:
a(121) = s1 / 4 - a(128) - a(250) - a(255):                             If a(121) < m1 Or a(121) > m2 Then GoTo 1280:
If a(121) = a(122) Then GoTo 1280
a(120) = a(128) + a(248) - a(256):                                      If a(120) < m1 Or a(120) > m2 Then GoTo 1280:
a(119) = -a(128) + a(247) + a(256):                                     If a(119) < m1 Or a(119) > m2 Then GoTo 1280:
If a(119) = a(120) Then GoTo 1280
a(118) = a(128) + a(246) - a(256):                                      If a(118) < m1 Or a(118) > m2 Then GoTo 1280:
a(117) = -a(128) + a(245) + a(256):                                     If a(117) < m1 Or a(117) > m2 Then GoTo 1280:
If a(117) = a(118) Then GoTo 1280
a(116) = a(128) + a(244) - a(256):                                      If a(116) < m1 Or a(116) > m2 Then GoTo 1280:
a(115) = s1 / 4 - a(128) - a(244) - a(245) - a(246) + a(256):           If a(115) < m1 Or a(115) > m2 Then GoTo 1280:
If a(115) = a(116) Then GoTo 1280
a(114) = a(128) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254):  If a(114) < m1 Or a(114) > m2 Then GoTo 1280:
a(113) = s1 / 4 - a(128) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254):
If a(113) < m1 Or a(113) > m2 Then GoTo 1280:
If a(113) = a(114) Then GoTo 1280

m11 = 113: m21 = 128: GoSub 2700: If fl1 = 0 Then GoTo 1280            'Check row 9

For j112 = m1 To m2                                                    'a(112)
a(112) = j112
If a(112) = a(127) Or a(112) = a(128) Then GoTo 1120
a(111) = s1 / 4 - a(112) - a(255) - a(256):                             If a(111) < m1 Or a(111) > m2 Then GoTo 1120:
If a(111) = a(112) Or a(111) = a(127) Or a(111) = a(128) Then GoTo 1120
a(110) = a(112) - a(254) + a(256):                                      If a(110) < m1 Or a(110) > m2 Then GoTo 1120:
If a(110) = a(125) Or a(110) = a(126) Then GoTo 1120
a(109) = s1 / 4 - a(112) - a(253) - a(256):                             If a(109) < m1 Or a(109) > m2 Then GoTo 1120:
If a(109) = a(110) Or a(109) = a(125) Or a(109) = a(126) Then GoTo 1120
a(108) = a(112) - a(252) + a(256):                                      If a(108) < m1 Or a(108) > m2 Then GoTo 1120:
If a(108) = a(123) Or a(108) = a(124) Then GoTo 1120
a(107) = -a(112) + a(252) + a(253) + a(254) - a(256):                   If a(107) < m1 Or a(107) > m2 Then GoTo 1120:
If a(107) = a(108) Or a(107) = a(123) Or a(107) = a(124) Then GoTo 1120
a(106) = a(112) - a(250) + a(256):                                      If a(106) < m1 Or a(106) > m2 Then GoTo 1120:
If a(106) = a(121) Or a(106) = a(122) Then GoTo 1120
a(105) = -a(112) + a(250) + a(255):                                     If a(105) < m1 Or a(105) > m2 Then GoTo 1120:
If a(105) = a(106) Or a(105) = a(121) Or a(105) = a(122) Then GoTo 1120
a(104) = a(112) - a(248) + a(256):                                      If a(104) < m1 Or a(104) > m2 Then GoTo 1120:
If a(104) = a(119) Or a(104) = a(120) Then GoTo 1120
a(103) = s1 / 4 - a(112) - a(247) - a(256):                             If a(103) < m1 Or a(103) > m2 Then GoTo 1120:
If a(103) = a(104) Or a(103) = a(119) Or a(103) = a(120) Then GoTo 1120
a(102) = a(112) - a(246) + a(256):                                      If a(102) < m1 Or a(102) > m2 Then GoTo 1120:
If a(102) = a(117) Or a(102) = a(118) Then GoTo 1120
a(101) = s1 / 4 - a(112) - a(245) - a(256):                             If a(101) < m1 Or a(101) > m2 Then GoTo 1120:
If a(101) = a(102) Or a(101) = a(117) Or a(101) = a(118) Then GoTo 1120
a(100) = a(112) - a(244) + a(256):                                      If a(100) < m1 Or a(100) > m2 Then GoTo 1120:
If a(100) = a(115) Or a(100) = a(116) Then GoTo 1120
a(99) = -a(112) + a(244) + a(245) + a(246) - a(256):                    If a(99) < m1 Or a(99) > m2 Then GoTo 1120:
If a(99) = a(100) Or a(99) = a(115) Or a(99) = a(116) Then GoTo 1120
a(98) = a(112) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254):   If a(98) < m1 Or a(98) > m2 Then GoTo 1120:
If a(98) = a(113) Or a(98) = a(114) Then GoTo 1120
a(97) = -a(112) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254):  If a(97) < m1 Or a(97) > m2 Then GoTo 1120:
If a(97) = a(98) Or a(97) = a(113) Or a(97) = a(114) Then GoTo 1120

m11 = 97: m21 = 112: GoSub 2700: If fl1 = 0 Then GoTo 1120             'Check row 10

For j96 = m1 To m2                                                     'a(96)
a(96) = j96

a(95) = -a(96) + a(255) + a(256):                                       If a(95) < m1 Or a(95) > m2 Then GoTo 960:
If a(95) = a(96) Then GoTo 960
a(94) = a(96) + a(254) - a(256):                                        If a(94) < m1 Or a(94) > m2 Then GoTo 960:
a(93) = -a(96) + a(253) + a(256):                                       If a(93) < m1 Or a(93) > m2 Then GoTo 960:
If a(93) = a(94) Then GoTo 960
a(92) = a(96) + a(252) - a(256):                                        If a(92) < m1 Or a(92) > m2 Then GoTo 960:
a(91) = s1 / 4 - a(96) - a(252) - a(253) - a(254) + a(256):             If a(91) < m1 Or a(91) > m2 Then GoTo 960:
If a(91) = a(92) Then GoTo 960
a(90) = a(96) + a(250) - a(256):                                        If a(90) < m1 Or a(90) > m2 Then GoTo 960:
a(89) = s1 / 4 - a(96) - a(250) - a(255):                               If a(89) < m1 Or a(89) > m2 Then GoTo 960:
If a(89) = a(90) Then GoTo 960
a(88) = a(96) + a(248) - a(256):                                        If a(88) < m1 Or a(88) > m2 Then GoTo 960:
a(87) = -a(96) + a(247) + a(256):                                       If a(87) < m1 Or a(87) > m2 Then GoTo 960:
If a(87) = a(88) Then GoTo 960
a(86) = a(96) + a(246) - a(256):                                        If a(86) < m1 Or a(86) > m2 Then GoTo 960:
a(85) = -a(96) + a(245) + a(256):                                       If a(85) < m1 Or a(85) > m2 Then GoTo 960:
If a(85) = a(86) Then GoTo 960
a(84) = a(96) + a(244) - a(256):                                        If a(84) < m1 Or a(84) > m2 Then GoTo 960:
a(83) = s1 / 4 - a(96) - a(244) - a(245) - a(246) + a(256):             If a(83) < m1 Or a(83) > m2 Then GoTo 960:
If a(83) = a(84) Then GoTo 960
a(82) = a(96) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254):    If a(82) < m1 Or a(82) > m2 Then GoTo 960:
a(81) = s1 / 4 - a(96) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254):
If a(81) < m1 Or a(81) > m2 Then GoTo 960:
If a(81) = a(82) Then GoTo 960

m11 = 81: m21 = 96: GoSub 2700: If fl1 = 0 Then GoTo 960                'Check row 11

For j80 = m1 To m2                                                      'a(80)
a(80) = j80
If a(80) = a(95) Or a(80) = a(96) Then GoTo 800

a(79) = s1 / 4 - a(80) - a(255) - a(256):                               If a(79) < m1 Or a(79) > m2 Then GoTo 800:
If a(79) = a(80) Or a(79) = a(95) Or a(79) = a(96) Then GoTo 800
a(78) = a(80) - a(254) + a(256):                                        If a(78) < m1 Or a(78) > m2 Then GoTo 800:
If a(78) = a(93) Or a(78) = a(94) Then GoTo 800
a(77) = s1 / 4 - a(80) - a(253) - a(256):                               If a(77) < m1 Or a(77) > m2 Then GoTo 800:
If a(77) = a(78) Or a(77) = a(93) Or a(77) = a(94) Then GoTo 800
a(76) = a(80) - a(252) + a(256):                                        If a(76) < m1 Or a(76) > m2 Then GoTo 800:
If a(76) = a(91) Or a(76) = a(92) Then GoTo 800
a(75) = -a(80) + a(252) + a(253) + a(254) - a(256):                     If a(75) < m1 Or a(75) > m2 Then GoTo 800:
If a(75) = a(76) Or a(75) = a(91) Or a(75) = a(92) Then GoTo 800
a(74) = a(80) - a(250) + a(256):                                        If a(74) < m1 Or a(74) > m2 Then GoTo 800:
If a(74) = a(89) Or a(74) = a(90) Then GoTo 800
a(73) = -a(80) + a(250) + a(255):                                       If a(73) < m1 Or a(73) > m2 Then GoTo 800:
If a(73) = a(74) Or a(73) = a(89) Or a(73) = a(90) Then GoTo 800
a(72) = a(80) - a(248) + a(256):                                        If a(72) < m1 Or a(72) > m2 Then GoTo 800:
If a(72) = a(87) Or a(72) = a(88) Then GoTo 800
a(71) = s1 / 4 - a(80) - a(247) - a(256):                               If a(71) < m1 Or a(71) > m2 Then GoTo 800:
If a(71) = a(72) Or a(71) = a(87) Or a(71) = a(88) Then GoTo 800
a(70) = a(80) - a(246) + a(256):                                        If a(70) < m1 Or a(70) > m2 Then GoTo 800:
If a(70) = a(85) Or a(70) = a(86) Then GoTo 800
a(69) = s1 / 4 - a(80) - a(245) - a(256):                               If a(69) < m1 Or a(69) > m2 Then GoTo 800:
If a(69) = a(70) Or a(69) = a(85) Or a(69) = a(86) Then GoTo 800
a(68) = a(80) - a(244) + a(256):                                        If a(68) < m1 Or a(68) > m2 Then GoTo 800:
If a(68) = a(83) Or a(68) = a(84) Then GoTo 800
a(67) = -a(80) + a(244) + a(245) + a(246) - a(256):                     If a(67) < m1 Or a(67) > m2 Then GoTo 800:
If a(67) = a(68) Or a(67) = a(83) Or a(67) = a(84) Then GoTo 800
a(66) = a(80) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254):    If a(66) < m1 Or a(66) > m2 Then GoTo 800:
If a(66) = a(81) Or a(66) = a(82) Then GoTo 800
a(65) = -a(80) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254):   If a(65) < m1 Or a(65) > m2 Then GoTo 800:
If a(65) = a(66) Or a(65) = a(81) Or a(65) = a(82) Then GoTo 800

m11 = 65: m21 = 80: GoSub 2700: If fl1 = 0 Then GoTo 800                'Check row 12

For j64 = m1 To m2                                                      'a(64)
a(64) = j64

a(63) = -a(64) + a(255) + a(256):                                       If a(63) < m1 Or a(63) > m2 Then GoTo 640:
If a(63) = a(64) Then GoTo 640
a(62) = a(64) + a(254) - a(256):                                        If a(62) < m1 Or a(62) > m2 Then GoTo 640:
a(61) = -a(64) + a(253) + a(256):                                       If a(61) < m1 Or a(61) > m2 Then GoTo 640:
If a(61) = a(62) Then GoTo 640
a(60) = a(64) + a(252) - a(256):                                        If a(60) < m1 Or a(60) > m2 Then GoTo 640:
a(59) = s1 / 4 - a(64) - a(252) - a(253) - a(254) + a(256):             If a(59) < m1 Or a(59) > m2 Then GoTo 640:
If a(59) = a(60) Then GoTo 640
a(58) = a(64) + a(250) - a(256):                                        If a(58) < m1 Or a(58) > m2 Then GoTo 640:
a(57) = s1 / 4 - a(64) - a(250) - a(255):                               If a(57) < m1 Or a(57) > m2 Then GoTo 640:
If a(57) = a(58) Then GoTo 640
a(56) = a(64) + a(248) - a(256):                                        If a(56) < m1 Or a(56) > m2 Then GoTo 640:
a(55) = -a(64) + a(247) + a(256):                                       If a(55) < m1 Or a(55) > m2 Then GoTo 640:
If a(55) = a(56) Then GoTo 640
a(54) = a(64) + a(246) - a(256):                                        If a(54) < m1 Or a(54) > m2 Then GoTo 640:
a(53) = -a(64) + a(245) + a(256):                                       If a(53) < m1 Or a(53) > m2 Then GoTo 640:
If a(53) = a(54) Then GoTo 640
a(52) = a(64) + a(244) - a(256):                                        If a(52) < m1 Or a(52) > m2 Then GoTo 640:
a(51) = s1 / 4 - a(64) - a(244) - a(245) - a(246) + a(256):             If a(51) < m1 Or a(51) > m2 Then GoTo 640:
If a(51) = a(52) Then GoTo 640
a(50) = a(64) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254): If a(50) < m1 Or a(50) > m2 Then GoTo 640:
a(49) = s1 / 4 - a(64) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254):
If a(49) < m1 Or a(49) > m2 Then GoTo 640:
If a(49) = a(50) Then GoTo 640

m11 = 49: m21 = 64: GoSub 2700: If fl1 = 0 Then GoTo 640               'Check row 13

a(48) = s1 / 4 - a(64) - a(80) - a(96):                                 If a(48) < m1 Or a(48) > m2 Then GoTo 640:
If a(48) = a(63) Or a(48) = a(64) Then GoTo 640
a(47) = a(64) + a(80) + a(96) - a(255) - a(256):                        If a(47) < m1 Or a(47) > m2 Then GoTo 640:
If a(47) = a(48) Or a(47) = a(63) Or a(47) = a(64) Then GoTo 640
a(46) = s1 / 4 - a(64) - a(80) - a(96) - a(254) + a(256):               If a(46) < m1 Or a(46) > m2 Then GoTo 640:
If a(46) = a(61) Or a(46) = a(62) Then GoTo 640
a(45) = a(64) + a(80) + a(96) - a(253) - a(256):                        If a(45) < m1 Or a(45) > m2 Then GoTo 640:
If a(45) = a(46) Or a(45) = a(61) Or a(45) = a(62) Then GoTo 640
a(44) = s1 / 4 - a(64) - a(80) - a(96) - a(252) + a(256):               If a(44) < m1 Or a(44) > m2 Then GoTo 640:
If a(44) = a(59) Or a(44) = a(60) Then GoTo 640
a(43) = -s1 / 4 + a(64) + a(80) + a(96) + a(252) + a(253) + a(254) - a(256):
If a(43) < m1 Or a(43) > m2 Then GoTo 640:
If a(43) = a(44) Or a(43) = a(59) Or a(43) = a(60) Then GoTo 640
a(42) = s1 / 4 - a(64) - a(80) - a(96) - a(250) + a(256):               If a(42) < m1 Or a(42) > m2 Then GoTo 640:
If a(42) = a(57) Or a(42) = a(58) Then GoTo 640
a(41) = -s1 / 4 + a(64) + a(80) + a(96) + a(250) + a(255):              If a(41) < m1 Or a(41) > m2 Then GoTo 640:
If a(41) = a(42) Or a(41) = a(57) Or a(41) = a(58) Then GoTo 640
a(40) = s1 / 4 - a(64) - a(80) - a(96) - a(248) + a(256):               If a(40) < m1 Or a(40) > m2 Then GoTo 640:
If a(40) = a(55) Or a(40) = a(56) Then GoTo 640
a(39) = a(64) + a(80) + a(96) - a(247) - a(256):                        If a(39) < m1 Or a(39) > m2 Then GoTo 640:
If a(39) = a(40) Or a(39) = a(55) Or a(39) = a(56) Then GoTo 640
a(38) = s1 / 4 - a(64) - a(80) - a(96) - a(246) + a(256):               If a(38) < m1 Or a(38) > m2 Then GoTo 640:
If a(38) = a(53) Or a(38) = a(54) Then GoTo 640
a(37) = a(64) + a(80) + a(96) - a(245) - a(256):                        If a(37) < m1 Or a(37) > m2 Then GoTo 640:
If a(37) = a(38) Or a(37) = a(53) Or a(37) = a(54) Then GoTo 640
a(36) = s1 / 4 - a(64) - a(80) - a(96) - a(244) + a(256):               If a(36) < m1 Or a(36) > m2 Then GoTo 640:
If a(36) = a(51) Or a(36) = a(52) Then GoTo 640
a(35) = -s1 / 4 + a(64) + a(80) + a(96) + a(244) + a(245) + a(246) - a(256):
If a(35) < m1 Or a(35) > m2 Then GoTo 640:
If a(35) = a(36) Or a(35) = a(51) Or a(35) = a(52) Then GoTo 640
a(34) = s1 / 4 - a(64) - a(80) - a(96) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254):
If a(34) < m1 Or a(34) > m2 Then GoTo 640:
If a(34) = a(49) Or a(34) = a(50) Then GoTo 640
a(33) = -s1 / 4 + a(64) + a(80) + a(96) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254):
If a(33) < m1 Or a(33) > m2 Then GoTo 640:
If a(33) = a(34) Or a(33) = a(49) Or a(33) = a(50) Then GoTo 640

m11 = 33: m21 = 48: GoSub 2700: If fl1 = 0 Then GoTo 640                'Check row 14

a(32) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(256):    If a(32) < m1 Or a(32) > m2 Then GoTo 640:
a(31) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(255):     If a(31) < m1 Or a(31) > m2 Then GoTo 640:
If a(31) = a(32) Then GoTo 640
a(30) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(254):    If a(30) < m1 Or a(30) > m2 Then GoTo 640:
a(29) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(253):     If a(29) < m1 Or a(29) > m2 Then GoTo 640:
If a(29) = a(30) Then GoTo 640
a(28) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(252):    If a(28) < m1 Or a(28) > m2 Then GoTo 640:
a(27) = s1 / 4 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) - a(252) - a(253) - a(254):
If a(27) < m1 Or a(27) > m2 Then GoTo 640:
If a(27) = a(28) Then GoTo 640
a(26) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(250):    If a(26) < m1 Or a(26) > m2 Then GoTo 640:
a(25) = s1 / 4 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) - a(250) - a(255) - a(256):
If a(25) < m1 Or a(25) > m2 Then GoTo 640:
If a(25) = a(26) Then GoTo 640
a(24) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(248):    If a(24) < m1 Or a(24) > m2 Then GoTo 640:
a(23) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(247):     If a(23) < m1 Or a(23) > m2 Then GoTo 640:
If a(23) = a(24) Then GoTo 640
a(22) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(246):    If a(22) < m1 Or a(22) > m2 Then GoTo 640:
a(21) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(245):     If a(21) < m1 Or a(21) > m2 Then GoTo 640:
If a(21) = a(22) Then GoTo 640
a(20) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(244):    If a(20) < m1 Or a(20) > m2 Then GoTo 640:
a(19) = s1 / 4 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) - a(244) - a(245) - a(246):
If a(19) < m1 Or a(19) > m2 Then GoTo 640:
If a(19) = a(20) Then GoTo 640
a(18) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254) + a(256):
If a(18) < m1 Or a(18) > m2 Then GoTo 640:
a(17) = s1 / 4 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254) - a(256):
If a(17) < m1 Or a(17) > m2 Then GoTo 640:
If a(17) = a(18) Then GoTo 640

m11 = 17: m21 = 32: GoSub 2700: If fl1 = 0 Then GoTo 640               'Check row 15

a(16) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(256):
If a(16) < m1 Or a(16) > m2 Then GoTo 640:
If a(16) = a(31) Or a(16) = a(32) Then GoTo 640
a(15) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(255):    If a(15) < m1 Or a(15) > m2 Then GoTo 640:
If a(15) = a(16) Or a(15) = a(31) Or a(15) = a(32) Then GoTo 640
a(14) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(254):
If a(14) < m1 Or a(14) > m2 Then GoTo 640:
If a(14) = a(29) Or a(14) = a(30) Then GoTo 640
a(13) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(253):    If a(13) < m1 Or a(13) > m2 Then GoTo 640:
If a(13) = a(14) Or a(13) = a(29) Or a(13) = a(30) Then GoTo 640
a(12) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(252):
If a(12) < m1 Or a(12) > m2 Then GoTo 640:
If a(12) = a(27) Or a(12) = a(28) Then GoTo 640
a(11) = -s1 / 4 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) + a(252) + a(253) + a(254):
If a(11) < m1 Or a(11) > m2 Then GoTo 640:
If a(11) = a(12) Or a(11) = a(27) Or a(11) = a(28) Then GoTo 640
a(10) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(250):
If a(10) < m1 Or a(10) > m2 Then GoTo 640:
If a(10) = a(25) Or a(10) = a(26) Then GoTo 640
a(9) = -s1 / 4 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) + a(250) + a(255) + a(256):
If a(9) < m1 Or a(9) > m2 Then GoTo 640:
If a(9) = a(10) Or a(9) = a(25) Or a(9) = a(26) Then GoTo 640
a(8) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(248):
If a(8) < m1 Or a(8) > m2 Then GoTo 640:
If a(8) = a(23) Or a(8) = a(24) Then GoTo 640
a(7) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(247):
If a(7) < m1 Or a(7) > m2 Then GoTo 640:
If a(7) = a(8) Or a(7) = a(23) Or a(7) = a(24) Then GoTo 640
a(6) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(246):
If a(6) < m1 Or a(6) > m2 Then GoTo 640:
If a(6) = a(21) Or a(6) = a(22) Then GoTo 640
a(5) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(245):     If a(5) < m1 Or a(5) > m2 Then GoTo 640:
If a(5) = a(6) Or a(5) = a(21) Or a(5) = a(22) Then GoTo 640
a(4) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(244):
If a(4) < m1 Or a(4) > m2 Then GoTo 640:
If a(4) = a(19) Or a(4) = a(20) Then GoTo 640
a(3) = -s1 / 4 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) + a(244) + a(245) + a(246):
If a(3) < m1 Or a(3) > m2 Then GoTo 640:
If a(3) = a(4) Or a(3) = a(19) Or a(3) = a(20) Then GoTo 640
a(2) = s1 / 4 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254) - a(256):
If a(2) < m1 Or a(2) > m2 Then GoTo 640:
If a(2) = a(17) Or a(2) = a(18) Then GoTo 640
a(1) = -s1 / 4 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254) + a(256):
If a(1) < m1 Or a(1) > m2 Then GoTo 640:
If a(1) = a(2) Or a(1) = a(17) Or a(1) = a(18) Then GoTo 640

m11 = 1: m21 = 16: GoSub 2700: If fl1 = 0 Then GoTo 640           'Check row 16

GoSub 2750: If fl1 = 0 Then GoTo 640 'Check diagonal 1, 2
GoSub 2770: If fl1 = 0 Then GoTo 640 'Check columns  1 ... 16
                                    
                            n9 = n9 + 1              'Total
'                           GoSub 2650               'Print results (Aux     Squares)
'                           GoSub 2655               'Print results (Bimagic Squares)
                            Cells(2, 1).Value = n9   'Counting
                            
'                           n10 = n10 + 1            'Inventarisation step 1
'                           Sheets(ShtNm1).Cells(j100, 66).Value = n10
                            
                            GoSub 3000               'Check properties as required

640 Next j64

800 Next j80

960 Next j96

1120 Next j112

1280 Next j128

1600 Next j160

1920 Next j192
     
2080 Next j208

2240 Next j224

2400 Next j240

2440 Next j244
2450 Next j245
2460 Next j246
2470 Next j247
2480 Next j248

2500 Next j250

2520 Next j252
2530 Next j253
2540 Next j254
2550 Next j255
2560 Next j256

1000 Next j100

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

End

'    Check Properties as required

3000

     For i1 = 1 To 256
         c(i1) = 4 * b(i1) + a(i1)
     Next i1

'   Check Pan Magic

    s(1)=c(1)+c(18)+c(35)+c(52)+c(69)+c(86)+c(103)+c(120)+c(137)+c(154)+c(171)+c(188)+c(205)+c(222)+c(239)+c(256)
    s(2)=c(2)+c(19)+c(36)+c(53)+c(70)+c(87)+c(104)+c(121)+c(138)+c(155)+c(172)+c(189)+c(206)+c(223)+c(240)+c(241)
    s(3)=c(3)+c(20)+c(37)+c(54)+c(71)+c(88)+c(105)+c(122)+c(139)+c(156)+c(173)+c(190)+c(207)+c(224)+c(225)+c(242)
    s(4)=c(4)+c(21)+c(38)+c(55)+c(72)+c(89)+c(106)+c(123)+c(140)+c(157)+c(174)+c(191)+c(208)+c(209)+c(226)+c(243)
    s(5)=c(5)+c(22)+c(39)+c(56)+c(73)+c(90)+c(107)+c(124)+c(141)+c(158)+c(175)+c(192)+c(193)+c(210)+c(227)+c(244)
    s(6)=c(6)+c(23)+c(40)+c(57)+c(74)+c(91)+c(108)+c(125)+c(142)+c(159)+c(176)+c(177)+c(194)+c(211)+c(228)+c(245)
    s(7)=c(7)+c(24)+c(41)+c(58)+c(75)+c(92)+c(109)+c(126)+c(143)+c(160)+c(161)+c(178)+c(195)+c(212)+c(229)+c(246)
    s(8)=c(8)+c(25)+c(42)+c(59)+c(76)+c(93)+c(110)+c(127)+c(144)+c(145)+c(162)+c(179)+c(196)+c(213)+c(230)+c(247)
    s(9)=c(9)+c(26)+c(43)+c(60)+c(77)+c(94)+c(111)+c(128)+c(129)+c(146)+c(163)+c(180)+c(197)+c(214)+c(231)+c(248)
    s(10)=c(10)+c(27)+c(44)+c(61)+c(78)+c(95)+c(112)+c(113)+c(130)+c(147)+c(164)+c(181)+c(198)+c(215)+c(232)+c(249)
    s(11)=c(11)+c(28)+c(45)+c(62)+c(79)+c(96)+c(97)+c(114)+c(131)+c(148)+c(165)+c(182)+c(199)+c(216)+c(233)+c(250)
    s(12)=c(12)+c(29)+c(46)+c(63)+c(80)+c(81)+c(98)+c(115)+c(132)+c(149)+c(166)+c(183)+c(200)+c(217)+c(234)+c(251)
    s(13)=c(13)+c(30)+c(47)+c(64)+c(65)+c(82)+c(99)+c(116)+c(133)+c(150)+c(167)+c(184)+c(201)+c(218)+c(235)+c(252)
    s(14)=c(14)+c(31)+c(48)+c(49)+c(66)+c(83)+c(100)+c(117)+c(134)+c(151)+c(168)+c(185)+c(202)+c(219)+c(236)+c(253)
    s(15)=c(15)+c(32)+c(33)+c(50)+c(67)+c(84)+c(101)+c(118)+c(135)+c(152)+c(169)+c(186)+c(203)+c(220)+c(237)+c(254)
    s(16)=c(16)+c(17)+c(34)+c(51)+c(68)+c(85)+c(102)+c(119)+c(136)+c(153)+c(170)+c(187)+c(204)+c(221)+c(238)+c(255)

    s(17)=c(16)+c(31)+c(46)+c(61)+c(76)+c(91)+c(106)+c(121)+c(136)+c(151)+c(166)+c(181)+c(196)+c(211)+c(226)+c(241)
    s(18)=c(15)+c(30)+c(45)+c(60)+c(75)+c(90)+c(105)+c(120)+c(135)+c(150)+c(165)+c(180)+c(195)+c(210)+c(225)+c(256)
    s(19)=c(14)+c(29)+c(44)+c(59)+c(74)+c(89)+c(104)+c(119)+c(134)+c(149)+c(164)+c(179)+c(194)+c(209)+c(240)+c(255)
    s(20)=c(13)+c(28)+c(43)+c(58)+c(73)+c(88)+c(103)+c(118)+c(133)+c(148)+c(163)+c(178)+c(193)+c(224)+c(239)+c(254)
    s(21)=c(12)+c(27)+c(42)+c(57)+c(72)+c(87)+c(102)+c(117)+c(132)+c(147)+c(162)+c(177)+c(208)+c(223)+c(238)+c(253)
    s(22)=c(11)+c(26)+c(41)+c(56)+c(71)+c(86)+c(101)+c(116)+c(131)+c(146)+c(161)+c(192)+c(207)+c(222)+c(237)+c(252)
    s(23)=c(10)+c(25)+c(40)+c(55)+c(70)+c(85)+c(100)+c(115)+c(130)+c(145)+c(176)+c(191)+c(206)+c(221)+c(236)+c(251)
    s(24)=c(9)+c(24)+c(39)+c(54)+c(69)+c(84)+c(99)+c(114)+c(129)+c(160)+c(175)+c(190)+c(205)+c(220)+c(235)+c(250)
    s(25)=c(8)+c(23)+c(38)+c(53)+c(68)+c(83)+c(98)+c(113)+c(144)+c(159)+c(174)+c(189)+c(204)+c(219)+c(234)+c(249)  
    s(26)=c(7)+c(22)+c(37)+c(52)+c(67)+c(82)+c(97)+c(128)+c(143)+c(158)+c(173)+c(188)+c(203)+c(218)+c(233)+c(248)
    s(27)=c(6)+c(21)+c(36)+c(51)+c(66)+c(81)+c(112)+c(127)+c(142)+c(157)+c(172)+c(187)+c(202)+c(217)+c(232)+c(247)
    s(28)=c(5)+c(20)+c(35)+c(50)+c(65)+c(96)+c(111)+c(126)+c(141)+c(156)+c(171)+c(186)+c(201)+c(216)+c(231)+c(246)
    s(29)=c(4)+c(19)+c(34)+c(49)+c(80)+c(95)+c(110)+c(125)+c(140)+c(155)+c(170)+c(185)+c(200)+c(215)+c(230)+c(245)
    s(30)=c(3)+c(18)+c(33)+c(64)+c(79)+c(94)+c(109)+c(124)+c(139)+c(154)+c(169)+c(184)+c(199)+c(214)+c(229)+c(244)
    s(31)=c(2)+c(17)+c(48)+c(63)+c(78)+c(93)+c(108)+c(123)+c(138)+c(153)+c(168)+c(183)+c(198)+c(213)+c(228)+c(243)
    s(32)=c(1)+c(32)+c(47)+c(62)+c(77)+c(92)+c(107)+c(122)+c(137)+c(152)+c(167)+c(182)+c(197)+c(212)+c(227)+c(242)

    fl1 = 1
    For i1 = 1 To 32
        If s(i1) <> 2056 Then fl1 = 0: Exit For
    Next i1

    If fl1 = 1 Then
        n10 = n10 + 1
        Sheets(ShtNm1).Cells(j100, 67).Value = n10
    End If

'   Check Bimagic Semi Diagonals

    s(1)=c(9)^2+c(26)^2+c(43)^2+c(60)^2+c(77)^2+c(94)^2+c(111)^2+c(128)^2+c(129)^2 + 
                                               + c(146)^2+c(163)^2+c(180)^2+c(197) ^ 2+ c(214)^2+c(231)^2+c(248)^2
    s(2)=c(8)^2+c(23)^2+c(38)^2+c(53)^2+c(68)^2+c(83)^2+c(98)^2+c(113)^2+c(144)^2 + 
                                               + c(159)^2+c(174)^2+c(189)^2+c(204) ^ 2 +c(219) ^ 2+c(234)^2+c(249)^2

    fl1 = 1
    For i1 = 1 To 2
        If s(i1) <> 351576 Then fl1 = 0: Exit For
    Next i1

    If fl1 = 1 Then
        n11 = n11 + 1
        Sheets(ShtNm1).Cells(j100, 68).Value = n11
    End If
    
'   Check Complete
                            
    s(1) = c(1) + c(137):     s(2) = c(2) + c(138):     s(3) = c(3) + c(139):     s(4) = c(4) + c(140):
    s(5) = c(5) + c(141):     s(6) = c(6) + c(142):     s(7) = c(7) + c(143):     s(8) = c(8) + c(144):
    s(9) = c(9) + c(129):     s(10) = c(10) + c(130):   s(11) = c(11) + c(131):   s(12) = c(12) + c(132):
    s(13) = c(13) + c(133):   s(14) = c(14) + c(134):   s(15) = c(15) + c(135):   s(16) = c(16) + c(136):
    s(17) = c(17) + c(153):   s(18) = c(18) + c(154):   s(19) = c(19) + c(155):   s(20) = c(20) + c(156):
    s(21) = c(21) + c(157):   s(22) = c(22) + c(158):   s(23) = c(23) + c(159):   s(24) = c(24) + c(160):
    s(25) = c(25) + c(145):   s(26) = c(26) + c(146):   s(27) = c(27) + c(147):   s(28) = c(28) + c(148):
    s(29) = c(29) + c(149):   s(30) = c(30) + c(150):   s(31) = c(31) + c(151):   s(32) = c(32) + c(152):
    s(33) = c(33) + c(169):   s(34) = c(34) + c(170):   s(35) = c(35) + c(171):   s(36) = c(36) + c(172):
    s(37) = c(37) + c(173):   s(38) = c(38) + c(174):   s(39) = c(39) + c(175):   s(40) = c(40) + c(176):
    s(41) = c(41) + c(161):   s(42) = c(42) + c(162):   s(43) = c(43) + c(163):   s(44) = c(44) + c(164):
    s(45) = c(45) + c(165):   s(46) = c(46) + c(166):   s(47) = c(47) + c(167):   s(48) = c(48) + c(168):
    s(49) = c(49) + c(185):   s(50) = c(50) + c(186):   s(51) = c(51) + c(187):   s(52) = c(52) + c(188):
    s(53) = c(53) + c(189):   s(54) = c(54) + c(190):   s(55) = c(55) + c(191):   s(56) = c(56) + c(192):
    s(57) = c(57) + c(177):   s(58) = c(58) + c(178):   s(59) = c(59) + c(179):   s(60) = c(60) + c(180):
    s(61) = c(61) + c(181):   s(62) = c(62) + c(182):   s(63) = c(63) + c(183):   s(64) = c(64) + c(184):
    s(65) = c(65) + c(201):   s(66) = c(66) + c(202):   s(67) = c(67) + c(203):   s(68) = c(68) + c(204):
    s(69) = c(69) + c(205):   s(70) = c(70) + c(206):   s(71) = c(71) + c(207):   s(72) = c(72) + c(208):
    s(73) = c(73) + c(193):   s(74) = c(74) + c(194):   s(75) = c(75) + c(195):   s(76) = c(76) + c(196):
    s(77) = c(77) + c(197):   s(78) = c(78) + c(198):   s(79) = c(79) + c(199):   s(80) = c(80) + c(200):
    s(81) = c(81) + c(217):   s(82) = c(82) + c(218):   s(83) = c(83) + c(219):   s(84) = c(84) + c(220):
    s(85) = c(85) + c(221):   s(86) = c(86) + c(222):   s(87) = c(87) + c(223):   s(88) = c(88) + c(224):
    s(89) = c(89) + c(209):   s(90) = c(90) + c(210):   s(91) = c(91) + c(211):   s(92) = c(92) + c(212):
    s(93) = c(93) + c(213):   s(94) = c(94) + c(214):   s(95) = c(95) + c(215):   s(96) = c(96) + c(216):
    s(97) = c(97) + c(233):   s(98) = c(98) + c(234):   s(99) = c(99) + c(235):   s(100) = c(100) + c(236):
    s(101) = c(101) + c(237): s(102) = c(102) + c(238): s(103) = c(103) + c(239): s(104) = c(104) + c(240):
    s(105) = c(105) + c(225): s(106) = c(106) + c(226): s(107) = c(107) + c(227): s(108) = c(108) + c(228):
    s(109) = c(109) + c(229): s(110) = c(110) + c(230): s(111) = c(111) + c(231): s(112) = c(112) + c(232):
    s(113) = c(113) + c(249): s(114) = c(114) + c(250): s(115) = c(115) + c(251): s(116) = c(116) + c(252):
    s(117) = c(117) + c(253): s(118) = c(118) + c(254): s(119) = c(119) + c(255): s(120) = c(120) + c(256):
    s(121) = c(121) + c(241): s(122) = c(122) + c(242): s(123) = c(123) + c(243): s(124) = c(124) + c(244):
    s(125) = c(125) + c(245): s(126) = c(126) + c(246): s(127) = c(127) + c(247): s(128) = c(128) + c(248):
                            
    fl1 = 1
    For i1 = 1 To 128
        If s(i1) <> 257 Then fl1 = 0: Exit For
    Next i1
                            
    If fl1 = 1 Then
        n12 = n12 + 1
        Sheets(ShtNm1).Cells(j100, 69).Value = n12
    End If
    
    Return

'   Print results (squares)

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

     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
    
     i3 = 0
     For i1 = 1 To 16
         For i2 = 1 To 16
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1
    
     Return
     
'   Print results (Bimagic Squares)

2655
     For i1 = 1 To 256
         c(i1) = 4 * b(i1) + a(i1)
     Next i1
     
     n2 = n2 + 1
     If n2 = 3 Then
         n2 = 1: k1 = k1 + 17: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 17
     End If

     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
    
     i3 = 0
     For i1 = 1 To 16
         For i2 = 1 To 16
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = c(i3)
         Next i2
     Next i1
    
     Return
     
'    Check Row i (i = 1 ... 16)
     
2700 fl1 = 1

    s21 = 0: s31 = 0
    For i1 = m11 To m21
    
        s21 = s21 + a(i1) ^ 2
        s31 = s31 + a(i1) * b(i1)
    
    Next i1

    If s21 <> s2 Then fl1 = 0
    If s31 <> s3 Then fl1 = 0: Return

    Return

'   Check Diagonals 1, 2
     
2750 fl1 = 1

    s21 = 0: s31 = 0
    For i1 = 1 To 256 Step 17
    
        s21 = s21 + a(i1) ^ 2
        s31 = s31 + a(i1) * b(i1)
    
    Next i1

    If s21 <> s2 Then fl1 = 0: Return
    If s31 <> s3 Then fl1 = 0: Return

    s21 = 0: s31 = 0
    For i1 = 16 To 241 Step 15
    
        s21 = s21 + a(i1) ^ 2
        s31 = s31 + a(i1) * b(i1)
    
    Next i1

    If s21 <> s2 Then fl1 = 0: Return
    If s31 <> s3 Then fl1 = 0: Return

    Return

'    Check Columns 1 ... 16
     
2770 fl1 = 1

    For i2 = 1 To 16

        s21 = 0: s31 = 0
        m11 = i2: m21 = i2 + 240
       
        For i1 = m11 To m21 Step 16
        
            s21 = s21 + a(i1) ^ 2
            s31 = s31 + a(i1) * b(i1)
        
        Next i1
    
        If s21 <> s2 Then fl1 = 0: Return
        If s31 <> s3 Then fl1 = 0: Return

    Next i2
    
    Return

End Sub

Vorige Pagina About the Author