Vorige Pagina About the Author

' Generates Semi-Latin Franklin Like Pan Magic Squares of order 12
' Every 1/3 Row and 1/3 Column sum to s1/3 ' Franklin Like Properties (Compact, Bent Diagonals)

' Tested with Office 365 under Windows 10

Sub CompLat12e()
   
Dim a(144), b(12)
    
y = MsgBox("Locked", vbCritical, "Routine CompLat12e")
End
    
n2 = 0: n9 = 0
m1 = 0: m2 = 11: s1 = 66
k1 = 1: k2 = 1

Pr12 = 11
    
'   Generate data
        
    Sheets("Klad1").Select
        
    t1 = Timer
    
For j144 = m1 To m2                                             'a(144)
a(144) = j144
For j143 = m1 To m2                                             'a(143)
a(143) = j143
For j142 = m1 To m2                                             'a(142)
a(142) = j142
    
a(141) = s1 / 3 - a(142) - a(143) - a(144): If a(141) < 0 Or a(141) > 11 Then GoTo 1420
    
For j140 = m1 To m2                                              'a(140)
a(140) = j140
For j139 = m1 To m2                                              'a(139)
a(139) = j139
For j138 = m1 To m2                                              'a(138)
a(138) = j138

a(137) = s1 / 3 - a(138) - a(139) - a(140): If a(137) < 0 Or a(137) > 11 Then GoTo 1380

For j136 = m1 To m2                                              'a(136)
a(136) = j136
For j135 = m1 To m2                                              'a(135)
a(135) = j135

a(134) = Pr12 - a(136) - a(138) - a(139) + a(142) + a(144): If a(134) < 0 Or a(134) > 11 Then GoTo 1350
a(133) = Pr12 - a(135) + a(138) + a(139) - a(142) - a(144): If a(133) < 0 Or a(133) > 11 Then GoTo 1350

' Check Row 1

For i1 = 133 To 144: b(i1 - 132) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 1350
    
For j132 = m1 To m2                                               'a(132)
a(132) = j132

a(131) = s1 / 3 - a(132) - a(143) - a(144): If a(131) < 0 Or a(131) > 11 Then GoTo 1320
a(130) = a(132) - a(142) + a(144): If a(130) < 0 Or a(130) > 11 Then GoTo 1320
a(129) = -a(132) + a(142) + a(143): If a(129) < 0 Or a(129) > 11 Then GoTo 1320
a(128) = a(132) - a(140) + a(144): If a(128) < 0 Or a(128) > 11 Then GoTo 1320
a(127) = s1 / 3 - a(132) - a(139) - a(144): If a(127) < 0 Or a(127) > 11 Then GoTo 1320
a(126) = a(132) - a(138) + a(144): If a(126) < 0 Or a(126) > 11 Then GoTo 1320
a(125) = -a(132) + a(138) + a(139) + a(140) - a(144): If a(125) < 0 Or a(125) > 11 Then GoTo 1320
a(124) = a(132) - a(136) + a(144): If a(124) < 0 Or a(124) > 11 Then GoTo 1320
a(123) = s1 / 3 - a(132) - a(135) - a(144): If a(123) < 0 Or a(123) > 11 Then GoTo 1320
a(122) = -Pr12 + a(132) + a(136) + a(138) + a(139) - a(142): If a(122) < 0 Or a(122) > 11 Then GoTo 1320
a(121) = Pr12 - a(132) + a(135) - a(138) - a(139) + a(142): If a(121) < 0 Or a(121) > 11 Then GoTo 1320

' Check Row 2

For i1 = 121 To 132: b(i1 - 120) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 1320

For j120 = m1 To m2                                               'a(120)
a(120) = j120

a(119) = -a(120) + a(143) + a(144): If a(119) < 0 Or a(119) > 11 Then GoTo 1200
a(118) = a(120) + a(142) - a(144): If a(118) < 0 Or a(118) > 11 Then GoTo 1200
a(117) = s1 / 3 - a(120) - a(142) - a(143): If a(117) < 0 Or a(117) > 11 Then GoTo 1200
a(116) = a(120) + a(140) - a(144): If a(116) < 0 Or a(116) > 11 Then GoTo 1200
a(115) = -a(120) + a(139) + a(144): If a(115) < 0 Or a(115) > 11 Then GoTo 1200
a(114) = a(120) + a(138) - a(144): If a(114) < 0 Or a(114) > 11 Then GoTo 1200
a(113) = s1 / 3 - a(120) - a(138) - a(139) - a(140) + a(144): If a(113) < 0 Or a(113) > 11 Then GoTo 1200
a(112) = a(120) + a(136) - a(144): If a(112) < 0 Or a(112) > 11 Then GoTo 1200
a(111) = -a(120) + a(135) + a(144): If a(111) < 0 Or a(111) > 11 Then GoTo 1200
a(110) = Pr12 + a(120) - a(136) - a(138) - a(139) + a(142): If a(110) < 0 Or a(110) > 11 Then GoTo 1200
a(109) = Pr12 - a(120) - a(135) + a(138) + a(139) - a(142): If a(109) < 0 Or a(109) > 11 Then GoTo 1200

' Check Row 3

For i1 = 109 To 120: b(i1 - 108) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 1200

a(108) = s1 / 3 - a(120) - a(132) - a(144): If a(108) < 0 Or a(108) > 11 Then GoTo 1200
a(107) = a(120) + a(132) - a(143): If a(107) < 0 Or a(107) > 11 Then GoTo 1200
a(106) = s1 / 3 - a(120) - a(132) - a(142): If a(106) < 0 Or a(106) > 11 Then GoTo 1200
a(105) = -s1 / 3 + a(120) + a(132) + a(142) + a(143) + a(144): If a(105) < 0 Or a(105) > 11 Then GoTo 1200
a(104) = s1 / 3 - a(120) - a(132) - a(140): If a(104) < 0 Or a(104) > 11 Then GoTo 1200
a(103) = a(120) + a(132) - a(139): If a(103) < 0 Or a(103) > 11 Then GoTo 1200
a(102) = s1 / 3 - a(120) - a(132) - a(138): If a(102) < 0 Or a(102) > 11 Then GoTo 1200
a(101) = -s1 / 3 + a(120) + a(132) + a(138) + a(139) + a(140): If a(101) < 0 Or a(101) > 11 Then GoTo 1200
a(100) = s1 / 3 - a(120) - a(132) - a(136): If a(100) < 0 Or a(100) > 11 Then GoTo 1200
a(99) = a(120) + a(132) - a(135): If a(99) < 0 Or a(99) > 11 Then GoTo 1200

a(98) = Pr12 - a(120) - a(132) + a(136) + a(138) + a(139) - a(142) - a(144): 
If a(98) < 0 Or a(98) > 11 Then GoTo 1200
a(97) = -Pr12 + a(120) + a(132) + a(135) - a(138) - a(139) + a(142) + a(144): 
If a(97) < 0 Or a(97) > 11 Then GoTo 1200

' Check Row 4

For i1 = 97 To 108: b(i1 - 96) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 1200

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

a(95) = -a(96) + a(143) + a(144): If a(95) < 0 Or a(95) > 11 Then GoTo 960
a(94) = a(96) + a(142) - a(144): If a(94) < 0 Or a(94) > 11 Then GoTo 960
a(93) = s1 / 3 - a(96) - a(142) - a(143): If a(93) < 0 Or a(93) > 11 Then GoTo 960
a(92) = a(96) + a(140) - a(144): If a(92) < 0 Or a(92) > 11 Then GoTo 960
a(91) = -a(96) + a(139) + a(144): If a(91) < 0 Or a(91) > 11 Then GoTo 960
a(90) = a(96) + a(138) - a(144): If a(90) < 0 Or a(90) > 11 Then GoTo 960
a(89) = s1 / 3 - a(96) - a(138) - a(139) - a(140) + a(144): If a(89) < 0 Or a(89) > 11 Then GoTo 960
a(88) = a(96) + a(136) - a(144): If a(88) < 0 Or a(88) > 11 Then GoTo 960
a(87) = -a(96) + a(135) + a(144): If a(87) < 0 Or a(87) > 11 Then GoTo 960
a(86) = Pr12 + a(96) - a(136) - a(138) - a(139) + a(142): If a(86) < 0 Or a(86) > 11 Then GoTo 960
a(85) = Pr12 - a(96) - a(135) + a(138) + a(139) - a(142): If a(85) < 0 Or a(85) > 11 Then GoTo 960

' Check Row 5
    
For i1 = 85 To 96: b(i1 - 84) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 960

a(84) = -Pr12 + a(96) + 2 * a(120) - a(139) + a(140) + 2 * a(142) - 2 * a(144): 
If a(84) < 0 Or a(84) > 11 Then GoTo 960
a(83) = s1 / 2 - a(96) - 2 * a(120) + a(139) - a(140) - 2 * a(142) - a(143) + a(144): 
If a(83) < 0 Or a(83) > 11 Then GoTo 960
a(82) = -Pr12 + a(96) + 2 * a(120) - a(139) + a(140) + a(142) - a(144): 
If a(82) < 0 Or a(82) > 11 Then GoTo 960
a(81) = Pr12 - a(96) - 2 * a(120) + a(139) - a(140) - a(142) + a(143) + 2 * a(144): 
If a(81) < 0 Or a(81) > 11 Then GoTo 960

a(80) = -Pr12 + a(96) + 2 * a(120) - a(139) + 2 * a(142) - a(144): If a(80) < 0 Or a(80) > 11 Then GoTo 960
a(79) = s1 / 2 - a(96) - 2 * a(120) - a(140) - 2 * a(142) + a(144): If a(79) < 0 Or a(79) > 11 Then GoTo 960

a(78) = -Pr12 + a(96) + 2 * a(120) - a(138) - a(139) + a(140) + 2 * a(142) - a(144): 
If a(78) < 0 Or a(78) > 11 Then GoTo 960
a(77) = Pr12 - a(96) - 2 * a(120) + a(138) + 2 * a(139) - 2 * a(142) + a(144): 
If a(77) < 0 Or a(77) > 11 Then GoTo 960
a(76) = -Pr12 + a(96) + 2 * a(120) - a(136) - a(139) + a(140) + 2 * a(142) - a(144): 
If a(76) < 0 Or a(76) > 11 Then GoTo 960
a(75) = s1 / 2 - a(96) - 2 * a(120) - a(135) + a(139) - a(140) - 2 * a(142) + a(144): 
If a(75) < 0 Or a(75) > 11 Then GoTo 960
a(74) = -s1 / 3 + a(96) + 2 * a(120) + a(136) + a(138) + a(140) + a(142) - 2 * a(144): 
If a(74) < 0 Or a(74) > 11 Then GoTo 960
a(73) = s1 / 3 - a(96) - 2 * a(120) + a(135) - a(138) - a(140) - a(142) + 2 * a(144): 
If a(73) < 0 Or a(73) > 11 Then GoTo 960
    
' Check Row 6
    
For i1 = 73 To 84: b(i1 - 72) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 960
   
For j72 = m1 To m2                                                'a(72)
a(72) = j72
   
a(71) = -a(72) + a(143) + a(144): If a(71) < 0 Or a(71) > 11 Then GoTo 720
a(70) = a(72) + a(142) - a(144): If a(70) < 0 Or a(70) > 11 Then GoTo 720
a(69) = s1 / 3 - a(72) - a(142) - a(143): If a(69) < 0 Or a(69) > 11 Then GoTo 720
a(68) = a(72) + a(140) - a(144): If a(68) < 0 Or a(68) > 11 Then GoTo 720
a(67) = -a(72) + a(139) + a(144): If a(67) < 0 Or a(67) > 11 Then GoTo 720
a(66) = a(72) + a(138) - a(144): If a(66) < 0 Or a(66) > 11 Then GoTo 720
a(65) = s1 / 3 - a(72) - a(138) - a(139) - a(140) + a(144): If a(65) < 0 Or a(65) > 11 Then GoTo 720
a(64) = a(72) + a(136) - a(144): If a(64) < 0 Or a(64) > 11 Then GoTo 720
a(63) = -a(72) + a(135) + a(144): If a(63) < 0 Or a(63) > 11 Then GoTo 7
20
a(62) = Pr12 + a(72) - a(136) - a(138) - a(139) + a(142): If a(62) < 0 Or a(62) > 11 Then GoTo 720
a(61) = Pr12 - a(72) - a(135) + a(138) + a(139) - a(142): If a(61) < 0 Or a(61) > 11 Then GoTo 720

' Check Row 7
    
For i1 = 61 To 72: b(i1 - 60) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 720

a(60) = s1 / 2 - a(72) - 2 * a(96) - 2 * a(120) + a(139) - a(140) - 2 * a(142) + 2 * a(144): 
If a(60) < 0 Or a(60) > 11 Then GoTo 720
a(59) = -Pr12 + a(72) + 2 * a(96) + 2 * a(120) - a(139) + a(140) + 2 * a(142) - a(143) - 3 * a(144): 
If a(59) < 0 Or a(59) > 11 Then GoTo 720
a(58) = s1 / 2 - a(72) - 2 * a(96) - 2 * a(120) + a(139) - a(140) - 3 * a(142) + 3 * a(144): 
If a(58) < 0 Or a(58) > 11 Then GoTo 720
a(57) = -s1 / 2 + a(72) + 2 * a(96) + 2 * a(120) - a(139) + a(140) + 3 * a(142) + a(143) - 2 * a(144): 
If a(57) < 0 Or a(57) > 11 Then GoTo 720
a(56) = s1 / 2 - a(72) - 2 * a(96) - 2 * a(120) + a(139) - 2 * a(140) - 2 * a(142) + 3 * a(144): 
If a(56) < 0 Or a(56) > 11 Then GoTo 720
a(55) = -Pr12 + a(72) + 2 * a(96) + 2 * a(120) - 2 * a(139) + a(140) + 2 * a(142) - 3 * a(144): 
If a(55) < 0 Or a(55) > 11 Then GoTo 720
a(54) = s1 / 2 - a(72) - 2 * a(96) - 2 * a(120) - a(138) + a(139) - a(140) - 2 * a(142) + 3 * a(144): 
If a(54) < 0 Or a(54) > 11 Then GoTo 720
a(53) = -s1 / 2 + a(72) + 2 * a(96) + 2 * a(120) + a(138) + 2 * a(140) + 2 * a(142) - 3 * a(144): 
If a(53) < 0 Or a(53) > 11 Then GoTo 720
a(52) = s1 / 2 - a(72) - 2 * a(96) - 2 * a(120) - a(136) + a(139) - a(140) - 2 * a(142) + 3 * a(144): 
If a(52) < 0 Or a(52) > 11 Then GoTo 720
a(51) = -Pr12 + a(72) + 2 * a(96) + 2 * a(120) - a(135) - a(139) + a(140) + 2 * a(142) - 3 * a(144): 
If a(51) < 0 Or a(51) > 11 Then GoTo 720
a(50) = s1 / 3 - a(72) - 2 * a(96) - 2 * a(120) + a(136) + a(138) + 2 * a(139) - a(140) - 3 * a(142) + 2 * a(144): 
If a(50) < 0 Or a(50) > 11 Then GoTo 720
a(49) = -s1 / 3 + a(72) + 2 * a(96) + 2 * a(120) + a(135) - a(138) - 2 * a(139) + a(140) + 3 * a(142) - 2 * a(144): 
If a(49) < 0 Or a(49) > 11 Then GoTo 720

' Check Row 8
    
For i1 = 49 To 60: b(i1 - 48) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 720
   
For j48 = m1 To m2                                                'a(48)
a(48) = j48
   
a(47) = -a(48) + a(143) + a(144): If a(47) < 0 Or a(47) > 11 Then GoTo 480
a(46) = a(48) + a(142) - a(144): If a(46) < 0 Or a(46) > 11 Then GoTo 480
a(45) = s1 / 3 - a(48) - a(142) - a(143): If a(45) < 0 Or a(45) > 11 Then GoTo 480
a(44) = a(48) + a(140) - a(144): If a(44) < 0 Or a(44) > 11 Then GoTo 480
a(43) = -a(48) + a(139) + a(144): If a(43) < 0 Or a(43) > 11 Then GoTo 480
a(42) = a(48) + a(138) - a(144): If a(42) < 0 Or a(42) > 11 Then GoTo 480
a(41) = s1 / 3 - a(48) - a(138) - a(139) - a(140) + a(144): If a(41) < 0 Or a(41) > 11 Then GoTo 480
a(40) = a(48) + a(136) - a(144): If a(40) < 0 Or a(40) > 11 Then GoTo 480
a(39) = -a(48) + a(135) + a(144): If a(39) < 0 Or a(39) > 11 Then GoTo 480
a(38) = Pr12 + a(48) - a(136) - a(138) - a(139) + a(142): If a(38) < 0 Or a(38) > 11 Then GoTo 480
a(37) = Pr12 - a(48) - a(135) + a(138) + a(139) - a(142): If a(37) < 0 Or a(37) > 11 Then GoTo 480
   
' Check Row 9
    
For i1 = 37 To 48: b(i1 - 36) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 480
   
For j36 = m1 To m2                                                'a(36)
a(36) = j36

a(35) = s1 / 3 - a(36) - a(143) - a(144): If a(35) < 0 Or a(35) > 11 Then GoTo 360
a(34) = a(36) - a(142) + a(144): If a(34) < 0 Or a(34) > 11 Then GoTo 360
a(33) = -a(36) + a(142) + a(143): If a(33) < 0 Or a(33) > 11 Then GoTo 360
a(32) = a(36) - a(140) + a(144): If a(32) < 0 Or a(32) > 11 Then GoTo 360
a(31) = s1 / 3 - a(36) - a(139) - a(144): If a(31) < 0 Or a(31) > 11 Then GoTo 360
a(30) = a(36) - a(138) + a(144): If a(30) < 0 Or a(30) > 11 Then GoTo 360
a(29) = -a(36) + a(138) + a(139) + a(140) - a(144): If a(29) < 0 Or a(29) > 11 Then GoTo 360
a(28) = a(36) - a(136) + a(144): If a(28) < 0 Or a(28) > 11 Then GoTo 360
a(27) = s1 / 3 - a(36) - a(135) - a(144): If a(27) < 0 Or a(27) > 11 Then GoTo 360
a(26) = -Pr12 + a(36) + a(136) + a(138) + a(139) - a(142): If a(26) < 0 Or a(26) > 11 Then GoTo 360
a(25) = Pr12 - a(36) + a(135) - a(138) - a(139) + a(142): If a(25) < 0 Or a(25) > 11 Then GoTo 360

' Check Row 10
    
For i1 = 25 To 36: b(i1 - 24) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 360

a(24) = s1 / 3 - a(48) - a(72) - a(96) - a(120) + a(139) - a(140) - 2 * a(142) + 3 * a(144): 
If a(24) < 0 Or a(24) > 11 Then GoTo 360
a(23) = -s1 / 3 + a(48) + a(72) + a(96) + a(120) - a(139) + a(140) + 2 * a(142) + a(143) - 2 * a(144): 
If a(23) < 0 Or a(23) > 11 Then GoTo 360
a(22) = s1 / 3 - a(48) - a(72) - a(96) - a(120) + a(139) - a(140) - a(142) + 2 * a(144): 
If a(22) < 0 Or a(22) > 11 Then GoTo 360
a(21) = a(48) + a(72) + a(96) + a(120) - a(139) + a(140) + a(142) - a(143) - 3 * a(144): 
If a(21) < 0 Or a(21) > 11 Then GoTo 360
a(20) = s1 / 3 - a(48) - a(72) - a(96) - a(120) + a(139) - 2 * a(142) + 2 * a(144): 
If a(20) < 0 Or a(20) > 11 Then GoTo 360
a(19) = -s1 / 3 + a(48) + a(72) + a(96) + a(120) + a(140) + 2 * a(142) - 2 * a(144): 
If a(19) < 0 Or a(19) > 11 Then GoTo 360
a(18) = s1 / 3 - a(48) - a(72) - a(96) - a(120) + a(138) + a(139) - a(140) - 2 * a(142) + 2 * a(144): 
If a(18) < 0 Or a(18) > 11 Then GoTo 360
a(17) = a(48) + a(72) + a(96) + a(120) - a(138) - 2 * a(139) + 2 * a(142) - 2 * a(144): 
If a(17) < 0 Or a(17) > 11 Then GoTo 360
a(16) = s1 / 3 - a(48) - a(72) - a(96) - a(120) + a(136) + a(139) - a(140) - 2 * a(142) + 2 * a(144): 
If a(16) < 0 Or a(16) > 11 Then GoTo 360
a(15) = -s1 / 3 + a(48) + a(72) + a(96) + a(120) + a(135) - a(139) + a(140) + 2 * a(142) - 2 * a(144): 
If a(15) < 0 Or a(15) > 11 Then GoTo 360
a(14) = s1 / 2 - a(48) - a(72) - a(96) - a(120) - a(136) - a(138) - a(140) - a(142) + 3 * a(144): 
If a(14) < 0 Or a(14) > 11 Then GoTo 360
a(13) = -Pr12 + a(48) + a(72) + a(96) + a(120) - a(135) + a(138) + a(140) + a(142) - 3 * a(144): 
If a(13) < 0 Or a(13) > 11 Then GoTo 360

' Check Row 11
    
For i1 = 13 To 24: b(i1 - 12) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 360

a(12) = -a(36) + a(72) + a(96) + a(120) - a(139) + a(140) + 2 * a(142) - 3 * a(144): 
If a(12) < 0 Or a(12) > 11 Then GoTo 360
a(11) = s1 / 3 + a(36) - a(72) - a(96) - a(120) + a(139) - a(140) - 2 * a(142) - a(143) + 2 * a(144): 
If a(11) < 0 Or a(11) > 11 Then GoTo 360
a(10) = -a(36) + a(72) + a(96) + a(120) - a(139) + a(140) + a(142) - 2 * a(144): 
If a(10) < 0 Or a(10) > 11 Then GoTo 360
a(9) = a(36) - a(72) - a(96) - a(120) + a(139) - a(140) - a(142) + a(143) + 3 * a(144): 
If a(9) < 0 Or a(9) > 11 Then GoTo 360
a(8) = -a(36) + a(72) + a(96) + a(120) - a(139) + 2 * a(142) - 2 * a(144): 
If a(8) < 0 Or a(8) > 11 Then GoTo 360
a(7) = s1 / 3 + a(36) - a(72) - a(96) - a(120) - a(140) - 2 * a(142) + 2 * a(144): 
If a(7) < 0 Or a(7) > 11 Then GoTo 360
a(6) = -a(36) + a(72) + a(96) + a(120) - a(138) - a(139) + a(140) + 2 * a(142) - 2 * a(144): 
If a(6) < 0 Or a(6) > 11 Then GoTo 360
a(5) = a(36) - a(72) - a(96) - a(120) + a(138) + 2 * a(139) - 2 * a(142) + 2 * a(144): 
If a(5) < 0 Or a(5) > 11 Then GoTo 360
a(4) = -a(36) + a(72) + a(96) + a(120) - a(136) - a(139) + a(140) + 2 * a(142) - 2 * a(144): 
If a(4) < 0 Or a(4) > 11 Then GoTo 360
a(3) = s1 / 3 + a(36) - a(72) - a(96) - a(120) - a(135) + a(139) - a(140) - 2 * a(142) + 2 * a(144): 
If a(3) < 0 Or a(3) > 11 Then GoTo 360
a(2) = -Pr12 - a(36) + a(72) + a(96) + a(120) + a(136) + a(138) + a(140) + a(142) - 3 * a(144): 
If a(2) < 0 Or a(2) > 11 Then GoTo 360
a(1) = Pr12 + a(36) - a(72) - a(96) - a(120) + a(135) - a(138) - a(140) - a(142) + 3 * a(144): 
If a(1) < 0 Or a(1) > 11 Then GoTo 360

' Check Row 12
    
For i1 = 1 To 12: b(i1 - 0) = a(i1): Next i1
GoSub 1800: If fl1 = 0 Then GoTo 360
   
'Check Diagonal 1
i2 = 1
For i1 = 1 To 12:
    b(i1) = a(i2): i2 = i2 + 13
Next i1
GoSub 1800: If fl1 = 0 Then GoTo 360

'Check Diagonal 2
i2 = 12
For i1 = 1 To 12:
    b(i1) = a(i2): i2 = i2 + 11
Next i1
GoSub 1800: If fl1 = 0 Then GoTo 360
    
                       n9 = n9 + 1
'                      GoSub 2650 'Print results (squares)
                       GoSub 2645 'Print results (selected numbers
'                      Cells(1, 1).Value = n9 'Counting
   
360 Next j36

480 Next j48

720 Next j72

960 Next j96

1200 Next j120

1320 Next j132

1350 Next j135
1360 Next j136

1380 Next j138
1390 Next j139
1400 Next j140

1420 Next j142
1430 Next j143
1440 Next j144

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

'   Exclude solutions with identical numbers Latin Lines Order 12

1800 fl1 = 1
     For j1 = 1 To 12
        a2 = b(j1):
        For j2 = (1 + j1) To 12
            If a2 = b(j2) Then fl1 = 0: Return
        Next j2
1810 Next j1
     Return
    
'   Print results (selected numbers)
    
2645 For i1 = 1 To 144
         Cells(n9, i1).Value = a(i1)
     Next i1
     Cells(n9, 145).Value = n9
     Return

'   Print results (squares)
    
2650 n2 = n2 + 1
     If n2 = 3 Then
         n2 = 1: k1 = k1 + 13: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 13
     End If
     Cells(k1 + 1, k2 + 1).Select
        
     Cells(k1, k2 + 1).Select
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
    
     i3 = 0
     For i1 = 1 To 12
         For i2 = 1 To 12
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1
        
     Return
    
End Sub

Vorige Pagina About the Author