Results 1 to 1 of 1

Thread: Anagrams: Recursive Logic Error

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Anagrams: Recursive Logic Error

    In working on this Anagramming program, I've created a recursive function to search for sub anagrams. It works perfectly with letters but when I enter a "*", things go crazy. I get a few words listed repeatedly (15 or so times on some of them) and not all of the expected words show up.

    The "*" should be treated as a wildcard and replaced with "a" through "z". Then each of those 26 possibilites is treated as new word.

    I can't find the error. Can you?

    Code:
    Public Sub DoWildCardAnagram(w$)
    Dim i As Single
        w$ = SortWord(w$)   'rearranges the letters of w$ into alphabetical order
                            'so that if there's a "*" present it will be the first
                            'Character
            
        If Left(w$, 1) = "*" Then
            Dim ln As Integer, t$
            ln = Len(w$)
            'change * to letters and try again
            For i = 97 To 122
                t$ = Right(w$, ln - 1) & Chr(i)
                DoWildCardAnagram (t$)
            Next i
            Me.Caption = t$
        Else
            Dim v As Double
            v = GetWordValue(txtAnagram)
            
            For i = 1 To WordCount  'go through the list of legal words and see if any of them match my word
                If v / WordValue(i) = Int(v / WordValue(i)) Then
                    If Len(WordList(i)) < 12 Then AddToLists WordList(i) 'found a good word - add it to the list
                End If
            Next i
        End If
    End Sub
    Last edited by DroopyPawn; May 12th, 2009 at 04:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width