Vorige Pagina About the Author

' Constructs Associated Magic Cubes (6 x 6 x 6)
' Magic Center Planes, Trenkler Principle

' Tested with Office 2007 under Windows 7

Sub MgcCube6c()

Dim c(216), b(6), b1(27), a(216), d(4), s(12)

y = MsgBox("Blocked", 0, "MgcCube6c")
End

Sheets("Klad1").Select

' Define Simple Magic Cube

b1(19) = 10: b1(20) = 8:  b1(21) = 24: b1(22) = 5:  b1(23) = 21: b1(24) = 16: b1(25) = 27: b1(26) = 13: b1(27) = 2:
b1(10) = 6:  b1(11) = 19: b1(12) = 17: b1(13) = 25: b1(14) = 14: b1(15) = 3:  b1(16) = 11: b1(17) = 9:  b1(18) = 22:
b1(1) = 26:  b1(2) = 15:  b1(3) = 1:   b1(4) = 12:  b1(5) = 7:   b1(6) = 23:  b1(7) = 4:   b1(8) = 20:  b1(9) = 18:

n1 = 0: n9 = 0: n10 = 0: k1 = 1: k2 = 1
m1 = 1: m2 = 8: s1 = 21

t1 = Timer

' Center Planes

'Row 1

For j108 = m1 To m2                                          'c(108)
c(108) = j108 - 1

For j107 = m1 To m2                                          'c(107)
c(107) = j107 - 1
If c(107) = c(108) Then GoTo 1070

For j106 = m1 To m2                                          'c(106)
c(106) = j106 - 1

For j105 = m1 To m2                                          'c(105)
c(105) = j105 - 1
If c(105) = c(106) Then GoTo 1050

For j104 = m1 To m2                                          'c(104)
c(104) = j104 - 1

c(103) = s1 - c(104) - c(105) - c(106) - c(107) - c(108)
If c(103) < 0 Or c(103) > 7 Then GoTo 1040
If c(103) = c(104) Then GoTo 1040
        
'Diagonal 1

For j101 = m1 To m2                                          'c(101)
c(101) = j101 - 1
If c(101) = c(107) Or c(101) = c(108) Then GoTo 1010

For j94 = m1 To m2                                           'c(94)
c(94) = j94 - 1

For j87 = m1 To m2                                           'c(87)
c(87) = j87 - 1
If c(87) = c(94) Then GoTo 870
If c(87) = 7 - c(94) Then GoTo 870

For j80 = m1 To m2                                           'c(80)
c(80) = j80 - 1
If c(80) = 7 - c(101) Or c(80) = 7 - c(107) Or c(80) = 7 - c(108) Then GoTo 800

c(73) = s1 - c(80) - c(87) - c(94) - c(101) - c(108)
If c(73) < 0 Or c(73) > 7 Then GoTo 800
If c(73) = c(80) Then GoTo 800
If c(73) = 7 - c(101) Or c(73) = 7 - c(107) Or c(73) = 7 - c(108) Then GoTo 800
        
'Column 2

For j95 = m1 To m2                                           'c(95)
c(95) = j95 - 1

For j89 = m1 To m2                                           'c(89)
c(89) = j89 - 1
If c(89) = c(95) Then GoTo 890

For j83 = m1 To m2                                           'c(83)
c(83) = j83 - 1
If c(83) = 7 - c(103) Or c(83) = 7 - c(104) Then GoTo 830

c(77) = s1 - c(83) - c(89) - c(95) - c(101) - c(107)
If c(77) < 0 Or c(77) > 7 Then GoTo 830
If c(77) = c(83) Then GoTo 830
If c(77) = 7 - c(103) Or c(77) = 7 - c(104) Then GoTo 830
        
'Diagonal 2

For j98 = m1 To m2                                           'c(98)
c(98) = j98 - 1
If c(98) = c(103) Or c(98) = c(104) Then GoTo 980
If c(98) = 7 - c(77) Or c(98) = 7 - c(83) Then GoTo 980

For j93 = m1 To m2                                           'c(93)
c(93) = j93 - 1
If c(93) = c(87) Or c(93) = c(94) Then GoTo 930
If c(93) = 7 - c(87) Or c(93) = 7 - c(94) Then GoTo 930

For j88 = m1 To m2                                           'c(88)
c(88) = j88 - 1
If c(88) = c(87) Or c(88) = c(93) Or c(88) = c(94) Then GoTo 880
If c(88) = 7 - c(87) Or c(88) = 7 - c(93) Or c(88) = 7 - c(94) Then GoTo 880

c(78) = s1 - c(83) - c(88) - c(93) - c(98) - c(103)
If c(78) < 0 Or c(78) > 7 Then GoTo 880
If c(78) = c(77) Or c(78) = c(83) Then GoTo 880
If c(78) = 7 - c(98) Or c(78) = 7 - c(103) Or c(78) = 7 - c(104) Then GoTo 880
        
'Column 5

For j92 = m1 To m2                                           'c(92)
c(92) = j92 - 1
If c(92) = 7 - c(89) Or c(92) = 7 - c(95) Then GoTo 920

For j86 = m1 To m2                                           'c(86)
c(86) = j86 - 1
If c(86) = c(92) Then GoTo 860
If c(86) = 7 - c(89) Or c(86) = 7 - c(95) Then GoTo 860

c(74) = s1 - c(80) - c(86) - c(92) - c(98) - c(104)
If c(74) < 0 Or c(74) > 7 Then GoTo 860
If c(74) = c(73) Or c(74) = c(80) Then GoTo 860
If c(74) = 7 - c(101) Or c(74) = 7 - c(107) Or c(74) = 7 - c(108) Then GoTo 860

'Row 6

For j75 = m1 To m2                                           'c(75)
c(75) = j75 - 1
If c(75) = 7 - c(105) Or c(75) = 7 - c(106) Then GoTo 750

c(76) = s1 - c(73) - c(74) - c(75) - c(77) - c(78)
If c(76) < 0 Or c(76) > 7 Then GoTo 750
If c(76) = c(75) Then GoTo 750
If c(76) = 7 - c(105) Or c(76) = 7 - c(106) Then GoTo 750

'Column 3

For j100 = m1 To m2                                          'c(100)
c(100) = j100 - 1
If c(100) = c(105) Or c(100) = c(106) Then GoTo 1000
If c(100) = 7 - c(75) Or c(100) = 7 - c(76) Then GoTo 1000

c(82) = s1 - c(76) - c(88) - c(94) - c(100) - c(106)
If c(82) < 0 Or c(82) > 7 Then GoTo 1000
If c(82) = c(75) Or c(82) = c(76) Then GoTo 1000
If c(82) = 7 - c(100) Or c(82) = 7 - c(105) Or c(82) = 7 - c(106) Then GoTo 1000

'Column 4

For j99 = m1 To m2                                           'c(99)
c(99) = j99 - 1
If c(99) = c(100) Or c(99) = c(105) Or c(99) = c(106) Then GoTo 990
If c(99) = 7 - c(75) Or c(99) = 7 - c(76) Or c(99) = 7 - c(82) Then GoTo 990

c(81) = s1 - c(75) - c(87) - c(93) - c(99) - c(105)
If c(81) < 0 Or c(81) > 7 Then GoTo 990
If c(81) = c(75) Or c(81) = c(76) Or c(81) = c(82) Then GoTo 990
If c(81) = 7 - c(99) Or c(81) = 7 - c(100) Or c(81) = 7 - c(105) Or c(81) = 7 - c(106) Then GoTo 1000

'Row 3

For j96 = m1 To m2                                           'c(96)
c(96) = j96 - 1
If c(96) = c(89) Or c(96) = c(95) Then GoTo 960
If c(96) = 7 - c(86) Or c(96) = 7 - c(92) Then GoTo 960

c(91) = s1 - c(92) - c(93) - c(94) - c(95) - c(96)
If c(91) < 0 Or c(91) > 7 Then GoTo 960
If c(91) = c(86) Or c(91) = c(92) Then GoTo 960
If c(91) = 7 - c(89) Or 7 - c(95) = 7 - c(96) Then GoTo 960

'Row 4

For j90 = m1 To m2                                           'c(90)
c(90) = j90 - 1
If c(90) = c(89) Or c(90) = c(95) Or c(90) = c(96) Then GoTo 900
If c(90) = 7 - c(86) Or c(90) = 7 - c(91) Or c(90) = 7 - c(92) Then GoTo 900

c(85) = s1 - c(86) - c(87) - c(88) - c(89) - c(90)
If c(85) < 0 Or c(85) > 7 Then GoTo 900
If c(85) = c(86) Or c(85) = c(91) Or c(85) = c(92) Then GoTo 900
If c(85) = 7 - c(89) Or c(85) = 7 - c(90) Or c(85) = 7 - c(95) Or c(85) = 7 - c(96) Then GoTo 900

'Remainder

For j84 = m1 To m2                                           'c(84)
c(84) = j84 - 1
If c(84) = c(77) Or c(84) = c(78) Or c(84) = c(83) Then GoTo 840
If c(84) = 7 - c(98) Or c(84) = 7 - c(103) Or c(84) = 7 - c(104) Then GoTo 840

c(79) = s1 - c(80) - c(81) - c(82) - c(83) - c(84)
If c(79) < 0 Or c(79) > 7 Then GoTo 840
If c(79) = c(73) Or c(79) = c(74) Or c(79) = c(80) Then GoTo 840
If c(79) = 7 - c(101) Or c(79) = 7 - c(107) Or c(79) = 7 - c(108) Then GoTo 840

c(97) = s1 - c(73) - c(79) - c(85) - c(91) - c(103)
If c(97) < 0 Or c(97) > 7 Then GoTo 840
If c(97) = c(103) Or c(97) = c(104) Or c(97) = c(98) Then GoTo 840
If c(97) = 7 - c(77) Or c(97) = 7 - c(78) Or c(97) = 7 - c(83) Or c(97) = 7 - c(84) Then GoTo 840

c(102) = s1 - c(84) - c(90) - c(96) - c(78) - c(108)
If c(102) < 0 Or c(102) > 7 Then GoTo 840
If c(102) = c(101) Or c(102) = c(107) Or c(102) = c(108) Then GoTo 840
If c(102) = 7 - c(97) Or c(102) = 7 - c(98) Or c(102) = 7 - c(103) Or c(102) = 7 - c(104) Then GoTo 840

i2 = 109
For i1 = 109 To 144
    i2 = i2 - 1
    c(i1) = 7 - c(i2)
Next i1

'Center Plane L3

'Diagonals

For j183 = m1 To m2
c(183) = j183 - 1

For j153 = m1 To m2
c(153) = j153 - 1
If c(153) = c(183) Then GoTo 1530

For j63 = m1 To m2
c(63) = j63 - 1
If c(63) = 7 - c(153) Or c(63) = 7 - c(183) Then GoTo 630

c(33) = s1 - c(63) - c(93) - c(123) - c(153) - c(183)
If c(33) < 0 Or c(33) > 7 Then GoTo 630
If c(33) = c(63) Then GoTo 630
If c(33) = 7 - c(153) Or c(33) = 7 - c(183) Then GoTo 630

For j213 = m1 To m2
c(213) = j213 - 1

For j171 = m1 To m2
c(171) = j171 - 1
If c(171) = c(213) Then GoTo 1710

For j45 = m1 To m2
c(45) = j45 - 1
If c(45) = 7 - c(171) Or c(45) = 7 - c(213) Then GoTo 450

c(3) = s1 - c(45) - c(87) - c(129) - c(171) - c(213)
If c(3) < 0 Or c(3) > 7 Then GoTo 450
If c(3) = c(45) Then GoTo 450
If c(3) = 7 - c(171) Or c(3) = 7 - c(213) Then GoTo 450

For j27 = m1 To m2
c(27) = j27 - 1
If c(27) = c(33) Or c(27) = c(63) Then GoTo 270
If c(27) = 7 - c(153) Or c(27) = 7 - c(183) Then GoTo 270

c(207) = s1 - c(171) - c(135) - c(99) - c(63) - c(27)
If c(207) < 0 Or c(207) > 7 Then GoTo 270
If c(207) = c(171) Or c(207) = c(213) Then GoTo 270
If c(207) = 7 - c(3) Or c(207) = 7 - c(45) Then GoTo 270

For j9 = m1 To m2
c(9) = j9 - 1
If c(9) = c(3) Or c(9) = c(45) Then GoTo 90
If c(9) = 7 - c(171) Or c(9) = 7 - c(207) Or c(9) = 7 - c(213) Then GoTo 90

c(189) = s1 - c(153) - c(117) - c(81) - c(45) - c(9)
If c(189) < 0 Or c(189) > 7 Then GoTo 90
If c(189) = c(153) Or c(189) = c(183) Then GoTo 90
If c(189) = 7 - c(27) Or c(189) = 7 - c(33) Or c(189) = 7 - c(63) Then GoTo 90

For j21 = m1 To m2
c(21) = j21 - 1

c(15) = s1 - c(3) - c(9) - c(21) - c(27) - c(33)
If c(15) < 0 Or c(15) > 7 Then GoTo 90
If c(15) = c(21) Then GoTo 210

For j201 = m1 To m2
c(201) = j201 - 1
If c(201) = 7 - c(15) Or c(201) = 7 - c(21) Then GoTo 2010

c(195) = s1 - c(183) - c(189) - c(201) - c(207) - c(213)
If c(195) < 0 Or c(195) > 7 Then GoTo 2010
If c(195) = c(201) Then GoTo 2010
If c(195) = 7 - c(15) Or c(195) = 7 - c(21) Then GoTo 2010

For j57 = m1 To m2
c(57) = j57 - 1
If c(57) = c(15) Or c(57) = c(21) Then GoTo 570
If c(57) = 7 - c(195) Or c(57) = 7 - c(201) Then GoTo 570

c(165) = s1 - c(201) - c(129) - c(93) - c(57) - c(21)
If c(165) < 0 Or c(165) > 7 Then GoTo 570
If c(165) = c(195) Or c(165) = c(201) Then GoTo 570
If c(165) = 7 - c(15) Or c(165) = 7 - c(21) Or c(165) = 7 - c(57) Then GoTo 570

For j51 = m1 To m2
c(51) = j51 - 1
If c(51) = c(15) Or c(51) = c(21) Or c(51) = c(57) Then GoTo 510
If c(51) = 7 - c(165) Or c(51) = 7 - c(195) Or c(51) = 7 - c(201) Then GoTo 510

c(159) = s1 - c(195) - c(123) - c(87) - c(51) - c(15)
If c(159) < 0 Or c(159) > 7 Then GoTo 510
If c(159) = c(165) Or c(159) = c(195) Or c(159) = c(201) Then GoTo 510
If c(159) = 7 - c(15) Or c(159) = 7 - c(21) Or c(159) = 7 - c(51) Or c(159) = 7 - c(57) Then GoTo 510

For j39 = m1 To m2
c(39) = j39 - 1
If c(39) = c(3) Or c(39) = c(9) Or c(39) = c(45) Then GoTo 390
If c(39) = 7 - c(171) Or c(39) = 7 - c(207) Or c(39) = 7 - c(213) Then GoTo 390

c(69) = s1 - c(39) - c(45) - c(51) - c(57) - c(63)
If c(69) < 0 Or c(69) > 7 Then GoTo 390
If c(69) = c(27) Or c(69) = c(33) Or c(69) = c(63) Then GoTo 390
If c(69) = 7 - c(153) Or c(69) = 7 - c(183) Or c(69) = 7 - c(189) Then GoTo 390

c(177) = s1 - c(213) - c(141) - c(105) - c(69) - c(33)
If c(177) < 0 Or c(177) > 7 Then GoTo 390
If c(177) = c(171) Or c(177) = c(207) Or c(177) = c(213) Then GoTo 390
If c(177) = 7 - c(3) Or c(177) = 7 - c(9) Or c(177) = 7 - c(39) Or c(177) = 7 - c(45) Then GoTo 390

c(147) = s1 - c(153) - c(159) - c(165) - c(171) - c(177)
If c(147) < 0 Or c(147) > 7 Then GoTo 390
If c(147) = c(153) Or c(147) = c(183) Or c(147) = c(189) Then GoTo 390
If c(147) = 7 - c(27) Or c(147) = 7 - c(33) Or c(147) = 7 - c(63) Or c(147) = 7 - c(69) Then GoTo 390

c(184) = 7 - c(33): c(190) = 7 - c(27): c(196) = 7 - c(21): c(202) = 7 - c(15): c(208) = 7 - c(9):  c(214) = 7 - c(3):
c(148) = 7 - c(69): c(154) = 7 - c(63): c(160) = 7 - c(57): c(166) = 7 - c(51): c(172) = 7 - c(45): c(178) = 7 - c(39):
c(40) = 7 - c(177): c(46) = 7 - c(171): c(52) = 7 - c(165): c(58) = 7 - c(159): c(64) = 7 - c(153): c(70) = 7 - c(147):
c(4) = 7 - c(213):  c(10) = 7 - c(207): c(16) = 7 - c(201): c(22) = 7 - c(195): c(28) = 7 - c(189): c(34) = 7 - c(183):

For j24 = m1 To m2
c(24) = j39 - 1

For j59 = m1 To m2
c(59) = j59 - 1
If c(59) = c(24) Then GoTo 590

For j164 = m1 To m2
c(164) = j164 - 1
If c(164) = 7 - c(59) Or c(164) = 7 - c(24) Then GoTo 1640

c(199) = s1 - c(164) - c(129) - c(94) - c(59) - c(24)
If c(199) < 0 Or c(199) > 7 Then GoTo 1640
If c(199) = c(164) Then GoTo 1640
If c(199) = 7 - c(59) Or c(199) = 7 - c(24) Then GoTo 1640

For j19 = m1 To m2
c(19) = j19 - 1

For j56 = m1 To m2
c(56) = j56 - 1
If c(56) = c(19) Then GoTo 560

c(167) = (2*s1-2*c(56)-2*c(164)-2*c(59)-c(165)-c(166)+c(127)-c(129)-c(130)+c(132)+c(91)-c(93)-c(94)+c(96)-c(57)-c(58))/2

If c(167) < 0 Or c(167) > 7 Or CInt(c(167)) <> c(167) Then GoTo 560
If c(167) = 7 - c(56) Or c(167) = 7 - c(19) Then GoTo 560

c(204) = s1 - c(167) - c(130) - c(93) - c(56) - c(19)
If c(204) < 0 Or c(204) > 7 Then GoTo 560
If c(204) = c(167) Then GoTo 560
If c(204) = 7 - c(56) Or c(204) = 7 - c(19) Then GoTo 560

For j23 = m1 To m2
c(23) = j23 - 1
If c(23) = c(24) Or c(23) = c(59) Then GoTo 230
If c(23) = 7 - c(164) Or c(23) = 7 - c(199) Then GoTo 230

c(20) = s1 - c(23) - c(19) - c(24) - c(21) - c(22)
If c(20) < 0 Or c(20) > 7 Then GoTo 230
If c(20) = c(19) Or c(20) = c(56) Then GoTo 230
If c(20) = 7 - c(167) Or c(20) = 7 - c(204) Then GoTo 230

For j60 = m1 To m2
c(60) = j60 - 1
If c(60) = c(23) Or c(60) = c(24) Or c(60) = c(59) Then GoTo 600
If c(60) = 7 - c(164) Or c(60) = 7 - c(199) Then GoTo 600

c(55) = s1 - c(60) - c(56) - c(59) - c(57) - c(58)
If c(55) < 0 Or c(55) > 7 Then GoTo 600
If c(55) = c(19) Or c(55) = c(20) Or c(55) = c(56) Then GoTo 600
If c(55) = 7 - c(167) Or c(55) = 7 - c(204) Then GoTo 600

c(168) = s1 - c(60) - c(204) - c(24) - c(132) - c(96)
If c(168) < 0 Or c(168) > 7 Then GoTo 600
If c(168) = c(167) Or c(168) = c(204) Then GoTo 600
If c(168) = 7 - c(19) Or c(168) = 7 - c(20) Or c(168) = 7 - c(55) Or c(168) = 7 - c(56) Then GoTo 600

c(163) = s1 - c(55) - c(19) - c(199) - c(127) - c(91)
If c(163) < 0 Or c(163) > 7 Then GoTo 600
If c(163) = c(164) Or c(163) = c(199) Then GoTo 600
If c(163) = 7 - c(23) Or c(163) = 7 - c(24) Or c(163) = 7 - c(59) Or c(163) = 7 - c(60) Then GoTo 600

c(203) = s1 - c(23) - c(167) - c(59) - c(131) - c(95)
If c(203) < 0 Or c(203) > 7 Then GoTo 600
If c(203) = c(167) Or c(203) = c(168) Or c(203) = c(204) Then GoTo 600
If c(203) = 7 - c(19) Or c(203) = 7 - c(20) Or c(203) = 7 - c(55) Or c(203) = 7 - c(56) Then GoTo 600

c(200) = s1 - c(20) - c(56) - c(164) - c(128) - c(92)
If c(200) < 0 Or c(200) > 7 Then GoTo 600
If c(200) = c(163) Or c(200) = c(164) Or c(200) = c(199) Then GoTo 600
If c(200) = 7 - c(23) Or c(200) = 7 - c(24) Or c(200) = 7 - c(59) Or c(200) = 7 - c(60) Then GoTo 600

c(193) = 7 - c(24): c(194) = 7 - c(23): c(197) = 7 - c(20): c(198) = 7 - c(19):
c(157) = 7 - c(60): c(158) = 7 - c(59): c(161) = 7 - c(56): c(162) = 7 - c(55):
c(49) = 7 - c(168): c(50) = 7 - c(167): c(53) = 7 - c(164): c(54) = 7 - c(163):
c(13) = 7 - c(204): c(14) = 7 - c(203): c(17) = 7 - c(200): c(18) = 7 - c(199):

n6 = n6 + 1
Cells(k1, 1).Select: Cells(k1, 1).Value = n6

' Top/Bottom Planes

For j36 = m1 To m2
c(36) = j36 - 1

For j35 = m1 To m2
c(35) = j35 - 1
If c(35) = c(36) Then GoTo 350

For j32 = m1 To m2
c(32) = j32 - 1

c(31) = s1 - c(32) - c(35) - c(36) - c(33) - c(34)
If c(31) < 0 Or c(31) > 7 Then GoTo 320
If c(31) = c(32) Then GoTo 320

For j30 = m1 To m2
c(30) = j30 - 1
If c(30) = c(35) Or c(30) = c(36) Then GoTo 300

For j29 = m1 To m2
c(29) = j29 - 1
If c(29) = c(30) Or c(29) = c(35) Or c(29) = c(36) Then GoTo 290

For j26 = m1 To m2
c(26) = j26 - 1
If c(26) = c(31) Or c(26) = c(32) Then GoTo 260

c(25) = s1 - c(26) - c(29) - c(30) - c(27) - c(28)
If c(25) < 0 Or c(25) > 7 Then GoTo 260
If c(25) = c(26) Or c(25) = c(31) Or c(25) = c(32) Then GoTo 260

For j12 = m1 To m2
c(12) = j12 - 1

c(6) = s1 - c(12) - c(30) - c(36) - c(18) - c(24)
If c(6) < 0 Or c(6) > 7 Then GoTo 120
If c(6) = c(12) Then GoTo 120

For j11 = m1 To m2
c(11) = j11 - 1
If c(11) = c(6) Or c(11) = c(12) Then GoTo 110

c(5) = s1 - c(11) - c(29) - c(35) - c(17) - c(23)
If c(5) < 0 Or c(5) > 7 Then GoTo 110
If c(5) = c(6) Or c(5) = c(11) Or c(5) = c(12) Then GoTo 110

For j8 = m1 To m2
c(8) = j8 - 1

c(7) = s1 - c(8) - c(11) - c(12) - c(9) - c(10)
If c(7) < 0 Or c(7) > 7 Then GoTo 80
If c(7) = c(8) Then GoTo 80

c(2) = s1 - c(8) - c(26) - c(32) - c(14) - c(20)
If c(2) < 0 Or c(2) > 7 Then GoTo 80
If c(2) = c(7) Or c(2) = c(8) Then GoTo 80

c(1) = s1 - c(7) - c(25) - c(31) - c(13) - c(19)
If c(1) < 0 Or c(1) > 7 Then GoTo 80
If c(1) = c(2) Or c(1) = c(7) Or c(1) = c(8) Then GoTo 80

c(181) = 7 - c(36): c(182) = 7 - c(35): c(185) = 7 - c(32): c(186) = 7 - c(31):
c(187) = 7 - c(30): c(188) = 7 - c(29): c(191) = 7 - c(26): c(192) = 7 - c(25):
                    
c(205) = 7 - c(12): c(206) = 7 - c(11): c(209) = 7 - c(8):  c(210) = 7 - c(7):
c(211) = 7 - c(6):  c(212) = 7 - c(5):  c(215) = 7 - c(2):  c(216) = 7 - c(1):

For j180 = m1 To m2
c(180) = j180 - 1
If c(180) = c(209) Or c(180) = c(210) Or c(180) = c(215) Or c(180) = c(216) Then GoTo 1800

For j179 = m1 To m2
c(179) = j179 - 1
If c(179) = c(180) Then GoTo 1790
If c(179) = c(209) Or c(179) = c(210) Or c(179) = c(215) Or c(179) = c(216) Then GoTo 1790

For j176 = m1 To m2
c(176) = j176 - 1
If c(176) = c(205) Or c(176) = c(206) Or c(176) = c(211) Or c(176) = c(212) Then GoTo 1760

c(175) = s1 - c(176) - c(177) - c(178) - c(179) - c(180)
If c(175) < 0 Or c(175) > 7 Then GoTo 1760
If c(175) = c(176) Then GoTo 1760
If c(175) = c(205) Or c(175) = c(206) Or c(175) = c(211) Or c(175) = c(212) Then GoTo 1760

For j174 = m1 To m2
c(174) = j174 - 1
If c(174) = c(179) Or c(174) = c(180) Then GoTo 1740
If c(174) = c(209) Or c(174) = c(210) Or c(174) = c(215) Or c(174) = c(216) Then GoTo 1740

c(173) = 14 - c(174) - c(179) - c(180)
If c(173) < 0 Or c(173) > 7 Then GoTo 1740
If c(173) = c(174) Or c(173) = c(179) Or c(173) = c(180) Then GoTo 1740
If c(173) = c(209) Or c(173) = c(210) Or c(173) = c(215) Or c(173) = c(216) Then GoTo 1740

c(37) = 7 - c(180): c(38) = 7 - c(179)
c(43) = 7 - c(174): c(44) = 7 - c(173)

c(145) = s1 - c(181) - c(109) - c(73) - c(37) - c(1)
If c(145) < 0 Or c(145) > 7 Then GoTo 1740
If c(145) = c(181) Or c(145) = c(182) Or c(145) = c(187) Or c(145) = c(188) Then GoTo 1740

c(146) = s1 - c(182) - c(110) - c(74) - c(38) - c(2)
If c(146) < 0 Or c(146) > 7 Then GoTo 1740
If c(146) = c(145) Then GoTo 1740
If c(146) = c(181) Or c(146) = c(182) Or c(146) = c(187) Or c(146) = c(188) Then GoTo 1740

c(151) = s1 - c(187) - c(115) - c(79) - c(43) - c(7)
If c(151) < 0 Or c(151) > 7 Then GoTo 1740
If c(151) = c(145) Or c(151) = c(146) Then GoTo 1740
If c(151) = c(181) Or c(151) = c(182) Or c(151) = c(187) Or c(151) = c(188) Then GoTo 1740

c(152) = s1 - c(188) - c(116) - c(80) - c(44) - c(8)
If c(152) < 0 Or c(152) > 7 Then GoTo 1740
If c(152) = c(145) Or c(152) = c(146) Or c(152) = c(151) Then GoTo 1740
If c(152) = c(181) Or c(152) = c(182) Or c(152) = c(187) Or c(152) = c(188) Then GoTo 1740

c(65) = 7 - c(152): c(66) = 7 - c(151)
c(71) = 7 - c(146): c(72) = 7 - c(145)

c(170) = s1 - c(146) - c(152) - c(158) - c(164) - c(176)
If c(170) < 0 Or c(170) > 7 Then GoTo 1740
If c(170) = c(205) Or c(170) = c(206) Or c(170) = c(211) Or c(170) = c(212) Then GoTo 1740

c(169) = s1 - c(145) - c(151) - c(157) - c(163) - c(175)
If c(169) < 0 Or c(169) > 7 Then GoTo 1740
If c(169) = c(205) Or c(169) = c(206) Or c(169) = c(211) Or c(169) = c(212) Then GoTo 1740

c(61) = s1 - c(205) - c(169) - c(133) - c(97) - c(25)
If c(61) < 0 Or c(61) > 7 Then GoTo 1740
If c(61) = c(25) Or c(61) = c(26) Or c(61) = c(31) Or c(61) = c(32) Then GoTo 1740

c(62) = s1 - c(206) - c(170) - c(134) - c(98) - c(26)
If c(62) < 0 Or c(62) > 7 Then GoTo 1740
If c(62) = c(61) Then GoTo 1740
If c(62) = c(25) Or c(62) = c(26) Or c(62) = c(31) Or c(62) = c(32) Then GoTo 1740

c(67) = s1 - c(211) - c(175) - c(139) - c(103) - c(31)
If c(67) < 0 Or c(67) > 7 Then GoTo 1740
If c(67) = c(61) Or c(67) = c(62) Then GoTo 1740
If c(67) = c(25) Or c(67) = c(26) Or c(67) = c(31) Or c(67) = c(32) Then GoTo 1740

c(68) = s1 - c(212) - c(176) - c(140) - c(104) - c(32)
If c(68) < 0 Or c(68) > 7 Then GoTo 1740
If c(68) = c(61) Or c(68) = c(62) Or c(68) = c(67) Then GoTo 1740
If c(68) = c(25) Or c(68) = c(26) Or c(68) = c(31) Or c(68) = c(32) Then GoTo 1740

c(149) = 7 - c(68): c(150) = 7 - c(67)
c(155) = 7 - c(62): c(156) = 7 - c(61)

c(41) = s1 - c(185) - c(149) - c(113) - c(77) - c(5)
If c(41) < 0 Or c(41) > 7 Then GoTo 1740
If c(41) = c(5) Or c(41) = c(6) Or c(41) = c(11) Or c(41) = c(12) Then GoTo 1740

c(42) = s1 - c(186) - c(150) - c(114) - c(78) - c(6)
If c(42) < 0 Or c(42) > 7 Then GoTo 1740
If c(42) = c(11) Then GoTo 1740
If c(42) = c(5) Or c(42) = c(6) Or c(42) = c(11) Or c(42) = c(12) Then GoTo 1740

c(47) = s1 - c(191) - c(155) - c(119) - c(83) - c(11)
If c(47) < 0 Or c(47) > 7 Then GoTo 1740
If c(47) = c(41) Or c(47) = c(42) Then GoTo 1740
If c(47) = c(5) Or c(47) = c(6) Or c(47) = c(11) Or c(47) = c(12) Then GoTo 1740

c(48) = s1 - c(192) - c(156) - c(120) - c(84) - c(12)
If c(48) < 0 Or c(48) > 7 Then GoTo 1740
If c(48) = c(41) Or c(48) = c(42) Or c(48) = c(47) Then GoTo 1740
If c(48) = c(5) Or c(48) = c(6) Or c(48) = c(11) Or c(48) = c(12) Then GoTo 1740


          MC6 = 21: GoSub 2000: If fl1 = 0 Then GoTo 5       'Back Check Trenkler Cube
    
          GoSub 2800                                         'Contruct Simple Magic Cube
          GoSub 2850: If fl1 = 0 Then GoTo 1740              'Back Check Identical Numbers
        
          n9 = n9 + 1: GoSub 2750                            'Print Cube

5

1740 Next j174

1760 Next j176
1790 Next j179
1800 Next j180

80  Next j8
110 Next j11
120 Next j12

260 Next j26
290 Next j29
300 Next j30

320 Next j32
350 Next j35
360 Next j36

600 Next j60
230 Next j23

560 Next j56
190 Next j19

1640 Next j164
590 Next j59
240 Next j24

390 Next j39

510 Next j51

570 Next j57

2010 Next j201
210 Next j21

90 Next j9
270 Next j27

450 Next j45
1710 Next j171
2130 Next j213

630 Next j63
1530 Next j153
1830 Next j183

840 Next j84
900 Next j90
960 Next j96
990 Next j99
1000 Next j100
750  Next j75

860 Next j86
920 Next j92

880 Next j88
930 Next j93
980 Next j98

830 Next j83
890 Next j89
950 Next j95

800  Next j80
870  Next j87
940  Next j94
1010 Next j101

1040 Next j104
1050 Next j105
1060 Next j106
1070 Next j107
1080 Next j108

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

End

'    Back Check Magic Constant

2000 fl1 = 1

'   Rows
    
    i1 = -5
    For i0 = 1 To 36
        i1 = i1 + 6
        b(1) = c(i1): b(2) = c(i1 + 1): b(3) = c(i1 + 2): b(4) = c(i1 + 3): b(5) = c(i1 + 4): b(6) = c(i1 + 5)
        GoSub 2860
        If fl1 = 0 Then Return
    Next i0
   
'   Columns
    
    i1 = 0: i2 = 0
    For i0 = 1 To 36
        i1 = i1 + 1
        b(1) = c(i1): b(2) = c(i1 + 6): b(3) = c(i1 + 12): b(4) = c(i1 + 18): b(5) = c(i1 + 24): b(6) = c(i1 + 30)
        i2 = i2 + 1: If i2 = 6 Then i2 = 0: i1 = i1 + 30
        GoSub 2860
        If fl1 = 0 Then Return
    Next i0
    
'   Pillars
    
    i1 = 0: i2 = 0
    For i0 = 1 To 36
        i1 = i0
        b(1) = c(i1): b(2) = c(i1 + 36): b(3) = c(i1 + 72): b(4) = c(i1 + 108): b(5) = c(i1 + 144): b(6) = c(i1 + 180)
        GoSub 2860
        If fl1 = 0 Then Return
    Next i0

'   Accociated Pairs

    For i1 = 1 To 108
        s2 = c(i1) + c(216 + 1 - i1)
        If s2 <> 7 Then fl1 = 0: Return
    Next i1

'   Plane Diagonals

'   Hor Planes
    
    s(1) = c(109) + c(116) + c(123) + c(130) + c(137) + c(144)
    s(2) = c(139) + c(134) + c(129) + c(124) + c(119) + c(114)
    s(3) = c(73) + c(80) + c(87) + c(94) + c(101) + c(108)
    s(4) = c(103) + c(98) + c(93) + c(88) + c(83) + c(78)
    
'   Vert Planes L/R
    
    s(5) = c(183) + c(153) + c(123) + c(93) + c(63) + c(33)
    s(6) = c(184) + c(154) + c(124) + c(94) + c(64) + c(34)
    s(7) = c(213) + c(171) + c(129) + c(87) + c(45) + c(3)
    s(8) = c(214) + c(172) + c(130) + c(88) + c(46) + c(4)
    
'   Vert Planes B/F
    
    s(9) = c(193) + c(158) + c(123) + c(88) + c(53) + c(18)
    s(10) = c(198) + c(161) + c(124) + c(87) + c(50) + c(13)
    s(11) = c(199) + c(164) + c(129) + c(94) + c(59) + c(24)
    s(12) = c(204) + c(167) + c(130) + c(93) + c(56) + c(19)
 
    fl1 = 1
    For i1 = 1 To 12
        If s(i1) <> MC6 Then fl1 = 0: Return
    Next i1

    Return

'    Check MC6

2860 fl1 = 1
     If b(1) + b(2) + b(3) + b(4) + b(5) + b(6) <> MC6 Then fl1 = 0
     Return

'    Print Cubes (6 plane format)

2750 n2 = n2 + 1
     If n2 = 5 Then
         n2 = 1: k1 = k1 + 42: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 7
     End If

     Cells(k1, k2 + 1).Select
     Cells(k1, k2 + 1).Font.Color = -4165632
     Cells(k1, k2 + 1).Value = n9
       
     For i0 = 1 To 6
         i3 = (6 - i0) * 36
         For i1 = 1 To 6
             For i2 = 1 To 6
                 i3 = i3 + 1
                 Cells(k1 + i1 + (i0 - 1) * 7, k2 + i2).Value = c(i3)   'Trenkler Cube
'                Cells(k1 + i1 + (i0 - 1) * 7, k2 + i2).Value = a(i3)   'Simple Magic Cube
             Next i2
         Next i1
     Next i0
    
     Return

'    Calculate Simple Magic Cubes

2800

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

a(4) = b1(2) + 27 * c(4):      a(5) = b1(3) + 27 * c(5):      a(6) = b1(3) + 27 * c(6):
a(10) = b1(2) + 27 * c(10):    a(11) = b1(3) + 27 * c(11):    a(12) = b1(3) + 27 * c(12):
a(16) = b1(5) + 27 * c(16):    a(17) = b1(6) + 27 * c(17):    a(18) = b1(6) + 27 * c(18):
a(22) = b1(5) + 27 * c(22):    a(23) = b1(6) + 27 * c(23):    a(24) = b1(6) + 27 * c(24):
a(28) = b1(8) + 27 * c(28):    a(29) = b1(9) + 27 * c(29):    a(30) = b1(9) + 27 * c(30):
a(34) = b1(8) + 27 * c(34):    a(35) = b1(9) + 27 * c(35):    a(36) = b1(9) + 27 * c(36):

Return

'    Check Identical Numbers (Back Check)

2850 fl1 = 1
     For i1 = 1 To 216
     a20 = a(i1)
     For i2 = i1 + 1 To 216
         If a20 = a(i2) Then fl1 = 0: Return
     Next i2
     Next i1

     Return

End Sub

Vorige Pagina About the Author