Quote:It's only about 7 times slower than b+'s original (with C++ optimizations turned on)
$Checking: Off saves maybe .005 secs
I thought it might be the UDT so I tried this:
Code: (Select All)
'$Checking:Off
Const NUM_VALUES = 10
'Type vec3
' a As Integer
' b As Integer
' c As Integer
'End Type
'Dim As vec3 x, y, z
Dim As Integer xa, xb, xc, ya, yb, yc, za, zb, zc
t# = Timer(0.001)
Do While next_muldiff(xa, xb, xc, 4)
zero_vec3 ya, yb, yc
ya = 1
Do While next_sum(ya, yb, yc, 8)
zero_vec3 za, zb, zc
zb = 1
Do While next_divsum(za, zb, zc, 8)
If xa / ya + za = 9 _AndAlso _
xb + yb + zb = 8 _AndAlso _
xc + yc - zc = 6 Then
print_vec3 xa, xb, xc
print_vec3 ya, yb, yc
print_vec3 za, zb, zc
Print
End If
Loop
Loop
Loop
Print Timer(0.001) - t#
Function next_vec3 (a As Integer, b As Integer, c As Integer)
next_vec3 = _TRUE
c = (c + 1) Mod NUM_VALUES
If c = 0 Then
b = (b + 1) Mod NUM_VALUES
If b = 0 Then
a = (a + 1) Mod NUM_VALUES
next_vec3 = a <> 0
End If
End If
End Function
Function next_muldiff (a As Integer, b As Integer, c As Integer, target As Integer)
Do
If next_vec3(a, b, c) = 0 Then Exit Function
If a * b - c = target Then
next_muldiff = _TRUE
Exit Function
End If
Loop
End Function
Function next_sum (a As Integer, b As Integer, c As Integer, target As Integer)
Do
If next_vec3(a, b, c) = 0 Then Exit Function
If a + b + c = target Then
next_sum = _TRUE
Exit Function
End If
Loop
End Function
Function next_divsum (a As Integer, b As Integer, c As Integer, target As Integer)
Do
If next_vec3(a, b, c) = 0 Then Exit Function
If a / b + c = target Then
next_divsum = _TRUE
Exit Function
End If
Loop
End Function
Sub zero_vec3 (a As Integer, b As Integer, c As Integer)
a = 0
b = 0
c = 0
End Sub
Sub print_vec3 (a As Integer, b As Integer, c As Integer)
Print a; b; c
End Sub
but no big change in times.
Quote:... so I took the liberty of complexifying it for you.
these different ways of skinning the cat (or as ahenry3068 says, fellating a feline) are interesting.
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

