Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Danilin without the GoTo's
#6
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.

Smile 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
Reply


Messages In This Thread
Danilin without the GoTo's - by bplus - 02-28-2026, 10:23 PM
RE: Danilin without the GoTo's - by CharlieJV - 03-01-2026, 02:20 AM
RE: Danilin without the GoTo's - by bplus - 03-01-2026, 05:22 AM
RE: Danilin without the GoTo's - by SMcNeill - 03-01-2026, 02:23 AM
RE: Danilin without the GoTo's - by luke - 03-01-2026, 11:23 AM
RE: Danilin without the GoTo's - by bplus - 03-01-2026, 02:00 PM
RE: Danilin without the GoTo's - by SMcNeill - 03-01-2026, 03:19 PM
RE: Danilin without the GoTo's - by CharlieJV - 03-01-2026, 06:37 PM
RE: Danilin without the GoTo's - by bplus - 03-01-2026, 05:15 PM
RE: Danilin without the GoTo's - by bplus - 03-01-2026, 07:05 PM
RE: Danilin without the GoTo's - by Kernelpanic - 03-01-2026, 07:18 PM
RE: Danilin without the GoTo's - by CharlieJV - 03-01-2026, 07:44 PM
RE: Danilin without the GoTo's - by Kernelpanic - 03-01-2026, 10:02 PM
RE: Danilin without the GoTo's - by CharlieJV - 03-01-2026, 11:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Star MazeBall & DAV & Danilin Solve of Labyrinth DANILIN 1 826 10-12-2024, 11:57 AM
Last Post: DANILIN

Forum Jump:


Users browsing this thread: 1 Guest(s)