Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Word Finder.
#2
Hi Phil,

What you are talking about are Anagrams, words with same letters in different order eg art, rat, tar

Here is a function that converts a word to an AnaCode$ by counting up the number of A's, then B's, then C's...
This forms a unique string of digits, so you can use repeated amounts of letters in a word (up to 9) and still compare words.

In Demo of function I compare to anagram which as you can see needs 3 a's:
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"
AC$ = AnaCode$("anagram")
For i = 0 To 4
    If AC$ = AnaCode$(test$(i)) Then
        Print test$(i); " is an anagram of 'anagram'"
    Else
        Print test$(i); " is NOT an anagram of '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

With AnaCode$ you don't need to worry about word lengths.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Word Search Maker SierraKen 27 5,009 01-21-2026, 12:53 AM
Last Post: SierraKen
  Random Access word-list maker PhilOfPerth 0 571 03-06-2024, 03:59 AM
Last Post: PhilOfPerth
  Word (text) processor krovit 19 4,445 09-02-2023, 04:38 PM
Last Post: grymmjack
  Not ANOTHER word-game! PhilOfPerth 12 2,454 01-30-2023, 11:27 PM
Last Post: PhilOfPerth
  Alchemy - A word Game PhilOfPerth 30 6,365 05-11-2022, 07:27 AM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: