Vorige Pagina About the Author

' Combines Sudoku Comparable Cubes into Magic Cubes

' Tested with Office 2007 under Windows 7

Sub CnstrCbs5a()

    Dim b(3, 125), a(125)

    Sheets("Klad1").Select
    
y = MsgBox("Locked", vbCritical, "Routine CnstrCbs5a")
End
    
    n4 = 24                 'Test5

    n2 = 0: n9 = 0: k1 = 1: k2 = 1
    s1 = 315
    
    t1 = Timer
    
    For j1 = 1 To n4
    
    For j2 = 1 To n4
    If j2 = j1 Then GoTo 20
    
    For j3 = 1 To n4
    If j3 = j2 Or j3 = j1 Then GoTo 30
        
        j10 = j1: j20 = 1: GoSub 100                 'Read Sudoku Comparable Cube 1
        j10 = j2: j20 = 2: GoSub 100                 'Read Sudoku Comparable Cube 2
        j10 = j3: j20 = 3: GoSub 100                 'Read Sudoku Comparable Cube 3
        
        For j4 = 1 To 125
            a(j4) = b(1, j4) + 5 * b(2, j4) + 25 * b(3, j4) + 1
        Next j4
        
        GoSub 300: If fl1 = 0 Then GoTo 30           'Ckeck identical numbers
       
'********************** Only Counting **************************
       
 ''       Cells(2, 1).Value = j1
 ''       Cells(2, 2).Value = j2
 ''       Cells(2, 3).Value = j3

 ''       Cells(2, 4).Select: Cells(2, 4).Value = Cells(2, 4).Value + 1
       
'***************************************************************
       
       n9 = n9 + 1: GoSub 740 'Print results (selected numbers)
'      n9 = n9 + 1: GoSub 750 'Print results (5 Plane Format)

30  Next j3
20  Next j2
    Next j1
    
    t2 = Timer
    
    t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
    y = MsgBox(t10, 0, "Routine CnstrCbs5a")

End

'   Read Sudoku Comparable Cubes (line format)

100
    For i1 = 1 To 125
        b(j20, i1) = Sheets("Test5").Cells(j10, i1).Value
    Next i1
    Return
    
'   Check identical numbers
    
300 fl1 = 1
    For i1 = 1 To 125
       a2 = a(i1)
       For i2 = (1 + i1) To 125
           If a2 = a(i2) Then fl1 = 0: Return
       Next i2
    Next i1
    Return
    
'   Print results (selected numbers)

740 Cells(n9, 125).Select
    For i1 = 1 To 125
        Cells(n9, i1).Value = a(i1)
    Next i1
    Cells(n9, 126).Value = j1
    Cells(n9, 127).Value = j2
    Cells(n9, 128).Value = j3
    Return

'   Print results (5 Plane View)

750
    
    Return
    
End Sub

Vorige Pagina About the Author