Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Word Finder.
#6
Quote:No, I don't just mean anagrams, I mean words that can be formed from *some* or *all* of the letters - RAT gives RAT, AT, ART, TA,TAR
OK like this:


Code: (Select All)
_Title "AnaCode$ function" ' b+ 2022-11-17
test$(0) = "grmaana"
test$(1) = "angiogram"
test$(2) = "naagrma"
test$(3) = "telgram"
test$(4) = "gramana"
test$(5) = "gram"
test$(6) = "nag"
test$(7) = "tag"
test$(8) = "am"
test$(9) = "grip"

For i = 0 To 9
    If WordIsInGroup&(test$(i), "anagram") Then
        Print test$(i) + " is in anagram."
    Else
        Print test$(i) + " is Naht in anagram."
    End If
Next

Function AnaCode$ (wrd$) ' anaCode$ converts word to an Anagram pattern
    ' number of A's in first, number of B's in 2nd, number of C's in third
    Dim L(26)
    w$ = UCase$(wrd$)
    For i = 1 To Len(wrd$)
        p = Asc(w$, i) - 64 ' A=1, B=2...
        L(p) = L(p) + 1
    Next
    For i = 1 To 26
        rtn$ = rtn$ + _Trim$(Str$(L(i)))
    Next
    AnaCode$ = rtn$
End Function

Function WordIsInGroup& (Word$, Group$)
    aw$ = AnaCode$(Word$)
    ag$ = AnaCode$(Group$)
    For i = 1 To 26
        If Val(Mid$(aw$, i, 1)) > Val(Mid$(ag$, i, 1)) Then Exit Function
    Next
    WordIsInGroup& = -1
End Function
b = b + ...
Reply


Messages In This Thread
Word Finder. - by PhilOfPerth - 11-17-2022, 05:15 AM
RE: Word Finder. - by bplus - 11-17-2022, 04:58 PM
RE: Word Finder. - by PhilOfPerth - 11-17-2022, 11:39 PM
RE: Word Finder. - by Pete - 11-17-2022, 08:56 PM
RE: Word Finder. - by Unatic - 11-20-2022, 02:23 AM
RE: Word Finder. - by mnrvovrfc - 11-20-2022, 03:17 AM
RE: Word Finder. - by bplus - 11-17-2022, 09:22 PM
RE: Word Finder. - by bplus - 11-18-2022, 02:16 AM
RE: Word Finder. - by Pete - 11-20-2022, 06:22 AM



Users browsing this thread: 3 Guest(s)