Vorige Pagina About the Author

' Generates Moriyama Sudoku Comparable Cubes of order 5 for integers 0 thru 4 (Associated and Non-Associated)

' Tested with Office 2007 under Windows 7

Sub SudCube5d1()

Dim a(125), b(5)

y = MsgBox("Locked", vbCritical, "Routine SudCube5d")
End

n2 = 0: n9 = 0: k1 = 1: k2 = 1
m1 = 0: m2 = 4: s1 = 10
  
     Sheets("Klad1").Select
    
     t1 = Timer

'    Generate Cubes

     a(63) = (m1 + m2)/2

     For j125 = m1 To m2
     a(125) = j125

     For j124 = m1 To m2
     a(124) = j124

     For j123 = m1 To m2
     a(123) = j123

     For j122 = m1 To m2
     a(122) = j122

     a(121) = s1 - a(122) - a(123) - a(124) - a(125)
     If a(121) < m1 Or a(121) > m2 Then GoTo 1220

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

     a(105) = s1 - a(120) - a(122) - a(123) - a(125)
     If a(105) < m1 Or a(105) > m2 Then GoTo 1200

     For j119 = m1 To m2
     a(119) = j119
     
     a(104) = -a(119) + a(123) + a(125)
     If a(104) < m1 Or a(104) > m2 Then GoTo 1190

     For j118 = m1 To m2
     a(118) = j118
  
     a(114) = a(118) + a(120) - a(124)
     If a(114) < m1 Or a(114) > m2 Then GoTo 1180
     a(109) = s1 - a(118) - a(120) - a(123) - a(125)
     If a(109) < m1 Or a(109) > m2 Then GoTo 1180
     a(103) = -a(118) + a(122) + a(124)
     If a(103) < m1 Or a(103) > m2 Then GoTo 1180
     a(38) = -s1/5 - a(118) + a(122) + a(123) + a(124)
     If a(38) < m1 Or a(38) > m2 Then GoTo 1180
  
     For j117 = m1 To m2
     a(117) = j117

     a(116) = s1 - a(117) - a(118) - a(119) - a(120)
     If a(116) < m1 Or a(116) > m2 Then GoTo 1170
     a(115) = s1 - a(117) - a(118) - a(120) - a(125)
     If a(115) < m1 Or a(115) > m2 Then GoTo 1170
     a(113) = a(117) + a(119) - a(123)
     If a(113) < m1 Or a(113) > m2 Then GoTo 1170
     a(112) = s1 - a(117) - a(119) - a(120) - a(122)
     If a(112) < m1 Or a(112) > m2 Then GoTo 1170
     a(111) = -s1 + a(117) + a(120) + a(122) + a(123) + a(124) + a(125)
     If a(111) < m1 Or a(111) > m2 Then GoTo 1170
     a(110) = -s1 + a(117) + a(118) + a(120) + a(122) + a(123) + a(125)
     If a(110) < m1 Or a(110) > m2 Then GoTo 1170
     a(108) = s1 - a(117) - a(119) - a(122) - a(124)
     If a(108) < m1 Or a(108) > m2 Then GoTo 1170
     a(107) = -s1 + a(117) + a(119) + a(120) + a(122) + a(124) + a(125)
     If a(107) < m1 Or a(107) > m2 Then GoTo 1170
     a(106) = s1 - a(117) - a(120) - a(122) - a(125)
     If a(106) < m1 Or a(106) > m2 Then GoTo 1170
     a(102) = s1 - a(117) - a(122) - a(124) - a(125)
     If a(102) < m1 Or a(102) > m2 Then GoTo 1170
     a(101) = -s1 + a(117) + a(118) + a(119) + a(120) + a(122) + a(125)
     If a(101) < m1 Or a(101) > m2 Then GoTo 1170

     For j100 = m1 To m2
     a(100) = j100

     a(25) = s1 - a(100) - a(122) - a(123) - a(125)
     If a(25) < m1 Or a(25) > m2 Then GoTo 1000

     For j99 = m1 To m2
     a(99) = j99

     a(24) = -a(99) + a(123) + a(125)
     If a(24) < m1 Or a(24) > m2 Then GoTo 990

     For j98 = m1 To m2
     a(98) = j98

a(97) = (-a(98) + a(99) - 2*a(100) + 3*a(117) + a(118) - a(119) + 2*a(120))/3
If a(97) < m1 Or a(97) > m2 Or CInt(a(97)) <> a(97) Then GoTo 980

a(96) = (3*s1 - 2*a(98) - 4*a(99) - a(100) - 3*a(117) - a(118) + a(119) - 2*a(120))/3
If a(96) < m1 Or a(96) > m2 Or CInt(a(96)) <> a(96) Then GoTo 980

a(93) = (-3*s1/5 - 2*a(98) + 2*a(99) - a(100) + 3*a(117) - a(118) + a(119) + a(120) + 3*a(122) - 3*a(123) + 3*a(124))/3
If a(93) < m1 Or a(93) > m2 Or CInt(a(93)) <> a(93) Then GoTo 980

a(88) = (9*s1/5 - 4*a(98) - 2*a(99) + a(100) - 3*a(117) - 2*a(118) - a(119) - a(120) + 3*a(122) + 3*a(124))/3
If a(88) < m1 Or a(88) > m2 Or CInt(a(88)) <> a(88) Then GoTo 980

a(83) = (6*s1/5 + 2*a(98) - 2*a(99) + a(100) + a(118) + 2*a(119) - a(120) - 3*a(122) - 3*a(124))/3
If a(83) < m1 Or a(83) > m2 Or CInt(a(83)) <> a(83) Then GoTo 980

a(78) = (3*s1/5 + a(98) + 2*a(99) - a(100) + 2*a(118) - 2*a(119) + a(120) - 3*a(122) + 3*a(123) - 3*a(124))/3
If a(78) < m1 Or a(78) > m2 Or CInt(a(78)) <> a(78) Then GoTo 980

a(75) = (3*s1 - 2*a(98) - a(99) - a(100) - 3*a(117) - a(118) + a(119) - 2*a(120) - 3*a(125))/3
If a(75) < m1 Or a(75) > m2 Or CInt(a(75)) <> a(75) Then GoTo 980

a(74) = a(98) + a(100) - a(124)
If a(74) < m1 Or a(74) > m2 Then GoTo 980

a(73) = (-a(98) + 4*a(99) - 2*a(100) + 3*a(117) + a(118) - a(119) + 2*a(120) - 3*a(123))/3
If a(73) < m1 Or a(73) > m2 Or CInt(a(73)) <> a(73) Then GoTo 980

a(72) = (3*s1 + a(98) - 4*a(99) - a(100) - 3*a(117) - a(118) + a(119) - 2*a(120) - 3*a(122))/3
If a(72) < m1 Or a(72) > m2 Or CInt(a(72)) <> a(72) Then GoTo 980

a(71) = (-3*s1 - a(98) + a(99) + a(100) + 3*a(117) + a(118) - a(119) + 2*a(120) + 3*a(122) + 3*a(123) + 3*a(124) + 3*a(125))/3
If a(71) < m1 Or a(71) > m2 Or CInt(a(71)) <> a(71) Then GoTo 980

a(68) = (9*s1/5 - a(98) - 2*a(99) + a(100) - 3*a(117) - 5*a(118) - a(119) - a(120) + 3*a(122) + 3*a(124))/3
If a(68) < m1 Or a(68) > m2 Or CInt(a(68)) <> a(68) Then GoTo 980

a(58) = -s1/5 - a(98) + a(122) + a(123) + a(124)
If a(58) < m1 Or a(58) > m2 Then GoTo 980

a(53) = (6*s1/5 + 5*a(98) - 2*a(99) + a(100) + 4*a(118) + 2*a(119) - a(120) - 6*a(122) - 6*a(124))/3
If a(53) < m1 Or a(53) > m2 Or CInt(a(53)) <> a(53) Then GoTo 980

a(50) = (-3*s1 + 2*a(98) + a(99) + a(100) + 3*a(117) + a(118) - a(119) + 2*a(120) + 3*a(122) + 3*a(123) + 3*a(125))/3
If a(50) < m1 Or a(50) > m2 Or CInt(a(50)) <> a(50) Then GoTo 980

a(49) = s1 - a(98) - a(100) - a(123) - a(125)
If a(49) < m1 Or a(49) > m2 Then GoTo 980

a(48) = (3*s1 + a(98) - 4*a(99) + 2*a(100) - 3*a(117) - a(118) + a(119) - 2*a(120) - 3*a(122) - 3*a(124))/3
If a(48) < m1 Or a(48) > m2 Or CInt(a(48)) <> a(48) Then GoTo 980

a(47) = (-3*s1 - a(98) + 4*a(99) + a(100) + 3*a(117) + a(118) - a(119) + 2*a(120) + 3*a(122) + 3*a(124) + 3*a(125))/3
If a(47) < m1 Or a(47) > m2 Or CInt(a(47)) <> a(47) Then GoTo 980

a(46) = (3*s1 + a(98) - a(99) - a(100) - 3*a(117) - a(118) + a(119) - 2*a(120) - 3*a(122) - 3*a(125))/3
If a(46) < m1 Or a(46) > m2 Or CInt(a(46)) <> a(46) Then GoTo 980

a(43) = (6*s1/5 + a(98) + 2*a(99) - a(100) + 2*a(118) - 2*a(119) + a(120) - 3*a(122) - 3*a(124))/3
If a(43) < m1 Or a(43) > m2 Or CInt(a(43)) <> a(43) Then GoTo 980

a(33) = s1/5 + a(98) + a(118) - a(122) - a(124)
If a(33) < m1 Or a(33) > m2 Then GoTo 980

a(28) = (-6*s1/5 - 5*a(98) + 2*a(99) - a(100) + 3*a(117) - a(118) + a(119) + a(120) + 6*a(122) - 3*a(123) + 6*a(124))/3
If a(28) < m1 Or a(28) > m2 Or CInt(a(28)) <> a(28) Then GoTo 980

a(23) = -a(98) + a(122) + a(124)
If a(23) < m1 Or a(23) > m2 Then GoTo 980

a(22) = (3*s1 + a(98) - a(99) + 2*a(100) - 3*a(117) - a(118) + a(119) - 2*a(120) - 3*a(122) - 3*a(124) - 3*a(125))/3
If a(22) < m1 Or a(22) > m2 Or CInt(a(22)) <> a(22) Then GoTo 980

a(21) = (-3*s1 + 2*a(98) + 4*a(99) + a(100) + 3*a(117) + a(118) - a(119) + 2*a(120) + 3*a(122) + 3*a(125))/3
If a(21) < m1 Or a(21) > m2 Or CInt(a(21)) <> a(21) Then GoTo 980

a(18) = (3*s1/5 + 2*a(98) - 2*a(99) + a(100) + a(118) + 2*a(119) - a(120) - 3*a(122) + 3*a(123) - 3*a(124))/3
If a(18) < m1 Or a(18) > m2 Or CInt(a(18)) <> a(18) Then GoTo 980

a(13) = (6*s1/5 + 4*a(98) + 2*a(99) - a(100) + 5*a(118) - 2*a(119) + a(120) - 6*a(122) - 6*a(124))/3
If a(13) < m1 Or a(13) > m2 Or CInt(a(13)) <> a(13) Then GoTo 980

a(8) = (-6*s1/5 - 2*a(98) + 2*a(99) - a(100) + 3*a(117) - 4*a(118) + a(119) + a(120) + 6*a(122) - 3*a(123) + 6*a(124))/3
If a(8) < m1 Or a(8) > m2 Or CInt(a(8)) <> a(8) Then GoTo 980

a(3) = (12*s1/5 - a(98) - 2*a(99) + a(100) - 3*a(117) - 2*a(118) - a(119) - a(120))/3
If a(3) < m1 Or a(3) > m2 Or CInt(a(3)) <> a(3) Then GoTo 980
     
     For j95 = m1 To m2
     a(95) = j95

a(94) = (-21*s1/5 + a(95) + a(99) + 2*a(100) + 3*a(117) + a(118) + 4*a(120) + 4*a(122) + a(123) + 3*a(124) + 3*a(125))/2
If a(94) < m1 Or a(94) > m2 Or CInt(a(94)) <> a(94) Then GoTo 950

a(92) = (81*s1/5 - 3*a(95) - 2*a(98) - 7*a(99) - 4*a(100) - 15*a(117) - 7*a(118) - 2*a(119) - 14*a(120) - 6*a(122) - 3*a(123) - 3*a(124) - 9*a(125))/6
If a(92) < m1 Or a(92) > m2 Or CInt(a(92)) <> a(92) Then GoTo 950

a(91) = 3*s1/5 - a(95) + a(98) + a(118) - 2*a(122) + a(123) - 2*a(124)
If a(91) < m1 Or a(91) > m2 Then GoTo 950

a(90) = (-3*s1 - a(95) + 2*a(98) + a(99) + 3*a(117) + 3*a(118) + 4*a(120) + 3*a(123) - a(124) + 3*a(125))/2
If a(90) < m1 Or a(90) > m2 Or CInt(a(90)) <> a(90) Then GoTo 950

a(89) = (-3*s1/5 + 3*a(95) - 2*a(98) - a(99) - a(100) + 3*a(117) - a(118) + a(119) + a(120) + 3*a(122) - 3*a(123) + 3*a(124))/3
If a(89) < m1 Or a(89) > m2 Or CInt(a(89)) <> a(89) Then GoTo 950

a(87) = (6*s1/5 - 3*a(95) + 2*a(98) + a(99) + a(100) + a(118) + 2*a(119) - a(120) - 3*a(122) - 3*a(124))/3
If a(87) < m1 Or a(87) > m2 Or CInt(a(87)) <> a(87) Then GoTo 950

a(86) = (51*s1/5 + 3*a(95) + 2*a(98) + a(99) - 2*a(100) - 9*a(117) - 5*a(118) - 4*a(119) - 10*a(120) - 6*a(122) - 3*a(123) - 3*a(124) - 9*a(125))/6
If a(86) < m1 Or a(86) > m2 Or CInt(a(86)) <> a(86) Then GoTo 950

a(85) = (9*s1 + 3*a(95) - 2*a(98) - a(99) - 4*a(100) - 3*a(117) - 7*a(118) - 2*a(119) - 8*a(120) - 9*a(123) + 3*a(124) - 9*a(125))/6
If a(85) < m1 Or a(85) > m2 Or CInt(a(85)) <> a(85) Then GoTo 950

a(84) = (18*s1/5 - 3*a(95) - a(98) - 2*a(99) - 2*a(100) - 3*a(117) + a(118) - a(119) - a(120) - 3*a(122) + 3*a(123) - 3*a(124))/3
If a(84) < m1 Or a(84) > m2 Or CInt(a(84)) <> a(84) Then GoTo 950

a(82) = (-6*s1/5 + 3*a(95) - 2*a(98) + 2*a(99) + 2*a(100) - a(118) - 2*a(119) + a(120) + 3*a(122) + 3*a(124))/3
If a(82) < m1 Or a(82) > m2 Or CInt(a(82)) <> a(82) Then GoTo 950

a(81) = (-51*s1/5 - 3*a(95) + 4*a(98) + 5*a(99) + 2*a(100) + 9*a(117) + 5*a(118) + 4*a(119) + 10*a(120) + 6*a(122) + 3*a(123) + 3*a(124) + 9*a(125))/6
If a(81) < m1 Or a(81) > m2 Or CInt(a(81)) <> a(81) Then GoTo 950

a(80) = (3*s1 - 3*a(95) - 2*a(98) - a(99) - a(100) - 3*a(117) - a(118) + a(119) - 2*a(120))/3
If a(80) < m1 Or a(80) > m2 Or CInt(a(80)) <> a(80) Then GoTo 950

a(79) = (21*s1/5 - a(95) + 2*a(98) - a(99) - 3*a(117) - a(118) - 4*a(120) - 4*a(122) - a(123) - 3*a(124) - 3*a(125))/2
If a(79) < m1 Or a(79) > m2 Or CInt(a(79)) <> a(79) Then GoTo 950

a(77) = (-51*s1/5 + 3*a(95) + 4*a(98) - a(99) + 2*a(100) + 9*a(117) + 5*a(118) + 4*a(119) + 10*a(120) + 6*a(122) + 3*a(123) + 3*a(124) + 9*a(125))/6
If a(77) < m1 Or a(77) > m2 Or CInt(a(77)) <> a(77) Then GoTo 950

a(76) = (-9*s1/5 + 3*a(95) - 4*a(98) + a(99) + a(100) + 3*a(117) - 2*a(118) - a(119) + 2*a(120) + 6*a(122) - 3*a(123) + 6*a(124))/3
If a(76) < m1 Or a(76) > m2 Or CInt(a(76)) <> a(76) Then GoTo 950

a(70) = (-3*s1 - a(95) + 2*a(98) + a(99) + 2*a(100) + 3*a(117) + 3*a(118) + 2*a(120) + 3*a(123) - a(124) + 3*a(125))/2
If a(70) < m1 Or a(70) > m2 Or CInt(a(70)) <> a(70) Then GoTo 950

a(69) = (-3*s1/5 + 3*a(95) - 2*a(98) + 2*a(99) - a(100) + 3*a(117) - a(118) - 2*a(119) + a(120) + 3*a(122) - 3*a(123) + 3*a(124))/3
If a(69) < m1 Or a(69) > m2 Or CInt(a(69)) <> a(69) Then GoTo 950

a(67) = (6*s1/5 - 3*a(95) + a(98) + 2*a(99) - a(100) + 2*a(118) + a(119) + a(120) - 3*a(122) - 3*a(124))/3
If a(67) < m1 Or a(67) > m2 Or CInt(a(67)) <> a(67) Then GoTo 950

a(66) = (51*s1/5 + 3*a(95) - 2*a(98) - 7*a(99) - 4*a(100) - 9*a(117) - a(118) + 4*a(119) - 8*a(120) - 6*a(122) - 3*a(123) - 3*a(124) - 9*a(125))/6
If a(66) < m1 Or a(66) > m2 Or CInt(a(66)) <> a(66) Then GoTo 950

a(65) = (3*s1 + 9*a(95) - 2*a(98) - a(99) - 4*a(100) + 3*a(117) - a(118) - 2*a(119) - 2*a(120) - 9*a(123) + 3*a(124) - 3*a(125))/6
If a(65) < m1 Or a(65) > m2 Or CInt(a(65)) <> a(65) Then GoTo 950

a(64) = (-27*s1/5 - 3*a(95) - 2*a(98) - a(99) + 2*a(100) + 3*a(117) - a(118) - 2*a(119) + 4*a(120) + 6*a(122) + 9*a(123) + 9*a(124) + 9*a(125))/6
If a(64) < m1 Or a(64) > m2 Or CInt(a(64)) <> a(64) Then GoTo 950

a(62) = (13*s1/5 + a(95) - 2*a(98) - a(99) - 3*a(117) - 3*a(118) - 2*a(120) + 2*a(122) - a(123) + a(124) - 3*a(125))/2
If a(62) < m1 Or a(62) > m2 Or CInt(a(62)) <> a(62) Then GoTo 950

a(61) = (-3*s1/5 - 9*a(95) + 10*a(98) + 5*a(99) + 2*a(100) + 3*a(117) + 11*a(118) + 4*a(119) + 4*a(120) - 12*a(122) + 3*a(123) - 15*a(124) + 3*a(125))/6
If a(61) < m1 Or a(61) > m2 Or CInt(a(61)) <> a(61) Then GoTo 950

a(60) = (3*s1 - 9*a(95) + 2*a(98) + a(99) - 2*a(100) - 3*a(117) + a(118) + 2*a(119) + 2*a(120) - 6*a(122) + 3*a(123) - 3*a(124) + 3*a(125))/6
If a(60) < m1 Or a(60) > m2 Or CInt(a(60)) <> a(60) Then GoTo 950

a(59) = (27*s1/5 + 3*a(95) + 2*a(98) - 5*a(99) - 2*a(100) - 3*a(117) + a(118) + 2*a(119) - 4*a(120) - 6*a(122) - 3*a(123) - 3*a(124) - 3*a(125))/6
If a(59) < m1 Or a(59) > m2 Or CInt(a(59)) <> a(59) Then GoTo 950

a(57) = (-9*s1/5 - 3*a(95) + 8*a(98) + a(99) + 4*a(100) + 3*a(117) + 7*a(118) + 2*a(119) + 2*a(120) - 6*a(122) + 3*a(123) - 9*a(124) + 3*a(125))/6
If a(57) < m1 Or a(57) > m2 Or CInt(a(57)) <> a(57) Then GoTo 950

a(56) = (s1/5 + 3*a(95) - 2*a(98) + a(99) + a(117) - 3*a(118) - 2*a(119) + 4*a(122) - 3*a(123) + 3*a(124) - a(125))/2
If a(56) < m1 Or a(56) > m2 Or CInt(a(56)) <> a(56) Then GoTo 950

a(55) = (3*s1 + 3*a(95) - 2*a(98) - a(99) + 2*a(100) - 3*a(117) - 7*a(118) - 2*a(119) - 2*a(120) + 6*a(122) - 3*a(123) + 3*a(124) - 3*a(125))/6
If a(55) < m1 Or a(55) > m2 Or CInt(a(55)) <> a(55) Then GoTo 950

a(54) = (18*s1/5 - 3*a(95) - a(98) + a(99) - 2*a(100) - 3*a(117) + a(118) + 2*a(119) - a(120) - 3*a(122) - 3*a(124) - 3*a(125))/3
If a(54) < m1 Or a(54) > m2 Or CInt(a(54)) <> a(54) Then GoTo 950

a(52) = -7*s1/5 + a(95) - a(98) + a(99) + 2*a(117) - a(119) + a(120) + 2*a(122) + 2*a(124) + a(125)
If a(52) < m1 Or a(52) > m2 Then GoTo 950

a(51) = (3*s1/5 - a(95) - a(99) - a(117) - a(118) + a(123) + a(124) + a(125))/2
If a(51) < m1 Or a(51) > m2 Or CInt(a(51)) <> a(51) Then GoTo 950

a(45) = (3*s1 + a(95) - 2*a(98) - a(99) - 2*a(100) - a(117) - a(118) - 2*a(120) - 3*a(123) + a(124) - 3*a(125))/2
If a(45) < m1 Or a(45) > m2 Or CInt(a(45)) <> a(45) Then GoTo 950

a(44) = (18*s1/5 - 3*a(95) + 2*a(98) - 2*a(99) + a(100) - 3*a(117) - 2*a(118) - a(119) - 4*a(120) - 3*a(122) + 3*a(123) - 3*a(124))/3
If a(44) < m1 Or a(44) > m2 Or CInt(a(44)) <> a(44) Then GoTo 950

a(42) = (-6*s1/5 + 3*a(95) - a(98) - 2*a(99) + a(100) - 2*a(118) + 2*a(119) + 2*a(120) + 3*a(122) + 3*a(124))/3
If a(42) < m1 Or a(42) > m2 Or CInt(a(42)) <> a(42) Then GoTo 950

a(41) = (-51*s1/5 - 3*a(95) + 2*a(98) + 7*a(99) + 4*a(100) + 9*a(117) + 7*a(118) + 2*a(119) + 8*a(120) + 6*a(122) + 3*a(123) + 3*a(124) + 9*a(125))/6
If a(41) < m1 Or a(41) > m2 Or CInt(a(41)) <> a(41) Then GoTo 950

a(40) = (3*s1 - 9*a(95) + 2*a(98) + a(99) + 4*a(100) - 3*a(117) + a(118) + 2*a(119) - 4*a(120) - 6*a(122) + 3*a(123) - 3*a(124) + 3*a(125))/6
If a(40) < m1 Or a(40) > m2 Or CInt(a(40)) <> a(40) Then GoTo 950

a(39) = (27*s1/5 + 3*a(95) + 2*a(98) + a(99) - 2*a(100) - 3*a(117) + a(118) - 4*a(119) - 4*a(120) - 6*a(122) - 3*a(123) - 3*a(124) - 3*a(125))/6
If a(39) < m1 Or a(39) > m2 Or CInt(a(39)) <> a(39) Then GoTo 950

a(37) = (-3*s1/5 - a(95) + 2*a(98) + a(99) + a(117) + 3*a(118) + 2*a(120) - 2*a(122) + a(123) - 3*a(124) + a(125))/2
If a(37) < m1 Or a(37) > m2 Or CInt(a(37)) <> a(37) Then GoTo 950

a(36) = (3*s1/5 + 9*a(95) - 10*a(98) - 5*a(99) - 2*a(100) + 3*a(117) - 5*a(118) + 2*a(119) + 2*a(120) + 12*a(122) - 9*a(123) + 9*a(124) - 3*a(125))/6
If a(36) < m1 Or a(36) > m2 Or CInt(a(36)) <> a(36) Then GoTo 950

a(35) = (-3*s1 + 9*a(95) - 2*a(98) - a(99) + 2*a(100) + 3*a(117) - a(118) - 2*a(119) + 4*a(120) + 6*a(122) - 3*a(123) + 3*a(124) + 3*a(125))/6
If a(35) < m1 Or a(35) > m2 Or CInt(a(35)) <> a(35) Then GoTo 950

a(34) = (-27*s1/5 - 3*a(95) - 2*a(98) + 5*a(99) + 2*a(100) + 3*a(117) - a(118) + 4*a(119) + 4*a(120) + 6*a(122) + 3*a(123) + 9*a(124) + 3*a(125))/6
If a(34) < m1 Or a(34) > m2 Or CInt(a(34)) <> a(34) Then GoTo 950

a(32) = (9*s1/5 + 3*a(95) - 8*a(98) - a(99) - 4*a(100) + 3*a(117) - 7*a(118) - 2*a(119) - 2*a(120) + 12*a(122) - 3*a(123) + 9*a(124) - 3*a(125))/6
If a(32) < m1 Or a(32) > m2 Or CInt(a(32)) <> a(32) Then GoTo 950

a(31) = (19*s1/5 - 3*a(95) + 2*a(98) - a(99) - 3*a(117) + a(118) - 2*a(120) - 6*a(122) + a(123) - 5*a(124) - a(125))/2
If a(31) < m1 Or a(31) > m2 Or CInt(a(31)) <> a(31) Then GoTo 950

a(30) = (3*s1 - 3*a(95) + 2*a(98) + a(99) - 2*a(100) - 3*a(117) + a(118) + 2*a(119) + 2*a(120) - 6*a(122) + 3*a(123) - 3*a(124) - 3*a(125))/6
If a(30) < m1 Or a(30) > m2 Or CInt(a(30)) <> a(30) Then GoTo 950

a(29) = (-18*s1/5 + 3*a(95) + a(98) - a(99) + 2*a(100) + 3*a(117) + 2*a(118) + a(119) + 4*a(120) + 3*a(122) + 3*a(125))/3
If a(29) < m1 Or a(29) > m2 Or CInt(a(29)) <> a(29) Then GoTo 950

a(27) = 12*s1/5 - a(95) + a(98) - a(99) - 2*a(117) - 2*a(120) - 3*a(122) - 2*a(124) - a(125)
If a(27) < m1 Or a(27) > m2 Then GoTo 950

a(26) = (-3*s1/5 + a(95) + a(99) + a(117) - a(118) - 2*a(119) + 2*a(122) + a(123) + a(124) + a(125))/2
If a(26) < m1 Or a(26) > m2 Or CInt(a(26)) <> a(26) Then GoTo 950

a(20) = s1 - a(95) - a(117) - a(118) - a(120)
If a(20) < m1 Or a(20) > m2 Then GoTo 950

a(19) = (21*s1/5 - a(95) - a(99) - 2*a(100) - 3*a(117) + a(118) - 2*a(120) - 4*a(122) - a(123) - 3*a(124) - 3*a(125))/2
If a(19) < m1 Or a(19) > m2 Or CInt(a(19)) <> a(19) Then GoTo 950

a(17) = (-51*s1/5 + 3*a(95) + 2*a(98) + 7*a(99) + 4*a(100) + 9*a(117) + 7*a(118) - 4*a(119) + 8*a(120) + 6*a(122) + 3*a(123) + 3*a(124) + 9*a(125))/6
If a(17) < m1 Or a(17) > m2 Or CInt(a(17)) <> a(17) Then GoTo 950

a(16) = -3*s1/5 + a(95) - a(98) + a(117) - a(118) + a(120) + 2*a(122) - a(123) + 2*a(124)
If a(16) < m1 Or a(16) > m2 Then GoTo 950

a(15) = (s1 + a(95) - 2*a(98) - a(99) - a(117) - a(118) + 2*a(122) - a(123) + a(124) - a(125))/2
If a(15) < m1 Or a(15) > m2 Or CInt(a(15)) <> a(15) Then GoTo 950

a(14) = (18*s1/5 - 3*a(95) + 2*a(98) + a(99) + a(100) - 3*a(117) - 2*a(118) + 2*a(119) - 4*a(120) - 3*a(122) - 3*a(124) - 3*a(125))/3
If a(14) < m1 Or a(14) > m2 Or CInt(a(14)) <> a(14) Then GoTo 950

a(12) = (-21*s1/5 + 3*a(95) - 2*a(98) - a(99) - a(100) + 6*a(117) - a(118) + a(119) + 4*a(120) + 6*a(122) + 6*a(124) + 3*a(125))/3
If a(12) < m1 Or a(12) > m2 Or CInt(a(12)) <> a(12) Then GoTo 950

a(11) = (9*s1/5 - 3*a(95) - 2*a(98) - a(99) + 2*a(100) - 3*a(117) - a(118) - 2*a(119) - 2*a(120) + 3*a(123) + 3*a(124) + 3*a(125))/6
If a(11) < m1 Or a(11) > m2 Or CInt(a(11)) <> a(11) Then GoTo 950

a(10) = (3*s1 - 3*a(95) + 2*a(98) + a(99) + 4*a(100) - 3*a(117) + a(118) + 2*a(119) - 4*a(120) - 6*a(122) + 3*a(123) - 3*a(124) - 3*a(125))/6
If a(10) < m1 Or a(10) > m2 Or CInt(a(10)) <> a(10) Then GoTo 950

a(9) = (-18*s1/5 + 3*a(95) + a(98) + 2*a(99) + 2*a(100) + 3*a(117) + 2*a(118) - 2*a(119) + 4*a(120) + 3*a(122) + 3*a(125))/3
If a(9) < m1 Or a(9) > m2 Or CInt(a(9)) <> a(9) Then GoTo 950

a(7) = (36*s1/5 - 3*a(95) + 2*a(98) - 2*a(99) - 2*a(100) - 6*a(117) + a(118) - a(119) - 4*a(120) - 9*a(122) - 6*a(124) - 3*a(125))/3
If a(7) < m1 Or a(7) > m2 Or CInt(a(7)) <> a(7) Then GoTo 950

a(6) = (-9*s1/5 + 3*a(95) - 4*a(98) - 5*a(99) - 2*a(100) + 3*a(117) + a(118) + 2*a(119) + 2*a(120) + 6*a(122) + 3*a(123) + 3*a(124) + 3 * a(125))/6
If a(6) < m1 Or a(6) > m2 Or CInt(a(6)) <> a(6) Then GoTo 950

a(5) = (-6*s1 + 3*a(95) + 2*a(98) + a(99) + a(100) + 6*a(117) + 4*a(118) - a(119) + 5*a(120) + 3*a(122) + 3*a(123) + 6*a(125))/3
If a(5) < m1 Or a(5) > m2 Or CInt(a(5)) <> a(5) Then GoTo 950

a(4) = (-11*s1/5 + a(95) - 2*a(98) + a(99) + 3*a(117) - a(118) + 2*a(120) + 4*a(122) - a(123) + 5*a(124) + a(125))/2
If a(4) < m1 Or a(4) > m2 Or CInt(a(4)) <> a(4) Then GoTo 950

a(2) = (21*s1/5 - 3*a(95) - 4*a(98) + a(99) - 2*a(100) - 3*a(117) - 5*a(118) + 2*a(119) - 4*a(120) + 6*a(122) - 3*a(123) + 3*a(124) - 3 * a(125))/6
If a(2) < m1 Or a(2) > m2 Or CInt(a(2)) <> a(2) Then GoTo 950

a(1) = (39*s1/5 - 3*a(95) + 4*a(98) - a(99) - a(100) - 6*a(117) + 2*a(118) + a(119) - 5*a(120) - 12*a(122) - 9*a(124) - 6*a(125))/3
If a(1) < m1 Or a(1) > m2 Or CInt(a(1)) <> a(1) Then GoTo 950


'   Exclude solutions with identical numbers in rows, colums, pillars

    GoSub 800: If fl1 = 0 Then GoTo 950

    n9 = n9 + 1
    
    GoSub 1740 'Print results (selected numbers)
'   GoSub 1750 'Print results (planes 11, 12, 13, 14 and 15)
'   GoSub 1760 'Print results (3d)

950 Next j95

980 Next j98
990 Next j99
1000 Next j100

1170 Next j117
1180 Next j118
1190 Next j119
1200 Next j120

1220 Next j122
1230 Next j123
1240 Next j124
1250 Next j125
   
     t2 = Timer
    
     t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions"
     y = MsgBox(t10, 0, "Routine SudCube5d")

End

'   Exclude solutions with identical numbers in rows, colums and pillars

800 fl1 = 1

'   Rows
    
    i1 = -4
    For i0 = 1 To 25
        i1 = i1 + 5
        b(1) = a(i1): b(2) = a(i1 + 1): b(3) = a(i1 + 2): b(4) = a(i1 + 3): b(5) = a(i1 + 4)
        GoSub 860
        If fl1 = 0 Then Return
    Next i0
   
'   Columns
    
    i1 = 0: i2 = 0
    For i0 = 1 To 25
        i1 = i1 + 1
        b(1) = a(i1): b(2) = a(i1 + 5): b(3) = a(i1 + 10): b(4) = a(i1 + 15): b(5) = a(i1 + 20)
        i2 = i2 + 1: If i2 = 5 Then i2 = 0: i1 = i1 + 20
        GoSub 860
        If fl1 = 0 Then Return
    Next i0
    
'   Pillars
    
    i1 = 0: i2 = 0
    For i0 = 1 To 25
        i1 = i0
        b(1) = a(i1): b(2) = a(i1 + 25): b(3) = a(i1 + 50): b(4) = a(i1 + 75): b(5) = a(i1 + 100)
        GoSub 860
        If fl1 = 0 Then Return
    Next i0

    Return

860 fl1 = 1
    For j1 = 1 To 5
       b2 = b(j1)
       For j2 = (1 + j1) To 5
           If b2 = b(j2) Then fl1 = 0: Return
       Next j2
    Next j1
    Return

'    Print results (selected numbers)

1740 For i1 = 1 To 125
         Cells(n9, i1).Value = a(i1)
     Next i1
    
     Return

'    Print results (planes 11, 12, 13, 14 and 15)

1750 n2 = n2 + 1
     If n2 = 7 Then
         n2 = 1: k1 = k1 + 30: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 6
     End If
       
     For i0 = 1 To 5
         i3 = (5 - i0) * 25
         For i1 = 1 To 5
             For i2 = 1 To 5
                 i3 = i3 + 1
                 Cells(k1 + i1 + (i0 - 1) * 6, k2 + i2).Value = a(i3)
             Next i2
         Next i1
         If i0 = 1 Then
             Cells(k1 + (i0 - 1) * 6, k2 + 1).Value = "Plane 1" + CStr(i0) + ", C" + CStr(n9)
         Else
             Cells(k1 + (i0 - 1) * 6, k2 + 1).Value = "Plane 1" + CStr(i0)
         End If
     Next i0
    
     Return

'    Print results (3d)
    
1760 n2 = n2 + 1
     If n2 = 4 Then
         n2 = 1: k1 = k1 + 46: k2 = 1
     Else
         If n9 > 1 Then k2 = k2 + 22
     End If
       
     For i0 = 1 To 5
         i3 = (5 - i0) * 25
         For i1 = 1 To 5
             For i2 = 1 To 5
                 i3 = i3 + 1
                 Cells(k1 + 1 + (i1 - 1) * 2 + (i0 - 1) * 9, k2 + 9 + (i2 - 1) * 3 - (i1 - 1) * 2).Value = a(i3)
             Next i2
         Next i1
     Next i0

     Return

End Sub

Vorige Pagina About the Author