' Generates Bordered Magic Cubes of order 7 (Prime Numbers)
' Part III: Anti Symmetric Semi Magic Left Squares
' Tested with Office 2007 under Windows 7
Sub PrimeCubes8c()
Dim a1(1040), a(128), b1(19720), b(19720), c(128), c8(512)
Dim lns4(4, 4), a11(16), a12(16)
y = MsgBox("Locked", vbCritical, "Routine PrimeCubes8c")
End
n2 = 0: n3 = 0: k1 = 1: k2 = 1: n9 = 0: n10 = 0
Sht1 = "Pairs8b": Sht2 = "TopSqrs8": Sht3 = "BckSqrs8"
Sheets("Klad1").Select
t1 = Timer
n11 = 2: n12 = 2 'start row : column
n4 = 0: i4 = 0: n41 = 4 'current square
For j100 = 1 To 4 * 32 'Square nr j100 current
n4 = n4 + 1: n12 = 2 + (n4 - 1) * 5: i4 = 0
For j1 = n11 To n11 + 3 'Row within square j100
For j2 = n12 To n12 + 3 'Column within square j100
i4 = i4 + 1
a11(i4) = Sheets(Sht2).Cells(j1, j2).Value 'load top square
a12(i4) = Sheets(Sht3).Cells(j1, j2).Value 'load back square
Next j2
Next j1
Select Case n4
Case 1
rcrd1a = Sheets(Sht2).Cells(n11, n12 - 1)
GoSub 1810 'Read Primes b1()
Erase c
GoSub 700 'Construct c()
GoSub 1900 'Remove Primes Top and Back Square 1
Case 2
GoSub 700 'Construct c()
GoSub 1900 'Remove Primes Top and Back Square 2
Case 3
GoSub 700 'Construct c()
GoSub 1900 'Remove Primes Top and Back Square 3
Case 4
GoSub 700 'Construct c()
GoSub 1900 'Remove Primes Top and Back Square 4
GoSub 1820 'Define a1()
GoSub 600 'Calculate Left Square
End Select
If n4 = n41 Then n4 = 0: n11 = n11 + 5: n12 = 2
Next j100
t2 = Timer
t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
y = MsgBox(t10, 0, "Routine PrimeCubes8c")
End
' Generate Squares (8 x 8)
600 n10 = 0: Erase a, b, c
If j100 <> 72 And j100 <> 84 Then Return 'Preselected Sets (Time)
' Define a() based on c()
a(1) = c8(1): a(2) = c8(9): a(3) = c8(17): a(4) = c8(25):
a(5) = c8(33): a(6) = c8(41): a(7) = c8(49): a(8) = c8(57):
a(9) = c8(65): a(16) = c8(121):
a(17) = c8(129): a(24) = c8(185):
a(25) = c8(193): a(32) = c8(249):
a(33) = c8(257): a(40) = c8(313):
a(41) = c8(321): a(48) = c8(377):
a(49) = c8(385): a(56) = c8(441):
a(57) = c8(449): a(58) = c8(457): a(59) = c8(465): a(60) = c8(473):
a(61) = c8(481): a(62) = c8(489): a(63) = c8(497): a(64) = c8(505):
t11 = Timer 'Time Out
' Left Top Corner Square
For j10 = m1 To m2 'a(10)
If b1(a1(j10)) = 0 Then GoTo 100
If b(a1(j10)) = 0 Then b(a1(j10)) = a1(j10): c(10) = a1(j10) Else GoTo 100
a(10) = a1(j10)
a(75) = Pr4 - a(10): If b(a(75)) = 0 Then b(a(75)) = a(75): c(75) = a(75) Else GoTo 750
For j11 = m1 To m2 'a(11)
If b1(a1(j11)) = 0 Then GoTo 110
If b(a1(j11)) = 0 Then b(a1(j11)) = a1(j11): c(11) = a1(j11) Else GoTo 110
a(11) = a1(j11)
a(76) = Pr4 - a(11): If b(a(76)) = 0 Then b(a(76)) = a(76): c(76) = a(76) Else GoTo 760
a(12) = s1 - a(11) - a(10) - a(9)
If a(12) < a1(m1) Or a(12) > a1(m2) Then GoTo 120
If b1(a(12)) = 0 Then GoTo 120
If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 120
a(77) = Pr4 - a(12): If b(a(77)) = 0 Then b(a(77)) = a(77): c(77) = a(77) Else GoTo 770
For j18 = m1 To m2 'a(18)
If b1(a1(j18)) = 0 Then GoTo 180
If b(a1(j18)) = 0 Then b(a1(j18)) = a1(j18): c(18) = a1(j18) Else GoTo 180
a(18) = a1(j18)
a(83) = Pr4 - a(18): If b(a(83)) = 0 Then b(a(83)) = a(83): c(83) = a(83) Else GoTo 830
a(26) = s1 - a(18) - a(10) - a(2)
If a(26) < a1(m1) Or a(26) > a1(m2) Then GoTo 260
If b1(a(26)) = 0 Then GoTo 260
If b(a(26)) = 0 Then b(a(26)) = a(26): c(26) = a(26) Else GoTo 260
a(91) = Pr4 - a(26): If b(a(91)) = 0 Then b(a(91)) = a(91): c(91) = a(91) Else GoTo 910
For j19 = m1 To m2 'a(19)
If b1(a1(j19)) = 0 Then GoTo 190
If b(a1(j19)) = 0 Then b(a1(j19)) = a1(j19): c(19) = a1(j19) Else GoTo 190
a(19) = a1(j19)
a(84) = Pr4 - a(19): If b(a(84)) = 0 Then b(a(84)) = a(84): c(84) = a(84) Else GoTo 840
a(20) = s1 - a(19) - a(18) - a(17)
If a(20) < a1(m1) Or a(20) > a1(m2) Then GoTo 200
If b1(a(20)) = 0 Then GoTo 200
If b(a(20)) = 0 Then b(a(20)) = a(20): c(20) = a(20) Else GoTo 200
a(85) = Pr4 - a(20): If b(a(85)) = 0 Then b(a(85)) = a(85): c(85) = a(85) Else GoTo 850
a(27) = s1 - a(19) - a(11) - a(3)
If a(27) < a1(m1) Or a(27) > a1(m2) Then GoTo 270
If b1(a(27)) = 0 Then GoTo 270
If b(a(27)) = 0 Then b(a(27)) = a(27): c(27) = a(27) Else GoTo 270
a(92) = Pr4 - a(27): If b(a(92)) = 0 Then b(a(92)) = a(92): c(92) = a(92) Else GoTo 920
a(28) = a(19) + a(18) + a(17) - a(12) - a(4)
If a(28) < a1(m1) Or a(28) > a1(m2) Then GoTo 280
If b1(a(28)) = 0 Then GoTo 280
If b(a(28)) = 0 Then b(a(28)) = a(28): c(28) = a(28) Else GoTo 280
a(93) = Pr4 - a(28): If b(a(93)) = 0 Then b(a(93)) = a(93): c(93) = a(93) Else GoTo 930
' Left Bottom
For j52 = m2 / 2 To m1 Step -1 'a(52)
If b1(a1(j52)) = 0 Then GoTo 520
If b(a1(j52)) = 0 Then b(a1(j52)) = a1(j52): c(52) = a1(j52) Else GoTo 520
a(52) = a1(j52)
a(117) = Pr4 - a(52): If b(a(117)) = 0 Then b(a(117)) = a(117): c(117) = a(117) Else GoTo 1170
For j44 = m1 To m2 'a(44)
If b1(a1(j44)) = 0 Then GoTo 440
If b(a1(j44)) = 0 Then b(a1(j44)) = a1(j44): c(44) = a1(j44) Else GoTo 440
a(44) = a1(j44)
a(109) = Pr4 - a(44): If b(a(109)) = 0 Then b(a(109)) = a(109): c(109) = a(109) Else GoTo 1090
a(36) = s1 - a(44) - a(52) - a(60)
If a(36) < a1(m1) Or a(36) > a1(m2) Then GoTo 360
If b1(a(36)) = 0 Then GoTo 360
If b(a(36)) = 0 Then b(a(36)) = a(36): c(36) = a(36) Else GoTo 360
a(101) = Pr4 - a(36): If b(a(101)) = 0 Then b(a(101)) = a(101): c(101) = a(101) Else GoTo 1010
For j51 = m1 To m2 'a(51)
If b1(a1(j51)) = 0 Then GoTo 510
If b(a1(j51)) = 0 Then b(a1(j51)) = a1(j51): c(51) = a1(j51) Else GoTo 510
a(51) = a1(j51)
a(116) = Pr4 - a(51): If b(a(116)) = 0 Then b(a(116)) = a(116): c(116) = a(116) Else GoTo 1160
For j43 = m1 To m2 'a(43)
If b1(a1(j43)) = 0 Then GoTo 430
If b(a1(j43)) = 0 Then b(a1(j43)) = a1(j43): c(43) = a1(j43) Else GoTo 430
a(43) = a1(j43)
a(108) = Pr4 - a(43): If b(a(108)) = 0 Then b(a(108)) = a(108): c(108) = a(108) Else GoTo 1080
a(35) = s1 - a(43) - a(51) - a(59)
If a(35) < a1(m1) Or a(35) > a1(m2) Then GoTo 350
If b1(a(35)) = 0 Then GoTo 350
If b(a(35)) = 0 Then b(a(35)) = a(35): c(35) = a(35) Else GoTo 350
a(100) = Pr4 - a(35): If b(a(100)) = 0 Then b(a(100)) = a(100): c(100) = a(100) Else GoTo 1000
For j50 = m2 / 2 To m1 Step -1 'a(50)
If b1(a1(j50)) = 0 Then GoTo 500
If b(a1(j50)) = 0 Then b(a1(j50)) = a1(j50): c(50) = a1(j50) Else GoTo 500
a(50) = a1(j50)
a(115) = Pr4 - a(50): If b(a(115)) = 0 Then b(a(115)) = a(115): c(115) = a(115) Else GoTo 1150
For j42 = m1 To m2 'a(42)
If b1(a1(j42)) = 0 Then GoTo 420
If b(a1(j42)) = 0 Then b(a1(j42)) = a1(j42): c(42) = a1(j42) Else GoTo 420
a(42) = a1(j42)
a(107) = Pr4 - a(42): If b(a(107)) = 0 Then b(a(107)) = a(107): c(107) = a(107) Else GoTo 1070
a(34) = s1 - a(42) - a(50) - a(58)
If a(34) < a1(m1) Or a(34) > a1(m2) Then GoTo 340
If b1(a(34)) = 0 Then GoTo 340
If b(a(34)) = 0 Then b(a(34)) = a(34): c(34) = a(34) Else GoTo 340
a(99) = Pr4 - a(34): If b(a(99)) = 0 Then b(a(99)) = a(99): c(99) = a(99) Else GoTo 990
For j55 = m2 To m1 Step -1 'a(55)
If b1(a1(j55)) = 0 Then GoTo 550
If b(a1(j55)) = 0 Then b(a1(j55)) = a1(j55): c(55) = a1(j55) Else GoTo 550
a(55) = a1(j55)
a(120) = Pr4 - a(55): If b(a(120)) = 0 Then b(a(120)) = a(120): c(120) = a(120) Else GoTo 1200
For j54 = m2 To m1 Step -1 'a(54)
If b1(a1(j54)) = 0 Then GoTo 540
If b(a1(j54)) = 0 Then b(a1(j54)) = a1(j54): c(54) = a1(j54) Else GoTo 540
a(54) = a1(j54)
a(119) = Pr4 - a(54): If b(a(119)) = 0 Then b(a(119)) = a(119): c(119) = a(119) Else GoTo 1190
t12 = Timer: t13 = t12 - t11 'Time Out
If t13 > 120 Then Return 'Time Out, Try Next Set Sub Squares
a(53) = s8 - a(54) - a(55) - a(56) - a(49) - a(50) - a(51) - a(52)
If a(53) < a1(m1) Or a(53) > a1(m2) Then GoTo 530
If b1(a(53)) = 0 Then GoTo 530
If b(a(53)) = 0 Then b(a(53)) = a(53): c(53) = a(53) Else GoTo 530
a(118) = Pr4 - a(53): If b(a(118)) = 0 Then b(a(118)) = a(118): c(118) = a(118) Else GoTo 1180
For j47 = m1 To m2 'a(47)
If b1(a1(j47)) = 0 Then GoTo 470
If b(a1(j47)) = 0 Then b(a1(j47)) = a1(j47): c(47) = a1(j47) Else GoTo 470
a(47) = a1(j47)
a(112) = Pr4 - a(47): If b(a(112)) = 0 Then b(a(112)) = a(112): c(112) = a(112) Else GoTo 1120
For j46 = m1 To m2 'a(46)
If b1(a1(j46)) = 0 Then GoTo 460
If b(a1(j46)) = 0 Then b(a1(j46)) = a1(j46): c(46) = a1(j46) Else GoTo 460
a(46) = a1(j46)
a(111) = Pr4 - a(46): If b(a(111)) = 0 Then b(a(111)) = a(111): c(111) = a(111) Else GoTo 1110
a(45) = s8 - a(46) - a(47) - a(42) - a(43) - a(44) - a(41) - a(48)
If a(45) < a1(m1) Or a(45) > a1(m2) Then GoTo 450
If b1(a(45)) = 0 Then GoTo 450
If b(a(45)) = 0 Then b(a(45)) = a(45): c(45) = a(45) Else GoTo 450
a(110) = Pr4 - a(45): If b(a(110)) = 0 Then b(a(110)) = a(110): c(110) = a(110) Else GoTo 1100
For j31 = m1 To m2 'a(31)
If b1(a1(j31)) = 0 Then GoTo 310
If b(a1(j31)) = 0 Then b(a1(j31)) = a1(j31): c(31) = a1(j31) Else GoTo 310
a(31) = a1(j31)
a(96) = Pr4 - a(31): If b(a(96)) = 0 Then b(a(96)) = a(96): c(96) = a(96) Else GoTo 960
For j30 = m1 To m2 'a(30)
If b1(a1(j30)) = 0 Then GoTo 300
If b(a1(j30)) = 0 Then b(a1(j30)) = a1(j30): c(30) = a1(j30) Else GoTo 300
a(30) = a1(j30)
a(95) = Pr4 - a(30): If b(a(95)) = 0 Then b(a(95)) = a(95): c(95) = a(95) Else GoTo 950
a(29) = s1 - a(30) - a(31) - a(32)
If a(29) < a1(m1) Or a(29) > a1(m2) Then GoTo 290
If b1(a(29)) = 0 Then GoTo 290
If b(a(29)) = 0 Then b(a(29)) = a(29): c(29) = a(29) Else GoTo 290
a(94) = Pr4 - a(29): If b(a(94)) = 0 Then b(a(94)) = a(94): c(94) = a(94) Else GoTo 940
For j23 = m1 To m2 'a(23)
If b1(a1(j23)) = 0 Then GoTo 230
If b(a1(j23)) = 0 Then b(a1(j23)) = a1(j23): c(23) = a1(j23) Else GoTo 230
a(23) = a1(j23)
a(88) = Pr4 - a(23): If b(a(88)) = 0 Then b(a(88)) = a(88): c(88) = a(88) Else GoTo 880
For j22 = m1 To m2 'a(22)
If b1(a1(j22)) = 0 Then GoTo 220
If b(a1(j22)) = 0 Then b(a1(j22)) = a1(j22): c(22) = a1(j22) Else GoTo 220
a(22) = a1(j22)
a(87) = Pr4 - a(22): If b(a(87)) = 0 Then b(a(87)) = a(87): c(87) = a(87) Else GoTo 870
a(21) = s1 - a(22) - a(23) - a(24)
If a(21) < a1(m1) Or a(21) > a1(m2) Then GoTo 210
If b1(a(21)) = 0 Then GoTo 210
If b(a(21)) = 0 Then b(a(21)) = a(21): c(21) = a(21) Else GoTo 210
a(86) = Pr4 - a(21): If b(a(86)) = 0 Then b(a(86)) = a(86): c(86) = a(86) Else GoTo 860
For j15 = m1 To m2 'a(15)
If b1(a1(j15)) = 0 Then GoTo 150
If b(a1(j15)) = 0 Then b(a1(j15)) = a1(j15): c(15) = a1(j15) Else GoTo 150
a(15) = a1(j15)
a(80) = Pr4 - a(15): If b(a(80)) = 0 Then b(a(80)) = a(80): c(80) = a(80) Else GoTo 800
For j14 = m1 To m2 'a(14)
If b1(a1(j14)) = 0 Then GoTo 140
If b(a1(j14)) = 0 Then b(a1(j14)) = a1(j14): c(14) = a1(j14) Else GoTo 140
a(14) = a1(j14)
a(79) = Pr4 - a(14): If b(a(79)) = 0 Then b(a(79)) = a(79): c(79) = a(79) Else GoTo 790
t12 = Timer: t13 = t12 - t11 'Time Out
If t13 > 120 Then Return 'Time Out, Try Next Set Sub Squares
a(13) = s1 - a(14) - a(15) - a(16)
If a(13) < a1(m1) Or a(13) > a1(m2) Then GoTo 130
If b1(a(13)) = 0 Then GoTo 130
If b(a(13)) = 0 Then b(a(13)) = a(13): c(13) = a(13) Else GoTo 130
a(78) = Pr4 - a(13): If b(a(78)) = 0 Then b(a(78)) = a(78): c(78) = a(78) Else GoTo 780
a(39) = s8 - a(15) - a(23) - a(31) - a(47) - a(55) - a(7) - a(63)
If a(39) < a1(m1) Or a(39) > a1(m2) Then GoTo 390
If b1(a(39)) = 0 Then GoTo 390
If b(a(39)) = 0 Then b(a(39)) = a(39): c(39) = a(39) Else GoTo 390
a(104) = Pr4 - a(39): If b(a(104)) = 0 Then b(a(104)) = a(104): c(104) = a(104) Else GoTo 1040
a(38) = s8 - a(14) - a(22) - a(30) - a(46) - a(54) - a(6) - a(62)
If a(38) < a1(m1) Or a(38) > a1(m2) Then GoTo 380
If b1(a(38)) = 0 Then GoTo 380
If b(a(38)) = 0 Then b(a(38)) = a(38): c(38) = a(38) Else GoTo 380
a(103) = Pr4 - a(38): If b(a(103)) = 0 Then b(a(103)) = a(103): c(103) = a(103) Else GoTo 1030
a(37) = s8 - a(13) - a(21) - a(29) - a(45) - a(53) - a(5) - a(61)
If a(37) < a1(m1) Or a(37) > a1(m2) Then GoTo 370
If b1(a(37)) = 0 Then GoTo 370
If b(a(37)) = 0 Then b(a(37)) = a(37): c(37) = a(37) Else GoTo 370
a(102) = Pr4 - a(37): If b(a(102)) = 0 Then b(a(102)) = a(102): c(102) = a(102) Else GoTo 1020
GoSub 1300 'Complete Border
n9 = n9 + 1: GoSub 1750 'Print Completed Border
' n9 = n9 + 1: GoSub 650 'Print Left Square
Return
b(c(102)) = 0: c(102) = 0
1020 b(c(37)) = 0: c(37) = 0
370 b(c(103)) = 0: c(103) = 0
1030 b(c(38)) = 0: c(38) = 0
380 b(c(104)) = 0: c(104) = 0
1040 b(c(39)) = 0: c(39) = 0
390 b(c(78)) = 0: c(78) = 0
780 b(c(13)) = 0: c(13) = 0
130 b(c(79)) = 0: c(79) = 0
790 b(c(14)) = 0: c(14) = 0
140 Next j14
b(c(80)) = 0: c(80) = 0
800 b(c(15)) = 0: c(15) = 0
150 Next j15
b(c(86)) = 0: c(86) = 0
860 b(c(21)) = 0: c(21) = 0
210 b(c(87)) = 0: c(87) = 0
870 b(c(22)) = 0: c(22) = 0
220 Next j22
b(c(88)) = 0: c(88) = 0
880 b(c(23)) = 0: c(23) = 0
230 Next j23
b(c(94)) = 0: c(94) = 0
940 b(c(29)) = 0: c(29) = 0
290 b(c(95)) = 0: c(95) = 0
950 b(c(30)) = 0: c(30) = 0
300 Next j30
b(c(96)) = 0: c(96) = 0
960 b(c(31)) = 0: c(31) = 0
310 Next j31
b(c(110)) = 0: c(110) = 0
1100 b(c(45)) = 0: c(45) = 0
450 b(c(111)) = 0: c(111) = 0
1110 b(c(46)) = 0: c(46) = 0
460 Next j46
b(c(112)) = 0: c(112) = 0
1120 b(c(47)) = 0: c(47) = 0
470 Next j47
b(c(118)) = 0: c(118) = 0
1180 b(c(53)) = 0: c(53) = 0
530 b(c(119)) = 0: c(119) = 0
1190 b(c(54)) = 0: c(54) = 0
540 Next j54
b(c(120)) = 0: c(120) = 0
1200 b(c(55)) = 0: c(55) = 0
550 Next j55
b(c(99)) = 0: c(99) = 0
990 b(c(34)) = 0: c(34) = 0
340 b(c(107)) = 0: c(107) = 0
1070 b(c(42)) = 0: c(42) = 0
420 Next j42
b(c(115)) = 0: c(115) = 0
1150 b(c(50)) = 0: c(50) = 0
500 Next j50
b(c(100)) = 0: c(100) = 0
1000 b(c(35)) = 0: c(35) = 0
350 b(c(108)) = 0: c(108) = 0
1080 b(c(43)) = 0: c(43) = 0
430 Next j43
b(c(116)) = 0: c(116) = 0
1160 b(c(51)) = 0: c(51) = 0
510 Next j51
b(c(101)) = 0: c(101) = 0
1010 b(c(36)) = 0: c(36) = 0
360 b(c(109)) = 0: c(109) = 0
1090 b(c(44)) = 0: c(44) = 0
440 Next j44
b(c(117)) = 0: c(117) = 0
1170 b(c(52)) = 0: c(52) = 0
520 Next j52
b(c(93)) = 0: c(93) = 0
930 b(c(28)) = 0: c(28) = 0
280 b(c(92)) = 0: c(92) = 0
920 b(c(27)) = 0: c(27) = 0
270 b(c(85)) = 0: c(85) = 0
850 b(c(20)) = 0: c(20) = 0
200 b(c(84)) = 0: c(84) = 0
840 b(c(19)) = 0: c(19) = 0
190 Next j19
b(c(91)) = 0: c(91) = 0
910 b(c(26)) = 0: c(26) = 0
260 b(c(83)) = 0: c(83) = 0
830 b(c(18)) = 0: c(18) = 0
180 Next j18
b(c(77)) = 0: c(77) = 0
770 b(c(12)) = 0: c(12) = 0
120 b(c(76)) = 0: c(76) = 0
760 b(c(11)) = 0: c(11) = 0
110 Next j11
b(c(75)) = 0: c(75) = 0
750 b(c(10)) = 0: c(10) = 0
100 Next j10
Return
' Print results (selected numbers)
640 For i1 = 1 To 64
Cells(n9, i1).Value = a(i1)
Next i1
Return
' Print results (squares)
650 n2 = n2 + 1
If n2 = 4 Then
n2 = 1: k1 = k1 + 9: k2 = 1
Else
If n9 > 1 Then k2 = k2 + 9
End If
Cells(k1, k2 + 1).Select
Cells(k1, k2 + 1).Font.Color = -4165632
Cells(k1, k2 + 1).Value = s8
i3 = 0
For i1 = 1 To 8
For i2 = 1 To 8
i3 = i3 + 1
Cells(k1 + i1, k2 + i2).Value = a(i3)
Next i2
Next i1
Return
' Construct Cube
700
Select Case n4
Case 1
' Top
c8(1) = a11(1): c8(2) = a11(2): c8(3) = a11(3): c8(4) = a11(4):
c8(9) = a11(5): c8(10) = a11(6): c8(11) = a11(7): c8(12) = a11(8):
c8(17) = a11(9): c8(18) = a11(10): c8(19) = a11(11): c8(20) = a11(12):
c8(25) = a11(13): c8(26) = a11(14): c8(27) = a11(15): c8(28) = a11(16):
' Back
c8(65) = a12(9): c8(66) = a12(10): c8(67) = a12(11): c8(68) = a12(12):
c8(129) = a12(5): c8(130) = a12(6): c8(131) = a12(7): c8(132) = a12(8):
c8(193) = a12(1): c8(194) = a12(2): c8(195) = a12(3): c8(196) = a12(4):
Case 2
' Top
c8(5) = a11(1): c8(6) = a11(2): c8(7) = a11(3): c8(8) = a11(4):
c8(13) = a11(5): c8(14) = a11(6): c8(15) = a11(7): c8(16) = a11(8):
c8(21) = a11(9): c8(22) = a11(10): c8(23) = a11(11): c8(24) = a11(12):
c8(29) = a11(13): c8(30) = a11(14): c8(31) = a11(15): c8(32) = a11(16):
' Back
c8(69) = a12(9): c8(70) = a12(10): c8(71) = a12(11): c8(72) = a12(12):
c8(133) = a12(5): c8(134) = a12(6): c8(135) = a12(7): c8(136) = a12(8):
c8(197) = a12(1): c8(198) = a12(2): c8(199) = a12(3): c8(200) = a12(4):
Case 3
' Top
c8(33) = a11(1): c8(34) = a11(2): c8(35) = a11(3): c8(36) = a11(4):
c8(41) = a11(5): c8(42) = a11(6): c8(43) = a11(7): c8(44) = a11(8):
c8(49) = a11(9): c8(50) = a11(10): c8(51) = a11(11): c8(52) = a11(12):
c8(57) = a11(13): c8(58) = a11(14): c8(59) = a11(15): c8(60) = a11(16):
' Back
c8(258) = a12(2): c8(259) = a12(3): c8(260) = a12(4): c8(264) = a12(1):
c8(322) = a12(6): c8(323) = a12(7): c8(324) = a12(8): c8(328) = a12(5):
c8(386) = a12(10): c8(387) = a12(11): c8(388) = a12(12): c8(392) = a12(9):
c8(450) = a12(14): c8(451) = a12(15): c8(452) = a12(16): c8(456) = a12(13):
Case 4
' Top
c8(37) = a11(1): c8(38) = a11(2): c8(39) = a11(3): c8(40) = a11(4):
c8(45) = a11(5): c8(46) = a11(6): c8(47) = a11(7): c8(48) = a11(8):
c8(53) = a11(9): c8(54) = a11(10): c8(55) = a11(11): c8(56) = a11(12):
c8(61) = a11(13): c8(62) = a11(14): c8(63) = a11(15): c8(64) = a11(16):
' Back
c8(257) = a12(4): c8(261) = a12(1): c8(262) = a12(2): c8(263) = a12(3):
c8(321) = a12(8): c8(325) = a12(5): c8(326) = a12(6): c8(327) = a12(7):
c8(385) = a12(12): c8(389) = a12(9): c8(390) = a12(10): c8(391) = a12(11):
c8(449) = a12(16): c8(453) = a12(13): c8(454) = a12(14): c8(455) = a12(15):
' Bottom Square
c8(449) = Pr4 - c8(64): c8(450) = Pr4 - c8(58): c8(451) = Pr4 - c8(59): c8(452) = Pr4 - c8(60)
c8(453) = Pr4 - c8(61): c8(454) = Pr4 - c8(62): c8(455) = Pr4 - c8(63): c8(456) = Pr4 - c8(57)
c8(457) = Pr4 - c8(16): c8(458) = Pr4 - c8(10): c8(459) = Pr4 - c8(11): c8(460) = Pr4 - c8(12)
c8(461) = Pr4 - c8(13): c8(462) = Pr4 - c8(14): c8(463) = Pr4 - c8(15): c8(464) = Pr4 - c8(9)
c8(465) = Pr4 - c8(24): c8(466) = Pr4 - c8(18): c8(467) = Pr4 - c8(19): c8(468) = Pr4 - c8(20)
c8(469) = Pr4 - c8(21): c8(470) = Pr4 - c8(22): c8(471) = Pr4 - c8(23): c8(472) = Pr4 - c8(17)
c8(473) = Pr4 - c8(32): c8(474) = Pr4 - c8(26): c8(475) = Pr4 - c8(27): c8(476) = Pr4 - c8(28)
c8(477) = Pr4 - c8(29): c8(478) = Pr4 - c8(30): c8(479) = Pr4 - c8(31): c8(480) = Pr4 - c8(25)
c8(481) = Pr4 - c8(40): c8(482) = Pr4 - c8(34): c8(483) = Pr4 - c8(35): c8(484) = Pr4 - c8(36)
c8(485) = Pr4 - c8(37): c8(486) = Pr4 - c8(38): c8(487) = Pr4 - c8(39): c8(488) = Pr4 - c8(33)
c8(489) = Pr4 - c8(48): c8(490) = Pr4 - c8(42): c8(491) = Pr4 - c8(43): c8(492) = Pr4 - c8(44)
c8(493) = Pr4 - c8(45): c8(494) = Pr4 - c8(46): c8(495) = Pr4 - c8(47): c8(496) = Pr4 - c8(41)
c8(497) = Pr4 - c8(56): c8(498) = Pr4 - c8(50): c8(499) = Pr4 - c8(51): c8(500) = Pr4 - c8(52)
c8(501) = Pr4 - c8(53): c8(502) = Pr4 - c8(54): c8(503) = Pr4 - c8(55): c8(504) = Pr4 - c8(49)
c8(505) = Pr4 - c8(8): c8(506) = Pr4 - c8(2): c8(507) = Pr4 - c8(3): c8(508) = Pr4 - c8(4)
c8(509) = Pr4 - c8(5): c8(510) = Pr4 - c8(6): c8(511) = Pr4 - c8(7): c8(512) = Pr4 - c8(1)
' Front Square
c8(57) = Pr4 - c8(456): c8(58) = Pr4 - c8(450): c8(59) = Pr4 - c8(451): c8(60) = Pr4 - c8(452):
c8(61) = Pr4 - c8(453): c8(62) = Pr4 - c8(454): c8(63) = Pr4 - c8(455): c8(64) = Pr4 - c8(449)
c8(121) = Pr4 - c8(72): c8(122) = Pr4 - c8(66): c8(123) = Pr4 - c8(67): c8(124) = Pr4 - c8(68):
c8(125) = Pr4 - c8(69): c8(126) = Pr4 - c8(70): c8(127) = Pr4 - c8(71): c8(128) = Pr4 - c8(65)
c8(185) = Pr4 - c8(136): c8(186) = Pr4 - c8(130): c8(187) = Pr4 - c8(131): c8(188) = Pr4 - c8(132):
c8(189) = Pr4 - c8(133): c8(190) = Pr4 - c8(134): c8(191) = Pr4 - c8(135): c8(192) = Pr4 - c8(129)
c8(249) = Pr4 - c8(200): c8(250) = Pr4 - c8(194): c8(251) = Pr4 - c8(195): c8(252) = Pr4 - c8(196):
c8(253) = Pr4 - c8(197): c8(254) = Pr4 - c8(198): c8(255) = Pr4 - c8(199): c8(256) = Pr4 - c8(193)
c8(313) = Pr4 - c8(264): c8(314) = Pr4 - c8(258): c8(315) = Pr4 - c8(259): c8(316) = Pr4 - c8(260):
c8(317) = Pr4 - c8(261): c8(318) = Pr4 - c8(262): c8(319) = Pr4 - c8(263): c8(320) = Pr4 - c8(257)
c8(377) = Pr4 - c8(328): c8(378) = Pr4 - c8(322): c8(379) = Pr4 - c8(323): c8(380) = Pr4 - c8(324):
c8(381) = Pr4 - c8(325): c8(382) = Pr4 - c8(326): c8(383) = Pr4 - c8(327): c8(384) = Pr4 - c8(321)
c8(441) = Pr4 - c8(392): c8(442) = Pr4 - c8(386): c8(443) = Pr4 - c8(387): c8(444) = Pr4 - c8(388):
c8(445) = Pr4 - c8(389): c8(446) = Pr4 - c8(390): c8(447) = Pr4 - c8(391): c8(448) = Pr4 - c8(385)
c8(505) = Pr4 - c8(8): c8(506) = Pr4 - c8(2): c8(507) = Pr4 - c8(3): c8(508) = Pr4 - c8(4):
c8(509) = Pr4 - c8(5): c8(510) = Pr4 - c8(6): c8(511) = Pr4 - c8(7): c8(512) = Pr4 - c8(1)
End Select
Return
' Complete Cube
1300
' Left Square
c8(73) = a(10): c8(81) = a(11): c8(89) = a(12): c8(97) = a(13): c8(105) = a(14): c8(113) = a(15):
c8(137) = a(18): c8(145) = a(19): c8(153) = a(20): c8(161) = a(21): c8(169) = a(22): c8(177) = a(23):
c8(201) = a(26): c8(209) = a(27): c8(217) = a(28): c8(225) = a(29): c8(233) = a(30): c8(241) = a(31):
c8(265) = a(34): c8(273) = a(35): c8(281) = a(36): c8(289) = a(37): c8(297) = a(38): c8(305) = a(39):
c8(329) = a(42): c8(337) = a(43): c8(345) = a(44): c8(353) = a(45): c8(361) = a(46): c8(369) = a(47):
c8(393) = a(50): c8(401) = a(51): c8(409) = a(52): c8(417) = a(53): c8(425) = a(54): c8(433) = a(55):
' Right Square
c8(80) = Pr4 - c8(73): c8(88) = Pr4 - c8(81): c8(96) = Pr4 - c8(89): c8(104) = Pr4 - c8(97):
c8(112) = Pr4 - c8(105): c8(120) = Pr4 - c8(113):
c8(144) = Pr4 - c8(137): c8(152) = Pr4 - c8(145): c8(160) = Pr4 - c8(153): c8(168) = Pr4 - c8(161):
c8(176) = Pr4 - c8(169): c8(184) = Pr4 - c8(177):
c8(208) = Pr4 - c8(201): c8(216) = Pr4 - c8(209): c8(224) = Pr4 - c8(217): c8(232) = Pr4 - c8(225):
c8(240) = Pr4 - c8(233): c8(248) = Pr4 - c8(241):
c8(272) = Pr4 - c8(265): c8(280) = Pr4 - c8(273): c8(288) = Pr4 - c8(281): c8(296) = Pr4 - c8(289):
c8(304) = Pr4 - c8(297): c8(312) = Pr4 - c8(305):
c8(336) = Pr4 - c8(329): c8(344) = Pr4 - c8(337): c8(352) = Pr4 - c8(345): c8(360) = Pr4 - c8(353):
c8(368) = Pr4 - c8(361): c8(376) = Pr4 - c8(369):
c8(400) = Pr4 - c8(393): c8(408) = Pr4 - c8(401): c8(416) = Pr4 - c8(409): c8(424) = Pr4 - c8(417):
c8(432) = Pr4 - c8(425): c8(440) = Pr4 - c8(433):
Return
' Print results (8 plane format)
1750 n2 = n2 + 1
If n2 = 4 Then
n2 = 1: k1 = k1 + 72: k2 = 1
Else
If n9 > 1 Then k2 = k2 + 9
End If
Cells(k1, k2 + 1).Select
Cells(k1, k2 + 1).Font.Color = -4165632
Cells(k1, k2 + 1).Value = "MC = " + CStr(s8)
i3 = 0
For i0 = 1 To 8
For i1 = 1 To 8
For i2 = 1 To 8
i3 = i3 + 1
Cells(k1 + i1 + (i0 - 1) * 9, k2 + i2).Value = c8(i3)
Next i2
Next i1
Next i0
Return
' Exclude solutions with identical numbers a()
1800 fl1 = 1
For j1 = 1 To 64
a2 = a(j1): If a2 = 0 Then GoTo 1805
For j2 = (1 + j1) To 64
If a2 = a(j2) Then fl1 = 0: Return
Next j2
1805 Next j1
Return
' Read Prime Numbers From sheet Sht1
1810 Erase b1
Pr4 = Sheets(Sht1).Cells(rcrd1a, 1).Value
s1 = 2 * Pr4: s8 = 4 * Pr4
nVar = Sheets(Sht1).Cells(rcrd1a, 5).Value
m1 = 1: m2 = nVar
For i1 = m1 To m2
x = Sheets(Sht1).Cells(rcrd1a, i1 + 6).Value
b1(x) = x
Next i1
pMax = Sheets(Sht1).Cells(rcrd1a, m2 + 6).Value
Return
' Define a1()
1820 n10 = 0
For i1 = 1 To pMax
If b1(i1) > 0 Then
n10 = n10 + 1: a1(n10) = b1(i1)
End If
Next i1
m2 = n10: n10 = 0
Return
' Remove used primes from available primes
1900 For i1 = 1 To 16
b1(a11(i1)) = 0
b1(Pr4 - a11(i1)) = 0 'Complement
b1(a12(i1)) = 0
b1(Pr4 - a12(i1)) = 0 'Complement
Next i1
Return
End Sub