I can't tell from your post what it is you are trying to accomplish. I am
certain it is not as difficult as you are making it. If you can describe the
objective, perhaps we can help find a good solution to your problem.
> I can't tell from your post what it is you are trying to accomplish. I am
> certain it is not as difficult as you are making it. If you can describe the
> objective, perhaps we can help find a good solution to your problem.
I am writing code to brute force solve/recreate 2^54 Number. I have
broken this into 2 long integers as I am not sure how in VBA to store
2^54 as a single number accurately.
54 toggles on a form can be expressed as 54 bit, as one toggles it
would affect 4 other bits, this as been loaded into a two dimensional
array, this array would be XOR to the current value (stored as 2 long
integers).1,2,4,8,16,etc to calculate it down to 0.
Lights Out Cube Sovler via access 2007 form and tables.
egerds - 09 Dec 2006 07:22 GMT
> > I can't tell from your post what it is you are trying to accomplish. I am
> > certain it is not as difficult as you are making it. If you can describe the
> > objective, perhaps we can help find a good solution to your problem.
> >
> Lights Out Cube Sovler via access 2007 form and tables.
Example code
Private Sub Command_Solve_Click()
Dim array_toggles_form(0 To 53), array_toggles_solving(0 To 53)
Dim array_toggles_result(0 To 53), array_toggles_answer(0 To 53)
Dim bytX As Byte, bytY As Byte, bytZ As Byte, intButtonCount As Byte
Dim strToggleName As String, strSolve As String
'Fill array form and solving
For bytX = 0 To 53
strToggleName = lstr_Toggle & bytX
array_toggles_form(bytX) = Me(strToggleName)
array_toggles_solving(bytX) = Me(strToggleName)
array_toggles_result(bytX) = Me(strToggleName)
'array_toggles_answer(bytX) = Me(strToggleName)
Next
'start testing
For intButtonCount = 1 To Me.Text_Par
If intButtonCount > 1 Then
'I would need to add a loop for each of intbuttoncount or have a
recursive sub call
'this code example only works for 2 button presses
For bytZ = 1 To 53
strSolve = bytZ & " "
Call ToggleArray(bytZ, array_toggles_solving)
GoTo Loop2in
Loop1Return:
Call SetArray(array_toggles_form, array_toggles_solving)
Next
End If
'array_toggles_solving should be set here to ?
'Call SetArray(array_toggles_form, array_toggles_solving)
'MsgBox "outer loop" & intButtonCount
Next
'reset form
For bytX = 0 To 53
strToggleName = lstr_Toggle & bytX: Me(strToggleName) =
array_toggles_form(bytX)
Next
'this is the code for 1 button press solve
For bytX = 0 To 53
Call ToggleArray(bytX, array_toggles_result)
If Check_Complete(array_toggles_result) = True Then
strSolve = strSolve & bytX
End If
Call SetArray(array_toggles_solving, array_toggles_result)
Next
MsgBox "solved by pressing " & strSolve
Exit Sub ' End of solve button
Loop2in:
For bytX = 0 To 53
Call ToggleArray(bytX, array_toggles_result)
If Check_Complete(array_toggles_result) = True Then
strSolve = strSolve & bytX
MsgBox strSolve
Exit Sub
End If
Call SetArray(array_toggles_solving, array_toggles_result)
Next
GoTo Loop1Return
End Sub
Sub ToggleArray(ByRef bytX, array_toggles_result)
Dim bytY As Byte, strToggleName As String
Me(lstr_Toggle & bytX) = Not Me(lstr_Toggle & bytX)
array_toggles_result(bytX) = Not array_toggles_result(bytX)
For bytY = 1 To 4
strToggleName = lstr_Toggle & pAffected(bytX, bytY)
Me(strToggleName) = Not Me(strToggleName)
array_toggles_result(pAffected(bytX, bytY)) = Not
array_toggles_result(pAffected(bytX, bytY))
Next
End Sub