' Semi Latin Squares Order 16, Franklin Pan Magic, Complete (16 x 16)
' Tested with Office 365 under Windows 10
Sub Franklin16b()
Dim a(256), b(256), C(256), s(128)
Dim a2(256), b2(256)
y = MsgBox("Locked", vbCritical, "Routine Franklin16b")
End
n2 = 0: n9 = 0: k1 = 1: k2 = 1
m1 = 0: m2 = 15: s1 = 120: p1 = s1 / 8
' Generate Semi Latin Squares
Sheets("Klad1").Select
t1 = Timer
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
If a(254) = a(255) Or a(254) = a(256) Then GoTo 2540
For j253 = m1 To m2 'a(253)
a(253) = j253
If a(253) = a(254) Or a(253) = a(255) Or a(253) = a(256) Then GoTo 2530
For j252 = m1 To m2 'a(252)
a(252) = j252
If a(252) = a(253) Or a(252) = a(254) Or a(252) = a(255) Or a(252) = a(256) Then GoTo 2520
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) Or a(251) = a(253) Or a(251) = a(254) Or a(251) = a(255) Or a(251) = a(256) Then GoTo 2520
For j250 = m1 To m2 'a(250)
a(250) = j250
If a(250) = a(252) Or a(250) = a(253) Or a(250) = a(254) Or a(250) = a(255) Or a(250) = a(256) Then GoTo 2500
If a(250) = a(251) Then GoTo 2500
a(249) = s1 / 4 - a(250) - a(255) - a(256): If a(249) < m1 Or a(249) > m2 Then GoTo 2500:
a(248) = (a(250) + a(252) + a(254) - a(256)) / 2:
If a(248) < m1 Or a(248) > m2 Or CInt(a(248)) <> a(248) Then GoTo 2500:
a(247) = (s1 / 2 - a(250) - a(252) - a(254) - 2 * a(255) - a(256)) / 2:
If a(247) < m1 Or a(247) > m2 Or CInt(a(247)) <> a(247) Then GoTo 2500:
a(246) = (a(250) + a(252) - a(254) + a(256)) / 2:
If a(246) < m1 Or a(246) > m2 Or CInt(a(246) <> a(246)) Then GoTo 2500:
a(245) = (s1 / 2 - a(250) - a(252) - 2 * a(253) - a(254) - a(256)) / 2:
If a(245) < m1 Or a(245) > m2 Or CInt(a(245)) <> a(245) Then GoTo 2500:
a(244) = (a(250) - a(252) + a(254) + a(256)) / 2:
If a(244) < m1 Or a(244) > m2 Or CInt(a(244)) <> a(244) Then GoTo 2500:
a(243) = (-a(250) + a(252) + 2 * a(253) + a(254) - a(256)) / 2:
If a(243) < m1 Or a(243) > m2 Or CInt(a(243)) <> a(243) Then GoTo 2500:
a(242) = (-a(250) + a(252) + a(254) + a(256)) / 2:
If a(242) < m1 Or a(242) > m2 Or CInt(a(242)) <> a(242) Then GoTo 2500:
a(241) = (a(250) - a(252) - a(254) + 2 * a(255) + a(256)) / 2:
If a(241) < m1 Or a(241) > m2 Or CInt(a(241)) <> a(241) Then GoTo 2500:
m11 = 241: m21 = 256: GoSub 2700: If fl1 = 0 Then GoTo 2500 'Check row 1
For j240 = m1 To m2 'a(240)
a(240) = j240
a(239) = s1 / 4 - a(240) - a(255) - a(256): If a(239) < m1 Or a(239) > m2 Then GoTo 2400:
a(238) = a(240) - a(254) + a(256): If a(238) < m1 Or a(238) > m2 Then GoTo 2400:
a(237) = s1 / 4 - a(240) - a(253) - a(256): If a(237) < m1 Or a(237) > m2 Then GoTo 2400:
a(236) = a(240) - a(252) + a(256): If a(236) < m1 Or a(236) > m2 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:
a(234) = a(240) - a(250) + a(256): If a(234) < m1 Or a(234) > m2 Then GoTo 2400:
a(233) = -a(240) + a(250) + a(255): If a(233) < m1 Or a(233) > m2 Then GoTo 2400:
a(232) = (2 * a(240) - a(250) - a(252) - a(254) + 3 * a(256)) / 2:
If a(232) < m1 Or a(232) > m2 Or CInt(a(232)) <> a(232) Then GoTo 2400:
a(231) = (-2 * a(240) + a(250) + a(252) + a(254) + 2 * a(255) - a(256)) / 2:
If a(231) < m1 Or a(231) > m2 Or CInt(a(231)) <> a(231) Then GoTo 2400:
a(230) = (2 * a(240) - a(250) - a(252) + a(254) + a(256)) / 2:
If a(230) < m1 Or a(230) > m2 Or CInt(a(230)) <> a(230) Then GoTo 2400:
a(229) = (-2 * a(240) + a(250) + a(252) + 2 * a(253) + a(254) - a(256)) / 2:
If a(229) < m1 Or a(229) > m2 Or CInt(a(229)) <> a(229) Then GoTo 2400:
a(228) = (2 * a(240) - a(250) + a(252) - a(254) + a(256)) / 2:
If a(228) < m1 Or a(228) > m2 Or CInt(a(228)) <> a(228) Then GoTo 2400:
a(227) = (s1 / 2 - 2 * a(240) + a(250) - a(252) - 2 * a(253) - a(254) - a(256)) / 2:
If a(227) < m1 Or a(227) > m2 Or CInt(a(227)) <> a(227) Then GoTo 2400:
a(226) = (2 * a(240) + a(250) - a(252) - a(254) + a(256)) / 2:
If a(226) < m1 Or a(226) > m2 Or CInt(a(226)) <> a(226) Then GoTo 2400:
a(225) = (s1 / 2 - 2 * a(240) - a(250) + a(252) + a(254) - 2 * a(255) - 3 * a(256)) / 2:
If a(225) < m1 Or a(225) > m2 Or CInt(a(225)) <> a(225) 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:
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:
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:
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:
a(216) = (2 * a(224) + a(250) + a(252) + a(254) - 3 * a(256)) / 2:
If a(216) < m1 Or a(216) > m2 Or CInt(a(216)) <> a(216) Then GoTo 2240:
a(215) = (s1 / 2 - 2 * a(224) - a(250) - a(252) - a(254) - 2 * a(255) + a(256)) / 2:
If a(215) < m1 Or a(215) > m2 Or CInt(a(215)) <> a(215) Then GoTo 2240:
a(214) = (2 * a(224) + a(250) + a(252) - a(254) - a(256)) / 2:
If a(214) < m1 Or a(214) > m2 Or CInt(a(214)) <> a(214) Then GoTo 2240:
a(213) = (s1 / 2 - 2 * a(224) - a(250) - a(252) - 2 * a(253) - a(254) + a(256)) / 2:
If a(213) < m1 Or a(213) > m2 Or CInt(a(213)) <> a(213) Then GoTo 2240:
a(212) = (2 * a(224) + a(250) - a(252) + a(254) - a(256)) / 2:
If a(212) < m1 Or a(212) > m2 Or CInt(a(212)) <> a(212) Then GoTo 2240:
a(211) = (-2 * a(224) - a(250) + a(252) + 2 * a(253) + a(254) + a(256)) / 2:
If a(211) < m1 Or a(211) > m2 Or CInt(a(211)) <> a(211) Then GoTo 2240:
a(210) = (2 * a(224) - a(250) + a(252) + a(254) - a(256)) / 2:
If a(210) < m1 Or a(210) > m2 Or CInt(a(210)) <> a(210) Then GoTo 2240:
a(209) = (-2 * a(224) + a(250) - a(252) - a(254) + 2 * a(255) + 3 * a(256)) / 2:
If a(209) < m1 Or a(209) > m2 Or CInt(a(209)) <> a(209) 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
a(207) = s1 / 4 - a(208) - a(255) - a(256): If a(207) < m1 Or a(207) > m2 Then GoTo 2080:
a(206) = a(208) - a(254) + a(256): If a(206) < m1 Or a(206) > m2 Then GoTo 2080:
a(205) = s1 / 4 - a(208) - a(253) - a(256): If a(205) < m1 Or a(205) > m2 Then GoTo 2080:
a(204) = a(208) - a(252) + a(256): If a(204) < m1 Or a(204) > m2 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:
a(202) = a(208) - a(250) + a(256): If a(202) < m1 Or a(202) > m2 Then GoTo 2080:
a(201) = -a(208) + a(250) + a(255): If a(201) < m1 Or a(201) > m2 Then GoTo 2080:
a(200) = (2 * a(208) - a(250) - a(252) - a(254) + 3 * a(256)) / 2:
If a(200) < m1 Or a(200) > m2 Or CInt(a(200)) <> a(200) Then GoTo 2080:
a(199) = (-2 * a(208) + a(250) + a(252) + a(254) + 2 * a(255) - a(256)) / 2:
If a(199) < m1 Or a(199) > m2 Or CInt(a(199)) <> a(199) Then GoTo 2080:
a(198) = (2 * a(208) - a(250) - a(252) + a(254) + a(256)) / 2:
If a(198) < m1 Or a(198) > m2 Or CInt(a(198)) <> a(198) Then GoTo 2080:
a(197) = (-2 * a(208) + a(250) + a(252) + 2 * a(253) + a(254) - a(256)) / 2:
If a(197) < m1 Or a(197) > m2 Or CInt(a(197)) <> a(197) Then GoTo 2080:
a(196) = (2 * a(208) - a(250) + a(252) - a(254) + a(256)) / 2:
If a(196) < m1 Or a(196) > m2 Or CInt(a(196)) <> a(196) Then GoTo 2080:
a(195) = (s1 / 2 - 2 * a(208) + a(250) - a(252) - 2 * a(253) - a(254) - a(256)) / 2:
If a(195) < m1 Or a(195) > m2 Or CInt(a(195)) <> a(195) Then GoTo 2080:
a(194) = (2 * a(208) + a(250) - a(252) - a(254) + a(256)) / 2:
If a(194) < m1 Or a(194) > m2 Or CInt(a(194)) <> a(194) Then GoTo 2080:
a(193) = (s1 / 2 - 2 * a(208) - a(250) + a(252) + a(254) - 2 * a(255) - 3 * a(256)) / 2:
If a(193) < m1 Or a(193) > m2 Or CInt(a(193)) <> a(193) 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:
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:
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:
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:
a(184) = (2 * a(192) + a(250) + a(252) + a(254) - 3 * a(256)) / 2:
If a(184) < m1 Or a(184) > m2 Or CInt(a(184)) <> a(184) Then GoTo 1920:
a(183) = (s1 / 2 - 2 * a(192) - a(250) - a(252) - a(254) - 2 * a(255) + a(256)) / 2:
If a(183) < m1 Or a(183) > m2 Or CInt(a(183)) <> a(183) Then GoTo 1920:
a(182) = (2 * a(192) + a(250) + a(252) - a(254) - a(256)) / 2:
If a(182) < m1 Or a(182) > m2 Or CInt(a(182)) <> a(182) Then GoTo 1920:
a(181) = (s1 / 2 - 2 * a(192) - a(250) - a(252) - 2 * a(253) - a(254) + a(256)) / 2:
If a(181) < m1 Or a(181) > m2 Or CInt(a(181)) <> a(181) Then GoTo 1920:
a(180) = (2 * a(192) + a(250) - a(252) + a(254) - a(256)) / 2:
If a(180) < m1 Or a(180) > m2 Or CInt(a(180)) <> a(180) Then GoTo 1920:
a(179) = (-2 * a(192) - a(250) + a(252) + 2 * a(253) + a(254) + a(256)) / 2:
If a(179) < m1 Or a(179) > m2 Or CInt(a(179)) <> a(179) Then GoTo 1920:
a(178) = (2 * a(192) - a(250) + a(252) + a(254) - a(256)) / 2:
If a(178) < m1 Or a(178) > m2 Or CInt(a(178)) <> a(178) Then GoTo 1920:
a(177) = (-2 * a(192) + a(250) - a(252) - a(254) + 2 * a(255) + 3 * a(256)) / 2:
If a(177) < m1 Or a(177) > m2 Or CInt(a(177)) <> a(177) 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:
a(175) = a(192) + a(208) + a(224) - a(255) - a(256): If a(175) < m1 Or a(175) > m2 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:
a(173) = a(192) + a(208) + a(224) - a(253) - a(256): If a(173) < m1 Or a(173) > m2 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:
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:
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:
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:
a(168) = (s1 / 2 - 2 * a(192) - 2 * a(208) - 2 * a(224) - a(250) - a(252) - a(254) + 3 * a(256)) / 2:
If a(168) < m1 Or a(168) > m2 Or CInt(a(168)) <> a(168) Then GoTo 1920:
a(167) = (-s1 / 2 + 2 * a(192) + 2 * a(208) + 2 * a(224) + a(250) + a(252) + a(254) + 2 * a(255) - a(256)) / 2:
If a(167) < m1 Or a(167) > m2 Or CInt(a(167)) <> a(167) Then GoTo 1920:
a(166) = (s1 / 2 - 2 * a(192) - 2 * a(208) - 2 * a(224) - a(250) - a(252) + a(254) + a(256)) / 2:
If a(166) < m1 Or a(166) > m2 Or CInt(a(166)) <> a(166) Then GoTo 1920:
a(165) = (-s1 / 2 + 2 * a(192) + 2 * a(208) + 2 * a(224) + a(250) + a(252) + 2 * a(253) + a(254) - a(256)) / 2:
If a(165) < m1 Or a(165) > m2 Or CInt(a(165)) <> a(165) Then GoTo 1920:
a(164) = (s1 / 2 - 2 * a(192) - 2 * a(208) - 2 * a(224) - a(250) + a(252) - a(254) + a(256)) / 2:
If a(164) < m1 Or a(164) > m2 Or CInt(a(164)) <> a(164) Then GoTo 1920:
a(163) = (2 * a(192) + 2 * a(208) + 2 * a(224) + a(250) - a(252) - 2 * a(253) - a(254) - a(256)) / 2:
If a(163) < m1 Or a(163) > m2 Or CInt(a(163)) <> a(163) Then GoTo 1920:
a(162) = (s1 / 2 - 2 * a(192) - 2 * a(208) - 2 * a(224) + a(250) - a(252) - a(254) + a(256)) / 2:
If a(162) < m1 Or a(162) > m2 Or CInt(a(162)) <> a(162) Then GoTo 1920:
a(161) = (2 * a(192) + 2 * a(208) + 2 * a(224) - a(250) + a(252) + a(254) - 2 * a(255) - 3 * a(256)) / 2:
If a(161) < m1 Or a(161) > m2 Or CInt(a(161)) <> a(161) Then GoTo 1920:
m11 = 161: m21 = 176: GoSub 2700: If fl1 = 0 Then GoTo 1920 'Check row 6
a(160) = s1 / 4 - a(192) - a(224) - a(250) - a(252) - a(254) + 2 * a(256):
If a(160) < m1 Or a(160) > m2 Then GoTo 1920:
a(159) = -s1 / 4 + a(192) + a(224) + a(250) + a(252) + a(254) + a(255) - a(256):
If a(159) < m1 Or a(159) > m2 Then GoTo 1920:
a(158) = s1 / 4 - a(192) - a(224) - a(250) - a(252) + a(256):
If a(158) < m1 Or a(158) > m2 Then GoTo 1920:
a(157) = -s1 / 4 + a(192) + a(224) + a(250) + a(252) + a(253) + a(254) - a(256):
If a(157) < m1 Or a(157) > m2 Then GoTo 1920:
a(156) = s1 / 4 - a(192) - a(224) - a(250) - a(254) + a(256): If a(156) < m1 Or a(156) > m2 Then GoTo 1920:
a(155) = a(192) + a(224) + a(250) - a(253) - a(256): If a(155) < m1 Or a(155) > m2 Then GoTo 1920:
a(154) = s1 / 4 - a(192) - a(224) - a(252) - a(254) + a(256): If a(154) < m1 Or a(154) > m2 Then GoTo 1920:
a(153) = a(192) + a(224) + a(252) + a(254) - a(255) - 2 * a(256): If a(153) < m1 Or a(153) > m2 Then GoTo 1920:
a(152) = (s1 / 2 - 2 * a(192) - 2 * a(224) - a(250) - a(252) - a(254) + a(256)) / 2:
If a(152) < m1 Or a(152) > m2 Or CInt(a(152)) <> a(152) Then GoTo 1920:
a(151) = (2 * a(192) + 2 * a(224) + a(250) + a(252) + a(254) - 2 * a(255) - 3 * a(256)) / 2:
If a(151) < m1 Or a(151) > m2 Or CInt(a(151)) <> a(151) Then GoTo 1920:
a(150) = (s1 / 2 - 2 * a(192) - 2 * a(224) - a(250) - a(252) - 3 * a(254) + 3 * a(256)) / 2:
If a(150) < m1 Or a(150) > m2 Or CInt(a(150)) <> a(150) Then GoTo 1920:
a(149) = (2 * a(192) + 2 * a(224) + a(250) + a(252) - 2 * a(253) + a(254) - 3 * a(256)) / 2:
If a(149) < m1 Or a(149) > m2 Or CInt(a(149)) <> a(149) Then GoTo 1920:
a(148) = (s1 / 2 - 2 * a(192) - 2 * a(224) - a(250) - 3 * a(252) - a(254) + 3 * a(256)) / 2:
If a(148) < m1 Or a(148) > m2 Or CInt(a(148)) <> a(148) Then GoTo 1920:
a(147) = (-s1 / 2 + 2 * a(192) + 2 * a(224) + a(250) + 3 * a(252) + 2 * a(253) + 3 * a(254) - 3 * a(256)) / 2:
If a(147) < m1 Or a(147) > m2 Or CInt(a(147)) <> a(147) Then GoTo 1920:
a(146) = (s1 / 2 - 2 * a(192) - 2 * a(224) - 3 * a(250) - a(252) - a(254) + 3 * a(256)) / 2:
If a(146) < m1 Or a(146) > m2 Or CInt(a(146)) <> a(146) Then GoTo 1920:
a(145) = (-s1 / 2 + 2 * a(192) + 2 * a(224) + 3 * a(250) + a(252) + a(254) + 2 * a(255) - a(256)) / 2:
If a(145) < m1 Or a(145) > m2 Or CInt(a(145)) <> a(145) Then GoTo 1920:
m11 = 145: m21 = 160: GoSub 2700: If fl1 = 0 Then GoTo 1920 'Check row 7
a(144) = a(192) + a(224) - a(240) + a(250) + a(252) + a(254) - 3 * a(256):
If a(144) < m1 Or a(144) > m2 Then GoTo 1920:
a(143) = s1 / 4 - a(192) - a(224) + a(240) - a(250) - a(252) - a(254) - a(255) + 2 * a(256):
If a(143) < m1 Or a(143) > m2 Then GoTo 1920:
a(142) = a(192) + a(224) - a(240) + a(250) + a(252) - 2 * a(256):
If a(142) < m1 Or a(142) > m2 Then GoTo 1920:
a(141) = s1 / 4 - a(192) - a(224) + a(240) - a(250) - a(252) - a(253) - a(254) + 2 * a(256):
If a(141) < m1 Or a(141) > m2 Then GoTo 1920:
a(140) = a(192) + a(224) - a(240) + a(250) + a(254) - 2 * a(256): If a(140) < m1 Or a(140) > m2 Then GoTo 1920:
a(139) = -a(192) - a(224) + a(240) - a(250) + a(253) + 2 * a(256): If a(139) < m1 Or a(139) > m2 Then GoTo 1920:
a(138) = a(192) + a(224) - a(240) + a(252) + a(254) - 2 * a(256): If a(138) < m1 Or a(138) > m2 Then GoTo 1920:
a(137) = -a(192) - a(224) + a(240) - a(252) - a(254) + a(255) + 3 * a(256):
If a(137) < m1 Or a(137) > m2 Then GoTo 1920:
a(136) = (2 * a(192) + 2 * a(224) - 2 * a(240) + a(250) + a(252) + a(254) - 3 * a(256)) / 2:
If a(136) < m1 Or a(136) > m2 Or CInt(a(136)) <> a(136) Then GoTo 1920:
a(135) = (-2 * a(192) - 2 * a(224) + 2 * a(240) - a(250) - a(252) - a(254) + 2 * a(255) + 5 * a(256)) / 2:
If a(135) < m1 Or a(135) > m2 Or CInt(a(135)) <> a(135) Then GoTo 1920:
a(134) = (2 * a(192) + 2 * a(224) - 2 * a(240) + a(250) + a(252) + 3 * a(254) - 5 * a(256)) / 2:
If a(134) < m1 Or a(134) > m2 Or CInt(a(134)) <> a(134) Then GoTo 1920:
a(133) = (-2 * a(192) - 2 * a(224) + 2 * a(240) - a(250) - a(252) + 2 * a(253) - a(254) + 5 * a(256)) / 2:
If a(133) < m1 Or a(133) > m2 Or CInt(a(133)) <> a(133) Then GoTo 1920:
a(132) = (2 * a(192) + 2 * a(224) - 2 * a(240) + a(250) + 3 * a(252) + a(254) - 5 * a(256)) / 2:
If a(132) < m1 Or a(132) > m2 Or CInt(a(132)) <> a(132) Then GoTo 1920:
a(131) = (s1 / 2 - 2 * a(192) - 2 * a(224) + 2 * a(240) - a(250) - 3 * a(252) - 2 * a(253) - 3*a(254) + 5*a(256)) / 2:
If a(131) < m1 Or a(131) > m2 Or CInt(a(131)) <> a(131) Then GoTo 1920:
a(130) = (2 * a(192) + 2 * a(224) - 2 * a(240) + 3 * a(250) + a(252) + a(254) - 5 * a(256)) / 2:
If a(130) < m1 Or a(130) > m2 Or CInt(a(130)) <> a(130) Then GoTo 1920:
a(129) = (s1 / 2 - 2 * a(192) - 2 * a(224) + 2 * a(240) - 3 * a(250) - a(252) - a(254) - 2 * a(255) + 3 * a(256)) / 2:
If a(129) < m1 Or a(129) > m2 Or CInt(a(129)) <> a(129) Then GoTo 1920:
m11 = 129: m21 = 144: GoSub 2700: If fl1 = 0 Then GoTo 1920 'Check row 8
GoSub 3000 'Complete Sem-Latin Square
GoSub 2750: If fl1 = 0 Then GoTo 1920 'Check diagonal 1, 2
' Calculate c() = 16 * a2() + b2() + 1
Erase a2
For i1 = 1 To 256: a2(i1) = a(i1): Next i1
GoSub 1500: If fl1 = 0 Then GoTo 1920
n9 = n9 + 1 'Total
' GoSub 2600 'Print results (Lines)
' GoSub 2650 'Print results (Squares)
Cells(2, 1).Value = n9 'Counting
1920 Next j192
2080 Next j208
2240 Next j224
2400 Next j240
2500 Next j250
2520 Next j252
2530 Next j253
2540 Next j254
2550 Next j255
2560 Next j256
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
y = MsgBox(t10, 0, "Routine Franklin16b")
End
' Complete Semi-Latin Squares
3000
a(113) = p1 - a(249): a(114) = p1 - a(250): a(115) = p1 - a(251): a(116) = p1 - a(252): 'Row 9
a(117) = p1 - a(253): a(118) = p1 - a(254): a(119) = p1 - a(255): a(120) = p1 - a(256):
a(121) = p1 - a(241): a(122) = p1 - a(242): a(123) = p1 - a(243): a(124) = p1 - a(244):
a(125) = p1 - a(245): a(126) = p1 - a(246): a(127) = p1 - a(247): a(128) = p1 - a(248):
a(97) = p1 - a(233): a(98) = p1 - a(234): a(99) = p1 - a(235): a(100) = p1 - a(236): 'Row 10
a(101) = p1 - a(237): a(102) = p1 - a(238): a(103) = p1 - a(239): a(104) = p1 - a(240):
a(105) = p1 - a(225): a(106) = p1 - a(226): a(107) = p1 - a(227): a(108) = p1 - a(228):
a(109) = p1 - a(229): a(110) = p1 - a(230): a(111) = p1 - a(231): a(112) = p1 - a(232):
a(81) = p1 - a(217): a(82) = p1 - a(218): a(83) = p1 - a(219): a(84) = p1 - a(220): 'Row 11
a(85) = p1 - a(221): a(86) = p1 - a(222): a(87) = p1 - a(223): a(88) = p1 - a(224):
a(89) = p1 - a(209): a(90) = p1 - a(210): a(91) = p1 - a(211): a(92) = p1 - a(212):
a(93) = p1 - a(213): a(94) = p1 - a(214): a(95) = p1 - a(215): a(96) = p1 - a(216):
a(65) = p1 - a(201): a(66) = p1 - a(202): a(67) = p1 - a(203): a(68) = p1 - a(204): 'Row 12
a(69) = p1 - a(205): a(70) = p1 - a(206): a(71) = p1 - a(207): a(72) = p1 - a(208):
a(73) = p1 - a(193): a(74) = p1 - a(194): a(75) = p1 - a(195): a(76) = p1 - a(196):
a(77) = p1 - a(197): a(78) = p1 - a(198): a(79) = p1 - a(199): a(80) = p1 - a(200):
a(49) = p1 - a(185): a(50) = p1 - a(186): a(51) = p1 - a(187): a(52) = p1 - a(188): 'Row 13
a(53) = p1 - a(189): a(54) = p1 - a(190): a(55) = p1 - a(191): a(56) = p1 - a(192):
a(57) = p1 - a(177): a(58) = p1 - a(178): a(59) = p1 - a(179): a(60) = p1 - a(180):
a(61) = p1 - a(181): a(62) = p1 - a(182): a(63) = p1 - a(183): a(64) = p1 - a(184):
a(33) = p1 - a(169): a(34) = p1 - a(170): a(35) = p1 - a(171): a(36) = p1 - a(172): 'Row 14
a(37) = p1 - a(173): a(38) = p1 - a(174): a(39) = p1 - a(175): a(40) = p1 - a(176):
a(41) = p1 - a(161): a(42) = p1 - a(162): a(43) = p1 - a(163): a(44) = p1 - a(164):
a(45) = p1 - a(165): a(46) = p1 - a(166): a(47) = p1 - a(167): a(48) = p1 - a(168):
a(17) = p1 - a(153): a(18) = p1 - a(154): a(19) = p1 - a(155): a(20) = p1 - a(156): 'Row 15
a(21) = p1 - a(157): a(22) = p1 - a(158): a(23) = p1 - a(159): a(24) = p1 - a(160):
a(25) = p1 - a(145): a(26) = p1 - a(146): a(27) = p1 - a(147): a(28) = p1 - a(148):
a(29) = p1 - a(149): a(30) = p1 - a(150): a(31) = p1 - a(151): a(32) = p1 - a(152):
a(1) = p1 - a(137): a(2) = p1 - a(138): a(3) = p1 - a(139): a(4) = p1 - a(140): 'Row 16
a(5) = p1 - a(141): a(6) = p1 - a(142): a(7) = p1 - a(143): a(8) = p1 - a(144):
a(9) = p1 - a(129): a(10) = p1 - a(130): a(11) = p1 - a(131): a(12) = p1 - a(132):
a(13) = p1 - a(133): a(14) = p1 - a(134): a(15) = p1 - a(135): a(16) = p1 - a(136):
Return
' Construct Pan Magic, Compact, Complete Squares
1500 fl1 = 1
' Transpose a2()
b2(1) = a2(1): b2(2) = a2(17): b2(3) = a2(33): b2(4) = a2(49): b2(5) = a2(65): b2(6) = a2(81):
b2(7) = a2(97): b2(8) = a2(113): b2(9) = a2(129): b2(10) = a2(145): b2(11) = a2(161): b2(12) = a2(177):
b2(13) = a2(193): b2(14) = a2(209): b2(15) = a2(225): b2(16) = a2(241):
b2(17) = a2(2): b2(18) = a2(18): b2(19) = a2(34): b2(20) = a2(50): b2(21) = a2(66): b2(22) = a2(82):
b2(23) = a2(98): b2(24) = a2(114): b2(25) = a2(130): b2(26) = a2(146): b2(27) = a2(162): b2(28) = a2(178):
b2(29) = a2(194): b2(30) = a2(210): b2(31) = a2(226): b2(32) = a2(242):
b2(33) = a2(3): b2(34) = a2(19): b2(35) = a2(35): b2(36) = a2(51): b2(37) = a2(67): b2(38) = a2(83):
b2(39) = a2(99): b2(40) = a2(115): b2(41) = a2(131): b2(42) = a2(147): b2(43) = a2(163): b2(44) = a2(179):
b2(45) = a2(195): b2(46) = a2(211): b2(47) = a2(227): b2(48) = a2(243):
b2(49) = a2(4): b2(50) = a2(20): b2(51) = a2(36): b2(52) = a2(52): b2(53) = a2(68): b2(54) = a2(84):
b2(55) = a2(100): b2(56) = a2(116): b2(57) = a2(132): b2(58) = a2(148): b2(59) = a2(164): b2(60) = a2(180):
b2(61) = a2(196): b2(62) = a2(212): b2(63) = a2(228): b2(64) = a2(244):
b2(65) = a2(5): b2(66) = a2(21): b2(67) = a2(37): b2(68) = a2(53): b2(69) = a2(69): b2(70) = a2(85):
b2(71) = a2(101): b2(72) = a2(117): b2(73) = a2(133): b2(74) = a2(149): b2(75) = a2(165): b2(76) = a2(181):
b2(77) = a2(197): b2(78) = a2(213): b2(79) = a2(229): b2(80) = a2(245):
b2(81) = a2(6): b2(82) = a2(22): b2(83) = a2(38): b2(84) = a2(54): b2(85) = a2(70): b2(86) = a2(86):
b2(87) = a2(102): b2(88) = a2(118): b2(89) = a2(134): b2(90) = a2(150): b2(91) = a2(166): b2(92) = a2(182):
b2(93) = a2(198): b2(94) = a2(214): b2(95) = a2(230): b2(96) = a2(246):
b2(97) = a2(7): b2(98) = a2(23): b2(99) = a2(39): b2(100) = a2(55): b2(101) = a2(71): b2(102) = a2(87):
b2(103) = a2(103): b2(104) = a2(119): b2(105) = a2(135): b2(106) = a2(151): b2(107) = a2(167): b2(108) = a2(183):
b2(109) = a2(199): b2(110) = a2(215): b2(111) = a2(231): b2(112) = a2(247):
b2(113) = a2(8): b2(114) = a2(24): b2(115) = a2(40): b2(116) = a2(56): b2(117) = a2(72): b2(118) = a2(88):
b2(119) = a2(104): b2(120) = a2(120): b2(121) = a2(136): b2(122) = a2(152): b2(123) = a2(168): b2(124) = a2(184):
b2(125) = a2(200): b2(126) = a2(216): b2(127) = a2(232): b2(128) = a2(248):
b2(129) = a2(9): b2(130) = a2(25): b2(131) = a2(41): b2(132) = a2(57): b2(133) = a2(73): b2(134) = a2(89):
b2(135) = a2(105): b2(136) = a2(121): b2(137) = a2(137): b2(138) = a2(153): b2(139) = a2(169): b2(140) = a2(185):
b2(141) = a2(201): b2(142) = a2(217): b2(143) = a2(233): b2(144) = a2(249):
b2(145) = a2(10): b2(146) = a2(26): b2(147) = a2(42): b2(148) = a2(58): b2(149) = a2(74): b2(150) = a2(90):
b2(151) = a2(106): b2(152) = a2(122): b2(153) = a2(138): b2(154) = a2(154): b2(155) = a2(170): b2(156) = a2(186):
b2(157) = a2(202): b2(158) = a2(218): b2(159) = a2(234): b2(160) = a2(250):
b2(161) = a2(11): b2(162) = a2(27): b2(163) = a2(43): b2(164) = a2(59): b2(165) = a2(75): b2(166) = a2(91):
b2(167) = a2(107): b2(168) = a2(123): b2(169) = a2(139): b2(170) = a2(155): b2(171) = a2(171): b2(172) = a2(187):
b2(173) = a2(203): b2(174) = a2(219): b2(175) = a2(235): b2(176) = a2(251):
b2(177) = a2(12): b2(178) = a2(28): b2(179) = a2(44): b2(180) = a2(60): b2(181) = a2(76): b2(182) = a2(92):
b2(183) = a2(108): b2(184) = a2(124): b2(185) = a2(140): b2(186) = a2(156): b2(187) = a2(172): b2(188) = a2(188):
b2(189) = a2(204): b2(190) = a2(220): b2(191) = a2(236): b2(192) = a2(252):
b2(193) = a2(13): b2(194) = a2(29): b2(195) = a2(45): b2(196) = a2(61): b2(197) = a2(77): b2(198) = a2(93):
b2(199) = a2(109): b2(200) = a2(125): b2(201) = a2(141): b2(202) = a2(157): b2(203) = a2(173): b2(204) = a2(189):
b2(205) = a2(205): b2(206) = a2(221): b2(207) = a2(237): b2(208) = a2(253):
b2(209) = a2(14): b2(210) = a2(30): b2(211) = a2(46): b2(212) = a2(62): b2(213) = a2(78): b2(214) = a2(94):
b2(215) = a2(110): b2(216) = a2(126): b2(217) = a2(142): b2(218) = a2(158): b2(219) = a2(174): b2(220) = a2(190):
b2(221) = a2(206): b2(222) = a2(222): b2(223) = a2(238): b2(224) = a2(254):
b2(225) = a2(15): b2(226) = a2(31): b2(227) = a2(47): b2(228) = a2(63): b2(229) = a2(79): b2(230) = a2(95):
b2(231) = a2(111): b2(232) = a2(127): b2(233) = a2(143): b2(234) = a2(159): b2(235) = a2(175): b2(236) = a2(191):
b2(237) = a2(207): b2(238) = a2(223): b2(239) = a2(239): b2(240) = a2(255):
b2(241) = a2(16): b2(242) = a2(32): b2(243) = a2(48): b2(244) = a2(64): b2(245) = a2(80): b2(246) = a2(96):
b2(247) = a2(112): b2(248) = a2(128): b2(249) = a2(144): b2(250) = a2(160): b2(251) = a2(176): b2(252) = a2(192):
b2(253) = a2(208): b2(254) = a2(224): b2(255) = a2(240): b2(256) = a2(256):
Erase C
For i1 = 1 To 256
C(i1) = 16 * a2(i1) + b2(i1) + 1
Next i1
fl1 = 1: n20 = 0
For j1 = 1 To 256
a20 = C(j1):
For j2 = (1 + j1) To 256
If a20 = C(j2) Then fl1 = 0: Return
Next j2
Next j1
Return
' Print Results (lines)
2600
For i1 = 1 To 256
Cells(n9, i1).Value = a(i1)
Next i1
Cells(n9, 257).Value = n9
Cells(1, 259).Value = n9
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 = C(i3) ''a(i3)
Next i2
Next i1
Return
' Check Row i (i = 1 ... 16)
2700 fl1 = 1
For i1 = m11 To m21: b(i1 - m11 + 1) = a(i1): Next i1
For j1 = 1 To 16
a20 = b(j1):
For j2 = (1 + j1) To 16
If a20 = b(j2) Then fl1 = 0: Return
Next j2
Next j1
Return
' Check Diagonals 1, 2
2750 fl1 = 1
i2 = 1
For i1 = 1 To 16:
b(i1) = a(i2): i2 = i2 + 17
Next i1
For j1 = 1 To 16
a20 = b(j1):
For j2 = (1 + j1) To 16
If a20 = b(j2) Then fl1 = 0: Return
Next j2
Next j1
i2 = 16
For i1 = 1 To 16:
b(i1) = a(i2): i2 = i2 + 15
Next i1
For j1 = 1 To 16
a20 = b(j1):
For j2 = (1 + j1) To 16
If a20 = b(j2) Then fl1 = 0: Return
Next j2
Next j1
Return
End Sub