Vorige Pagina About the Author

' Generates Ultra Magic (Latin Diagonal) Squares Order 13

' Tested with Office 365 under Windows 10

Sub UltraLat13()

Dim a(169), b(13), c(169)
Dim a2(13, 13), b2(13, 13), c2(13, 13)
Dim nP(38), s(152)

y = MsgBox("Blocked", vbInformation, "UltraLat13")
End

Sheets("Klad1").Select

s1 = 78: k1 = 1: k2 = 1
m1 = 1: m2 = 13

For j169 = m1 To m2
a(169) = j169 - 1

a(2) = a(169)
a(168) = 2 * s1 / 13 - a(169)

a(1) = a(168)
a(8) = 3 * s1 / 13 - a(168) - a(169)

a(162) = 3 * s1 / 13 - a(168) - a(169)
If a(162) < 0 Or a(162) > 12 Then GoTo 1690
If a(162) = a(168) Or a(162) = a(169) Then GoTo 1690

For j167 = m1 To m2
a(167) = j167 - 1
If a(167) = a(162) Or a(167) = a(168) Or a(167) = a(169) Then GoTo 1670

a(3) = 2 * s1 / 13 - a(167)
a(13) = a(167)

a(157) = 2 * s1 / 13 - a(167)
If a(157) = a(162) Or a(157) = a(167) Or a(157) = a(168) Or a(157) = a(169) Then GoTo 1670

For j166 = m1 To m2
a(166) = j166 - 1
If a(166) = a(157) Or a(166) = a(162) Or a(166) = a(167) Or a(166) = a(168) Or a(166) = a(169) Then GoTo 1660

a(4) = 2 * s1 / 13 - a(166)
a(12) = a(166)

a(158) = 2 * s1 / 13 - a(166)
If a(158) = a(157) Or a(158) = a(162) Or a(158) = a(166) Or a(158) = a(167) Or a(158) = a(168) Or a(158) = a(169) Then GoTo 1660

For j165 = m1 To m2
a(165) = j165 - 1
If a(165) = a(157) Or a(165) = a(162) Or a(165) = a(166) Or a(165) = a(167) Or a(165) = a(168) Or a(165) = a(169) Then GoTo 1650
If a(165) = a(158) Then GoTo 1650

a(5) = 2 * s1 / 13 - a(165)
a(11) = a(165)

a(159) = 2 * s1 / 13 - a(165)
If a(159) = a(157) Or a(159) = a(162) Or a(159) = a(166) Or a(159) = a(167) Or a(159) = a(168) Or a(159) = a(169) Then GoTo 1650
If a(159) = a(158) Or a(159) = a(165) Then GoTo 1650

For j164 = m1 To m2
a(164) = j164 - 1
If a(164) = a(157) Or a(164) = a(162) Or a(164) = a(166) Or a(164) = a(167) Or a(164) = a(168) Or a(164) = a(169) Then GoTo 1640
If a(164) = a(158) Or a(164) = a(159) Or a(164) = a(165) Then GoTo 1640

a(6) = 2 * s1 / 13 - a(164)
a(10) = a(164)

a(160) = 2 * s1 / 13 - a(164)
If a(160) = a(157) Or a(160) = a(162) Or a(160) = a(166) Or a(160) = a(167) Or a(160) = a(168) Or a(160) = a(169) Then GoTo 1640
If a(160) = a(158) Or a(160) = a(159) Or a(160) = a(164) Or a(160) = a(165) Then GoTo 1640

For j163 = m1 To m2
a(163) = j163 - 1

a(7) = 2 * s1 / 13 - a(163)
a(9) = a(163)
a(161) = 2 * s1 / 13 - a(163)


        GoSub 900: If fl1 = 0 Then GoTo 1630    'Check    Latin Row
        GoSub 500                               'Complete Latin Square
        GoSub 300                               'Complete Ultra Magic Square

        GoSub 700: If fl1 = 0 Then GoTo 1630    'Check Magic Patterns (General)

        n9 = n9 + 1: GoSub 600                  'Print Paterns
''      n9 = n9 + 1: GoSub 650                  'Print Squares
''      n9 = n9 + 1: Cells(1, 1).Value = n9     'Counting

1630 Next j163
1640 Next j164
1650 Next j165
1660 Next j166
1670 Next j167
1690 Next j169

End

'   Complete square

500

a(14) = a(12):  a(15) = a(13):  a(16) = a(1):   a(17) = a(2):   a(18) = a(3):   a(19) = a(4):   a(20) = a(5):
a(21) = a(6):   a(22) = a(7):   a(23) = a(8):   a(24) = a(9):   a(25) = a(10):  a(26) = a(11):
a(27) = a(25):  a(28) = a(26):  a(29) = a(14):  a(30) = a(15):  a(31) = a(16):  a(32) = a(17): a(33) = a(18):
a(34) = a(19):  a(35) = a(20):  a(36) = a(21):  a(37) = a(22):  a(38) = a(23):  a(39) = a(24):
a(40) = a(38):  a(41) = a(39):  a(42) = a(27):  a(43) = a(28):  a(44) = a(29):  a(45) = a(30): a(46) = a(31):
a(47) = a(32):  a(48) = a(33):  a(49) = a(34):  a(50) = a(35):  a(51) = a(36):  a(52) = a(37):
a(53) = a(51):  a(54) = a(52):  a(55) = a(40):  a(56) = a(41):  a(57) = a(42):  a(58) = a(43):  a(59) = a(44):
a(60) = a(45):  a(61) = a(46):  a(62) = a(47):  a(63) = a(48):  a(64) = a(49):  a(65) = a(50):
a(66) = a(64):  a(67) = a(65):  a(68) = a(53):  a(69) = a(54):  a(70) = a(55):  a(71) = a(56):  a(72) = a(57):
a(73) = a(58):  a(74) = a(59):  a(75) = a(60):  a(76) = a(61):  a(77) = a(62):  a(78) = a(63):
a(79) = a(77):  a(80) = a(78):  a(81) = a(66):  a(82) = a(67):  a(83) = a(68):  a(84) = a(69):  a(85) = a(70):
a(86) = a(71):  a(87) = a(72):  a(88) = a(73):  a(89) = a(74):  a(90) = a(75):  a(91) = a(76):
a(92) = a(90):  a(93) = a(91):  a(94) = a(79):  a(95) = a(80):  a(96) = a(81):  a(97) = a(82):  a(98) = a(83):
a(99) = a(84):  a(100) = a(85): a(101) = a(86): a(102) = a(87): a(103) = a(88): a(104) = a(89):
a(105) = a(103): a(106) = a(104): a(107) = a(92):  a(108) = a(93):  a(109) = a(94): a(110) = a(95): a(111) = a(96):
a(112) = a(97):  a(113) = a(98):  a(114) = a(99):  a(115) = a(100): a(116) = a(101): a(117) = a(102):
a(118) = a(116): a(119) = a(117): a(120) = a(105): a(121) = a(106): a(122) = a(107): a(123) = a(108): a(124) = a(109):
a(125) = a(110): a(126) = a(111): a(127) = a(112): a(128) = a(113): a(129) = a(114): a(130) = a(115):
a(131) = a(129): a(132) = a(130): a(133) = a(118): a(134) = a(119): a(135) = a(120): a(136) = a(121): a(137) = a(122):
a(138) = a(123): a(139) = a(124): a(140) = a(125): a(141) = a(126): a(142) = a(127): a(143) = a(128):
a(144) = a(142): a(145) = a(143): a(146) = a(131): a(147) = a(132): a(148) = a(133): a(149) = a(134): a(150) = a(135):
a(151) = a(136): a(152) = a(137): a(153) = a(138): a(154) = a(139): a(155) = a(140): a(156) = a(141):
    
Return

'   Calculate and Check Ultra Magic Square

300 fl1 = 1

'   Load a2()

    i3 = 0
    For i1 = 1 To 13
    For i2 = 1 To 13
        i3 = i3 + 1
        a2(i1, i2) = a(i3)
    Next i2
    Next i1

'   Determine Transposed b2()

    For i1 = 1 To 13
    For i2 = 1 To 13
        b2(i1, i2) = a2(i2, i1)
    Next i2
    Next i1

'   Calculate Ultra Magic Square c2(), c()

    i3 = 0
    For i1 = 1 To 13
    For i2 = 1 To 13
        c2(i1, i2) = a2(i1, i2) + 13 * b2(i1, i2) + 1
        i3 = i3 + 1: c(i3) = c2(i1, i2)
    Next i2
    Next i1

'   Check Identical Numbers

    For i1 = 1 To 169
       c20 = c(i1)
       For i2 = (1 + i1) To 169
           If c20 = c(i2) Then fl1 = 0: Return
       Next i2
    Next i1

    Return

'   Exclude solutions with identical numbers in row

900 fl1 = 1
     
    For i1 = 157 To 169
        b(i1 - 156) = a(i1)
    Next i1
    
    For j1 = 1 To 13
       b20 = b(j1)
       For j2 = (1 + j1) To 13
           If b20 = b(j2) Then fl1 = 0: Return
       Next j2
    Next j1

    Return

'   Print Patterns

600

    For i1 = 1 To 38
        Cells(n9 + 1, i1) = nP(i1)
    Next i1
    Cells(n9 + 1, 39).Value = nQ4
    Cells(n9 + 1, 40).Value = n9
    
    Cells(1, 42).Value = n9
    Return

'   Print results (squares)

650 n1 = n1 + 1
    If n1 = 2 Then
        n1 = 1: k1 = k1 + 14: k2 = 1
    Else
        If n9 > 1 Then k2 = k2 + 14
    End If
    
    Cells(1, 1).Value = n9
    Cells(k1, k2 + 1).Font.Color = -4165632
    Cells(k1, k2 + 1).Value = n9
    Cells(k1, k2 + 2).Font.Color = -4165632
    Cells(k1, k2 + 2).Value = nQ
     
    Cells(k1, k2 + 3).Value = nStr13
    
    i3 = 0
    For i1 = 1 To 13
        For i2 = 1 To 13
            i3 = i3 + 1
            Cells(k1 + i1, k2 + i2).Value = c(i3) ''a(i3)
        Next i2
    Next i1
    Return

'   Check P01
    
750 fl1 = 1

    s(1) = c(4) + c(17) + c(30) + c(40) + c(41) + c(42) + c(43) + c(44) + c(45) + c(46) + c(56) + c(69) + c(82)              'P01
    s(2) = c(10) + c(23) + c(36) + c(46) + c(47) + c(48) + c(49) + c(50) + c(51) + c(52) + c(62) + c(75) + c(88)
    s(3) = c(82) + c(95) + c(108) + c(118) + c(119) + c(120) + c(121) + c(122) + c(123) + c(124) + c(134) + c(147) + c(160)
    s(4) = c(88) + c(101) + c(114) + c(124) + c(125) + c(126) + c(127) + c(128) + c(129) + c(130) + c(140) + c(153) + c(166)
    
    n13 = 0
    For i1 = 1 To 4
        If s(i1) = 1105 Then n13 = n13 + 1
    Next i1
    
    If n13 < 4 Then fl1 = 0

    Return
    
'   Check Magic Patterns (General)

700 fl1 = 1: nQ = 0: Erase nP, s

s(1) = c(4) + c(17) + c(30) + c(40) + c(41) + c(42) + c(43) + c(44) + c(45) + c(46) + c(56) + c(69) + c(82)   'P01
s(2) = c(10) + c(23) + c(36) + c(46) + c(47) + c(48) + c(49) + c(50) + c(51) + c(52) + c(62) + c(75) + c(88)
s(3) = c(82) + c(95) + c(108) + c(118) + c(119) + c(120) + c(121) + c(122) + c(123) + c(124) + c(134) + c(147) + c(160)
s(4) = c(88) + c(101) + c(114) + c(124) + c(125) + c(126) + c(127) + c(128) + c(129) + c(130) + c(140) + c(153) + c(166)

s(5) = c(17) + c(29) + c(30) + c(31) + c(41) + c(42) + c(43) + c(44) + c(45) + c(55) + c(56) + c(57) + c(69)  'P02
s(6) = c(23) + c(35) + c(36) + c(37) + c(47) + c(48) + c(49) + c(50) + c(51) + c(61) + c(62) + c(63) + c(75)
s(7) = c(95) + c(107) + c(108) + c(109) + c(119) + c(120) + c(121) + c(122) + c(123) + c(133) + c(134) + c(135) + c(147)
s(8) = c(101) + c(113) + c(114) + c(115) + c(125) + c(126) + c(127) + c(128) + c(129) + c(139) + c(140) + c(141) + c(153)

s(9) = c(4) + c(29) + c(30) + c(31) + c(40) + c(42) + c(43) + c(44) + c(46) + c(55) + c(56) + c(57) + c(82)   'P03
s(10) = c(10) + c(35) + c(36) + c(37) + c(46) + c(48) + c(49) + c(50) + c(52) + c(61) + c(62) + c(63) + c(88)
s(11) = c(82) + c(107) + c(108) + c(109) + c(118) + c(120) + c(121) + c(122) + c(124) + c(133) + c(134) + c(135) + c(160)
s(12) = c(88) + c(113) + c(114) + c(115) + c(124) + c(126) + c(127) + c(128) + c(130) + c(139) + c(140) + c(141) + c(166)

s(13) = c(4) + c(17) + c(29) + c(31) + c(40) + c(41) + c(43) + c(45) + c(46) + c(55) + c(57) + c(69) + c(82)  'P04
s(14) = c(10) + c(23) + c(35) + c(37) + c(46) + c(47) + c(49) + c(51) + c(52) + c(61) + c(63) + c(75) + c(88)
s(15) = c(82) + c(95) + c(107) + c(109) + c(118) + c(119) + c(121) + c(123) + c(124) + c(133) + c(135) + c(147) + c(160)
s(16) = c(88) + c(101) + c(113) + c(115) + c(124) + c(125) + c(127) + c(129) + c(130) + c(139) + c(141) + c(153) + c(166)

s(17) = c(15) + c(17) + c(19) + c(30) + c(41) + c(42) + c(43) + c(44) + c(45) + c(56) + c(67) + c(69) + c(71) 'P05
s(18) = c(21) + c(23) + c(25) + c(36) + c(47) + c(48) + c(49) + c(50) + c(51) + c(62) + c(73) + c(75) + c(77)
s(19) = c(93) + c(95) + c(97) + c(108) + c(119) + c(120) + c(121) + c(122) + c(123) + c(134) + c(145) + c(147) + c(149)
s(20) = c(99) + c(101) + c(103) + c(114) + c(125) + c(126) + c(127) + c(128) + c(129) + c(140) + c(151) + c(153) + c(155)

s(21) = c(4) + c(15) + c(19) + c(30) + c(40) + c(42) + c(43) + c(44) + c(46) + c(56) + c(67) + c(71) + c(82)  'P06
s(22) = c(10) + c(21) + c(25) + c(36) + c(46) + c(48) + c(49) + c(50) + c(52) + c(62) + c(73) + c(77) + c(88)
s(23) = c(82) + c(93) + c(97) + c(108) + c(118) + c(120) + c(121) + c(122) + c(124) + c(134) + c(145) + c(149) + c(160)
s(24) = c(88) + c(99) + c(103) + c(114) + c(124) + c(126) + c(127) + c(128) + c(130) + c(140) + c(151) + c(155) + c(166)

s(25) = c(4) + c(15) + c(17) + c(19) + c(40) + c(41) + c(43) + c(45) + c(46) + c(67) + c(69) + c(71) + c(82)  'P07
s(26) = c(10) + c(21) + c(23) + c(25) + c(46) + c(47) + c(49) + c(51) + c(52) + c(73) + c(75) + c(77) + c(88)
s(27) = c(82) + c(93) + c(95) + c(97) + c(118) + c(119) + c(121) + c(123) + c(124) + c(145) + c(147) + c(149) + c(160)
s(28) = c(88) + c(99) + c(101) + c(103) + c(124) + c(125) + c(127) + c(129) + c(130) + c(151) + c(153) + c(155) + c(166)

s(29) = c(15) + c(19) + c(29) + c(30) + c(31) + c(42) + c(43) + c(44) + c(55) + c(56) + c(57) + c(67) + c(71) 'P08
s(30) = c(21) + c(25) + c(35) + c(36) + c(37) + c(48) + c(49) + c(50) + c(61) + c(62) + c(63) + c(73) + c(77)
s(31) = c(93) + c(97) + c(107) + c(108) + c(109) + c(120) + c(121) + c(122) + c(133) + c(134) + c(135) + c(145) + c(149)
s(32) = c(99) + c(103) + c(113) + c(114) + c(115) + c(126) + c(127) + c(128) + c(139) + c(140) + c(141) + c(151) + c(155)

s(33) = c(15) + c(17) + c(19) + c(29) + c(31) + c(41) + c(43) + c(45) + c(55) + c(57) + c(67) + c(69) + c(71) 'P09
s(34) = c(21) + c(23) + c(25) + c(35) + c(37) + c(47) + c(49) + c(51) + c(61) + c(63) + c(73) + c(75) + c(77)
s(35) = c(93) + c(95) + c(97) + c(107) + c(109) + c(119) + c(121) + c(123) + c(133) + c(135) + c(145) + c(147) + c(149)
s(36) = c(99) + c(101) + c(103) + c(113) + c(115) + c(125) + c(127) + c(129) + c(139) + c(141) + c(151) + c(153) + c(155)

s(37) = c(4) + c(15) + c(19) + c(29) + c(31) + c(40) + c(43) + c(46) + c(55) + c(57) + c(67) + c(71) + c(82)  'P10
s(38) = c(10) + c(21) + c(25) + c(35) + c(37) + c(46) + c(49) + c(52) + c(61) + c(63) + c(73) + c(77) + c(88)
s(39) = c(82) + c(93) + c(97) + c(107) + c(109) + c(118) + c(121) + c(124) + c(133) + c(135) + c(145) + c(149) + c(160)
s(40) = c(88) + c(99) + c(103) + c(113) + c(115) + c(124) + c(127) + c(130) + c(139) + c(141) + c(151) + c(155) + c(166)

s(41) = c(1) + c(7) + c(17) + c(30) + c(41) + c(42) + c(43) + c(44) + c(45) + c(56) + c(69) + c(79) + c(85)   'P11
s(42) = c(7) + c(13) + c(23) + c(36) + c(47) + c(48) + c(49) + c(50) + c(51) + c(62) + c(75) + c(85) + c(91)
s(43) = c(79) + c(85) + c(95) + c(108) + c(119) + c(120) + c(121) + c(122) + c(123) + c(134) + c(147) + c(157) + c(163)
s(44) = c(85) + c(91) + c(101) + c(114) + c(125) + c(126) + c(127) + c(128) + c(129) + c(140) + c(153) + c(163) + c(169)

s(45) = c(1) + c(4) + c(7) + c(30) + c(40) + c(42) + c(43) + c(44) + c(46) + c(56) + c(79) + c(82) + c(85)    'P12
s(46) = c(7) + c(10) + c(13) + c(36) + c(46) + c(48) + c(49) + c(50) + c(52) + c(62) + c(85) + c(88) + c(91)
s(47) = c(79) + c(82) + c(85) + c(108) + c(118) + c(120) + c(121) + c(122) + c(124) + c(134) + c(157) + c(160) + c(163)
s(48) = c(85) + c(88) + c(91) + c(114) + c(124) + c(126) + c(127) + c(128) + c(130) + c(140) + c(163) + c(166) + c(169)

s(49) = c(1) + c(4) + c(7) + c(17) + c(40) + c(41) + c(43) + c(45) + c(46) + c(69) + c(79) + c(82) + c(85)    'P13
s(50) = c(7) + c(10) + c(13) + c(23) + c(46) + c(47) + c(49) + c(51) + c(52) + c(75) + c(85) + c(88) + c(91)
s(51) = c(79) + c(82) + c(85) + c(95) + c(118) + c(119) + c(121) + c(123) + c(124) + c(147) + c(157) + c(160) + c(163)
s(52) = c(85) + c(88) + c(91) + c(101) + c(124) + c(125) + c(127) + c(129) + c(130) + c(153) + c(163) + c(166) + c(169)

s(53) = c(1) + c(7) + c(29) + c(30) + c(31) + c(42) + c(43) + c(44) + c(55) + c(56) + c(57) + c(79) + c(85)   'P14
s(54) = c(7) + c(13) + c(35) + c(36) + c(37) + c(48) + c(49) + c(50) + c(61) + c(62) + c(63) + c(85) + c(91)
s(55) = c(79) + c(85) + c(107) + c(108) + c(109) + c(120) + c(121) + c(122) + c(133) + c(134) + c(135) + c(157) + c(163)
s(56) = c(85) + c(91) + c(113) + c(114) + c(115) + c(126) + c(127) + c(128) + c(139) + c(140) + c(141) + c(163) + c(169)

s(57) = c(1) + c(7) + c(17) + c(29) + c(31) + c(41) + c(43) + c(45) + c(55) + c(57) + c(69) + c(79) + c(85)   'P15
s(58) = c(7) + c(13) + c(23) + c(35) + c(37) + c(47) + c(49) + c(51) + c(61) + c(63) + c(75) + c(85) + c(91)
s(59) = c(79) + c(85) + c(95) + c(107) + c(109) + c(119) + c(121) + c(123) + c(133) + c(135) + c(147) + c(157) + c(163)
s(60) = c(85) + c(91) + c(101) + c(113) + c(115) + c(125) + c(127) + c(129) + c(139) + c(141) + c(153) + c(163) + c(169)

s(61) = c(1) + c(4) + c(7) + c(29) + c(31) + c(40) + c(43) + c(46) + c(55) + c(57) + c(79) + c(82) + c(85)    'P16
s(62) = c(7) + c(10) + c(13) + c(35) + c(37) + c(46) + c(49) + c(52) + c(61) + c(63) + c(85) + c(88) + c(91)
s(63) = c(79) + c(82) + c(85) + c(107) + c(109) + c(118) + c(121) + c(124) + c(133) + c(135) + c(157) + c(160) + c(163)
s(64) = c(85) + c(88) + c(91) + c(113) + c(115) + c(124) + c(127) + c(130) + c(139) + c(141) + c(163) + c(166) + c(169)

s(65) = c(1) + c(7) + c(15) + c(19) + c(30) + c(42) + c(43) + c(44) + c(56) + c(67) + c(71) + c(79) + c(85)   'P17
s(66) = c(7) + c(13) + c(21) + c(25) + c(36) + c(48) + c(49) + c(50) + c(62) + c(73) + c(77) + c(85) + c(91)
s(67) = c(79) + c(85) + c(93) + c(97) + c(108) + c(120) + c(121) + c(122) + c(134) + c(145) + c(149) + c(157) + c(163)
s(68) = c(85) + c(91) + c(99) + c(103) + c(114) + c(126) + c(127) + c(128) + c(140) + c(151) + c(155) + c(163) + c(169)

s(69) = c(1) + c(7) + c(15) + c(17) + c(19) + c(41) + c(43) + c(45) + c(67) + c(69) + c(71) + c(79) + c(85)   'P18
s(70) = c(7) + c(13) + c(21) + c(23) + c(25) + c(47) + c(49) + c(51) + c(73) + c(75) + c(77) + c(85) + c(91)
s(71) = c(79) + c(85) + c(93) + c(95) + c(97) + c(119) + c(121) + c(123) + c(145) + c(147) + c(149) + c(157) + c(163)
s(72) = c(85) + c(91) + c(99) + c(101) + c(103) + c(125) + c(127) + c(129) + c(151) + c(153) + c(155) + c(163) + c(169)

s(73) = c(1) + c(4) + c(7) + c(15) + c(19) + c(40) + c(43) + c(46) + c(67) + c(71) + c(79) + c(82) + c(85)    'P19
s(74) = c(7) + c(10) + c(13) + c(21) + c(25) + c(46) + c(49) + c(52) + c(73) + c(77) + c(85) + c(88) + c(91)
s(75) = c(79) + c(82) + c(85) + c(93) + c(97) + c(118) + c(121) + c(124) + c(145) + c(149) + c(157) + c(160) + c(163)
s(76) = c(85) + c(88) + c(91) + c(99) + c(103) + c(124) + c(127) + c(130) + c(151) + c(155) + c(163) + c(166) + c(169)

s(77) = c(1) + c(7) + c(15) + c(19) + c(29) + c(31) + c(43) + c(55) + c(57) + c(67) + c(71) + c(79) + c(85)   'P20
s(78) = c(7) + c(13) + c(21) + c(25) + c(35) + c(37) + c(49) + c(61) + c(63) + c(73) + c(77) + c(85) + c(91)
s(79) = c(79) + c(85) + c(93) + c(97) + c(107) + c(109) + c(121) + c(133) + c(135) + c(145) + c(149) + c(157) + c(163)
s(80) = c(85) + c(91) + c(99) + c(103) + c(113) + c(115) + c(127) + c(139) + c(141) + c(151) + c(155) + c(163) + c(169)

s(81) = c(16) + c(18) + c(28) + c(30) + c(32) + c(42) + c(43) + c(44) + c(54) + c(56) + c(58) + c(68) + c(70) 'P21
s(82) = c(22) + c(24) + c(34) + c(36) + c(38) + c(48) + c(49) + c(50) + c(60) + c(62) + c(64) + c(74) + c(76)
s(83) = c(94) + c(96) + c(106) + c(108) + c(110) + c(120) + c(121) + c(122) + c(132) + c(134) + c(136) + c(146) + c(148)
s(84) = c(100) + c(102) + c(112) + c(114) + c(116) + c(126) + c(127) + c(128) + c(138) + c(140) + c(142) + c(152) + c(154)

s(85) = c(16) + c(17) + c(18) + c(28) + c(32) + c(41) + c(43) + c(45) + c(54) + c(58) + c(68) + c(69) + c(70) 'P22
s(86) = c(22) + c(23) + c(24) + c(34) + c(38) + c(47) + c(49) + c(51) + c(60) + c(64) + c(74) + c(75) + c(76)
s(87) = c(94) + c(95) + c(96) + c(106) + c(110) + c(119) + c(121) + c(123) + c(132) + c(136) + c(146) + c(147) + c(148)
s(88) = c(100) + c(101) + c(102) + c(112) + c(116) + c(125) + c(127) + c(129) + c(138) + c(142) + c(152) + c(153) + c(154)

s(89) = c(4) + c(16) + c(18) + c(28) + c(32) + c(40) + c(43) + c(46) + c(54) + c(58) + c(68) + c(70) + c(82)  'P23
s(90) = c(10) + c(22) + c(24) + c(34) + c(38) + c(46) + c(49) + c(52) + c(60) + c(64) + c(74) + c(76) + c(88)
s(91) = c(82) + c(94) + c(96) + c(106) + c(110) + c(118) + c(121) + c(124) + c(132) + c(136) + c(146) + c(148) + c(160)
s(92) = c(88) + c(100) + c(102) + c(112) + c(116) + c(124) + c(127) + c(130) + c(138) + c(142) + c(152) + c(154) + c(166)

s(93) = c(16) + c(18) + c(28) + c(29) + c(31) + c(32) + c(43) + c(54) + c(55) + c(57) + c(58) + c(68) + c(70) 'P24
s(94) = c(22) + c(24) + c(34) + c(35) + c(37) + c(38) + c(49) + c(60) + c(61) + c(63) + c(64) + c(74) + c(76)
s(95) = c(94) + c(96) + c(106) + c(107) + c(109) + c(110) + c(121) + c(132) + c(133) + c(135) + c(136) + c(146) + c(148)
s(96) = c(100) + c(102) + c(112) + c(113) + c(115) + c(116) + c(127) + c(138) + c(139) + c(141) + c(142) + c(152) + c(154)

s(97) = c(15) + c(16) + c(18) + c(19) + c(28) + c(32) + c(43) + c(54) + c(58) + c(67) + c(68) + c(70) + c(71) 'P25
s(98) = c(21) + c(22) + c(24) + c(25) + c(34) + c(38) + c(49) + c(60) + c(64) + c(73) + c(74) + c(76) + c(77)
s(99) = c(93) + c(94) + c(96) + c(97) + c(106) + c(110) + c(121) + c(132) + c(136) + c(145) + c(146) + c(148) + c(149)
s(100) = c(99) + c(100) + c(102) + c(103) + c(112) + c(116) + c(127) + c(138) + c(142) + c(151) + c(152) + c(154) + c(155)

s(101) = c(1) + c(7) + c(16) + c(18) + c(28) + c(32) + c(43) + c(54) + c(58) + c(68) + c(70) + c(79) + c(85)  'P26
s(102) = c(7) + c(13) + c(22) + c(24) + c(34) + c(38) + c(49) + c(60) + c(64) + c(74) + c(76) + c(85) + c(91)
s(103) = c(79) + c(85) + c(94) + c(96) + c(106) + c(110) + c(121) + c(132) + c(136) + c(146) + c(148) + c(157) + c(163)
s(104) = c(85) + c(91) + c(100) + c(102) + c(112) + c(116) + c(127) + c(138) + c(142) + c(152) + c(154) + c(163) + c(169)

s(105) = c(3) + c(5) + c(27) + c(30) + c(33) + c(42) + c(43) + c(44) + c(53) + c(56) + c(59) + c(81) + c(83)  'P27
s(106) = c(9) + c(11) + c(33) + c(36) + c(39) + c(48) + c(49) + c(50) + c(59) + c(62) + c(65) + c(87) + c(89)
s(107) = c(81) + c(83) + c(105) + c(108) + c(111) + c(120) + c(121) + c(122) + c(131) + c(134) + c(137) + c(159) + c(161)
s(108) = c(87) + c(89) + c(111) + c(114) + c(117) + c(126) + c(127) + c(128) + c(137) + c(140) + c(143) + c(165) + c(167)

s(109) = c(3) + c(5) + c(17) + c(27) + c(33) + c(41) + c(43) + c(45) + c(53) + c(59) + c(69) + c(81) + c(83)  'P28
s(110) = c(9) + c(11) + c(23) + c(33) + c(39) + c(47) + c(49) + c(51) + c(59) + c(65) + c(75) + c(87) + c(89)
s(111) = c(81) + c(83) + c(95) + c(105) + c(111) + c(119) + c(121) + c(123) + c(131) + c(137) + c(147) + c(159) + c(161)
s(112) = c(87) + c(89) + c(101) + c(111) + c(117) + c(125) + c(127) + c(129) + c(137) + c(143) + c(153) + c(165) + c(167)

s(113) = c(3) + c(4) + c(5) + c(27) + c(33) + c(40) + c(43) + c(46) + c(53) + c(59) + c(81) + c(82) + c(83)   'P29
s(114) = c(9) + c(10) + c(11) + c(33) + c(39) + c(46) + c(49) + c(52) + c(59) + c(65) + c(87) + c(88) + c(89)
s(115) = c(81) + c(82) + c(83) + c(105) + c(111) + c(118) + c(121) + c(124) + c(131) + c(137) + c(159) + c(160) + c(161)
s(116) = c(87) + c(88) + c(89) + c(111) + c(117) + c(124) + c(127) + c(130) + c(137) + c(143) + c(165) + c(166) + c(167)

s(117) = c(3) + c(5) + c(27) + c(29) + c(31) + c(33) + c(43) + c(53) + c(55) + c(57) + c(59) + c(81) + c(83)  'P30
s(118) = c(9) + c(11) + c(33) + c(35) + c(37) + c(39) + c(49) + c(59) + c(61) + c(63) + c(65) + c(87) + c(89)
s(119) = c(81) + c(83) + c(105) + c(107) + c(109) + c(111) + c(121) + c(131) + c(133) + c(135) + c(137) + c(159) + c(161)
s(120) = c(87) + c(89) + c(111) + c(113) + c(115) + c(117) + c(127) + c(137) + c(139) + c(141) + c(143) + c(165) + c(167)

s(121) = c(3) + c(5) + c(15) + c(19) + c(27) + c(33) + c(43) + c(53) + c(59) + c(67) + c(71) + c(81) + c(83)  'P31
s(122) = c(9) + c(11) + c(21) + c(25) + c(33) + c(39) + c(49) + c(59) + c(65) + c(73) + c(77) + c(87) + c(89)
s(123) = c(81) + c(83) + c(93) + c(97) + c(105) + c(111) + c(121) + c(131) + c(137) + c(145) + c(149) + c(159) + c(161)
s(124) = c(87) + c(89) + c(99) + c(103) + c(111) + c(117) + c(127) + c(137) + c(143) + c(151) + c(155) + c(165) + c(167)

s(125) = c(1) + c(3) + c(5) + c(7) + c(27) + c(33) + c(43) + c(53) + c(59) + c(79) + c(81) + c(83) + c(85)    'P32
s(126) = c(7) + c(9) + c(11) + c(13) + c(33) + c(39) + c(49) + c(59) + c(65) + c(85) + c(87) + c(89) + c(91)
s(127) = c(79) + c(81) + c(83) + c(85) + c(105) + c(111) + c(121) + c(131) + c(137) + c(157) + c(159) + c(161) + c(163)
s(128) = c(85) + c(87) + c(89) + c(91) + c(111) + c(117) + c(127) + c(137) + c(143) + c(163) + c(165) + c(167) + c(169)

s(129) = c(2) + c(6) + c(14) + c(20) + c(30) + c(42) + c(43) + c(44) + c(56) + c(66) + c(72) + c(80) + c(84)  'P33
s(130) = c(8) + c(12) + c(20) + c(26) + c(36) + c(48) + c(49) + c(50) + c(62) + c(72) + c(78) + c(86) + c(90)
s(131) = c(80) + c(84) + c(92) + c(98) + c(108) + c(120) + c(121) + c(122) + c(134) + c(144) + c(150) + c(158) + c(162)
s(132) = c(86) + c(90) + c(98) + c(104) + c(114) + c(126) + c(127) + c(128) + c(140) + c(150) + c(156) + c(164) + c(168)

s(133) = c(2) + c(6) + c(14) + c(17) + c(20) + c(41) + c(43) + c(45) + c(66) + c(69) + c(72) + c(80) + c(84)  'P34
s(134) = c(8) + c(12) + c(20) + c(23) + c(26) + c(47) + c(49) + c(51) + c(72) + c(75) + c(78) + c(86) + c(90)
s(135) = c(80) + c(84) + c(92) + c(95) + c(98) + c(119) + c(121) + c(123) + c(144) + c(147) + c(150) + c(158) + c(162)
s(136) = c(86) + c(90) + c(98) + c(101) + c(104) + c(125) + c(127) + c(129) + c(150) + c(153) + c(156) + c(164) + c(168)

s(137) = c(2) + c(4) + c(6) + c(14) + c(20) + c(40) + c(43) + c(46) + c(66) + c(72) + c(80) + c(82) + c(84)   'P35
s(138) = c(8) + c(10) + c(12) + c(20) + c(26) + c(46) + c(49) + c(52) + c(72) + c(78) + c(86) + c(88) + c(90)
s(139) = c(80) + c(82) + c(84) + c(92) + c(98) + c(118) + c(121) + c(124) + c(144) + c(150) + c(158) + c(160) + c(162)
s(140) = c(86) + c(88) + c(90) + c(98) + c(104) + c(124) + c(127) + c(130) + c(150) + c(156) + c(164) + c(166) + c(168)

s(141) = c(2) + c(6) + c(14) + c(20) + c(29) + c(31) + c(43) + c(55) + c(57) + c(66) + c(72) + c(80) + c(84)  'P36
s(142) = c(8) + c(12) + c(20) + c(26) + c(35) + c(37) + c(49) + c(61) + c(63) + c(72) + c(78) + c(86) + c(90)
s(143) = c(80) + c(84) + c(92) + c(98) + c(107) + c(109) + c(121) + c(133) + c(135) + c(144) + c(150) + c(158) + c(162)
s(144) = c(86) + c(90) + c(98) + c(104) + c(113) + c(115) + c(127) + c(139) + c(141) + c(150) + c(156) + c(164) + c(168)

s(145) = c(2) + c(6) + c(14) + c(15) + c(19) + c(20) + c(43) + c(66) + c(67) + c(71) + c(72) + c(80) + c(84)  'P37
s(146) = c(8) + c(12) + c(20) + c(21) + c(25) + c(26) + c(49) + c(72) + c(73) + c(77) + c(78) + c(86) + c(90)
s(147) = c(80) + c(84) + c(92) + c(93) + c(97) + c(98) + c(121) + c(144) + c(145) + c(149) + c(150) + c(158) + c(162)
s(148) = c(86) + c(90) + c(98) + c(99) + c(103) + c(104) + c(127) + c(150) + c(151) + c(155) + c(156) + c(164) + c(168)

s(149) = c(1) + c(2) + c(6) + c(7) + c(14) + c(20) + c(43) + c(66) + c(72) + c(79) + c(80) + c(84) + c(85)    'P38
s(150) = c(7) + c(8) + c(12) + c(13) + c(20) + c(26) + c(49) + c(72) + c(78) + c(85) + c(86) + c(90) + c(91)
s(151) = c(79) + c(80) + c(84) + c(85) + c(92) + c(98) + c(121) + c(144) + c(150) + c(157) + c(158) + c(162) + c(163)
s(152) = c(85) + c(86) + c(90) + c(91) + c(98) + c(104) + c(127) + c(150) + c(156) + c(163) + c(164) + c(168) + c(169)

'  Type Patterns

For i1 = 1 To 152

    Select Case i1
    
        Case 1, 2, 3, 4: If s(i1) = 1105 Then nP(1) = nP(1) + 1
        Case 5, 6, 7, 8: If s(i1) = 1105 Then nP(2) = nP(2) + 1
        Case 9, 10, 11, 12: If s(i1) = 1105 Then nP(3) = nP(3) + 1
        Case 13, 14, 15, 16: If s(i1) = 1105 Then nP(4) = nP(4) + 1
        Case 17, 18, 19, 20: If s(i1) = 1105 Then nP(5) = nP(5) + 1
        Case 21, 22, 23, 24: If s(i1) = 1105 Then nP(6) = nP(6) + 1
        Case 25, 26, 27, 28: If s(i1) = 1105 Then nP(7) = nP(7) + 1
        Case 29, 30, 31, 32: If s(i1) = 1105 Then nP(8) = nP(8) + 1
        Case 33, 34, 35, 36: If s(i1) = 1105 Then nP(9) = nP(9) + 1
        Case 37, 38, 39, 40: If s(i1) = 1105 Then nP(10) = nP(10) + 1
        Case 41, 42, 43, 44: If s(i1) = 1105 Then nP(11) = nP(11) + 1
        Case 45, 46, 47, 48: If s(i1) = 1105 Then nP(12) = nP(12) + 1
        Case 49, 50, 51, 52: If s(i1) = 1105 Then nP(13) = nP(13) + 1
        Case 53, 54, 55, 56: If s(i1) = 1105 Then nP(14) = nP(14) + 1
        Case 57, 58, 59, 60: If s(i1) = 1105 Then nP(15) = nP(15) + 1
        Case 61, 62, 63, 64: If s(i1) = 1105 Then nP(16) = nP(16) + 1
        Case 65, 66, 67, 68: If s(i1) = 1105 Then nP(17) = nP(17) + 1
        Case 69, 70, 71, 72: If s(i1) = 1105 Then nP(18) = nP(18) + 1
        Case 73, 74, 75, 76: If s(i1) = 1105 Then nP(19) = nP(19) + 1
        Case 77, 78, 79, 80: If s(i1) = 1105 Then nP(20) = nP(20) + 1
        Case 81, 82, 83, 84: If s(i1) = 1105 Then nP(21) = nP(21) + 1
        Case 85, 86, 87, 88: If s(i1) = 1105 Then nP(22) = nP(22) + 1
        Case 89, 90, 91, 92: If s(i1) = 1105 Then nP(23) = nP(23) + 1
        Case 93, 94, 95, 96: If s(i1) = 1105 Then nP(24) = nP(24) + 1
        Case 97, 98, 99, 100: If s(i1) = 1105 Then nP(25) = nP(25) + 1
        Case 101, 102, 103, 104: If s(i1) = 1105 Then nP(26) = nP(26) + 1
        Case 105, 106, 107, 108: If s(i1) = 1105 Then nP(27) = nP(27) + 1
        Case 109, 110, 111, 112: If s(i1) = 1105 Then nP(28) = nP(28) + 1
        Case 113, 114, 115, 116: If s(i1) = 1105 Then nP(29) = nP(29) + 1
        Case 117, 118, 119, 120: If s(i1) = 1105 Then nP(30) = nP(30) + 1
        Case 121, 122, 123, 124: If s(i1) = 1105 Then nP(31) = nP(31) + 1
        Case 125, 126, 127, 128: If s(i1) = 1105 Then nP(32) = nP(32) + 1
        Case 129, 130, 131, 132: If s(i1) = 1105 Then nP(33) = nP(33) + 1
        Case 133, 134, 135, 136: If s(i1) = 1105 Then nP(34) = nP(34) + 1
        Case 137, 138, 139, 140: If s(i1) = 1105 Then nP(35) = nP(35) + 1
        Case 141, 142, 143, 144: If s(i1) = 1105 Then nP(36) = nP(36) + 1
        Case 145, 146, 147, 148: If s(i1) = 1105 Then nP(37) = nP(37) + 1
        Case 149, 150, 151, 152: If s(i1) = 1105 Then nP(38) = nP(38) + 1
    
    End Select
    
    If s(i1) = 1105 Then nQ = nQ + 1    ' Total Patterns

Next i1

nQ4 = 0
For i1 = 1 To 38
    If nP(i1) = 4 Then nQ4 = nQ4 + 1
Next i1

'  Selection Options

''If nQ <= 4 Then fl1 = 0: Return

  If nQ4 < 1 Then fl1 = 0: Return

''If nP(29) < 4 Then fl1 = 0: Return

nStr13 = ""
For i1 = 1 To 38
    If nP(i1) <> 0 Then
        nStr13 = nStr13 + "P" + CStr(i1) + "=" + CStr(nP(i1)) + " "
    End If
Next i1

Return

End Sub

Vorige Pagina About the Author