Page 1 of 1

anagram solver

Posted: Tue Aug 15, 2006 12:47 am
Just for a try-out, I want to make a anagram solver, which is capable to solve up to 10 letters in a word.

Currently I can only use up to 3 letters, anyone to step in and help me out?

Code: Select all

``````DIM SHARED letters(9) AS STRING

LINE INPUT "Give in word: ", word\$
PRINT "Wordlenght is "; LEN(word\$)

FOR a = 1 to LEN(word\$)
letters(a) = MID\$(word\$, a, 1)
NEXT

``````
Then I'm stuck. I do know that I have the following table:
[1-2-3]
[1-3-2]
[2-1-3]
[2-3-1]
[3-1-2]
[3-2-1]

grtz
Edited.

Posted: Tue Aug 15, 2006 1:10 am
Morning Seb.

I just wake up so im not 100% sure what youre after.

Code: Select all

``````DIM AS String Word, Letters()
DIM AS Integer Counter

LINE INPUT "Give in word: ";Word
REDIM Letters(LEN(Word))

PRINT "Wordlenght is "; LEN(word)

FOR Counter = 1 to LEN(Word)
Letters(Counter) = MID\$(Word, Counter, 1)
NEXT``````

Posted: Tue Aug 15, 2006 1:14 am
e.g. I have a word that is 'rta', you and I know that it would be 'art' or 'rat' but I want my program to show the following:

[1-2-3] = [r-t-a]
[1-3-2] = [r-a-t]
[2-1-3] = [t-r-a]
[2-3-1] = [t-a-r]
[3-1-2] = [a-r-t]
[3-2-1] = [a-t-r]

grtz

Posted: Wed Aug 16, 2006 12:06 am
Seb,

I'm not an expert on this, but the numbers 123,132, etc. are a perfect set of the permutations of 3 numbers.

Since you didn't show us the PRINT statement, I don't know why you're printing the numbers of the letter positions instead of the letters themselves. My guess is that in order to print both the numbers and their corresponding letter, you probably need to keep 2 arrays.

The big problem that you will encounter later is when the input word contains duplicate letters, like HELLO which has 2 L's. The duplicate letters will generate duplicate permutations which you'll need to detect and eliminate. When you get to this part, let me know. I have an algorithm for this.

Good luck!

Regards..... Moneo

Posted: Wed Aug 16, 2006 9:05 am
Anagram solver? Well for a N letter word there are N! permutations - far too many. I have written a similar program and the best approach is to search a dictionary file.
First check is the length, then if the anagram and a dictionary word have the same length use INSTR to check the letters are all there.

Posted: Wed Aug 16, 2006 4:25 pm
Quibbler wrote:Anagram solver? Well for a N letter word there are N! permutations - far too many. I have written a similar program and the best approach is to search a dictionary file.
First check is the length, then if the anagram and a dictionary word have the same length use INSTR to check the letters are all there.
Although, if you used INSTR to find the letters, you would come up with duplicates... (like moneo said) You could remove letters from each string and still open your dictionary file.

Code: Select all

``````EXAMPLE: NOT CODE!
FREE and REEF are being tested.

FREE - REEF   (F is scanned and removed)
_REE - REE_   (R is scanned and removed)
__EE - _EE_   (One of the E's is scanned and removed)
___E - __E_   (The other E is scanned and removed)
____ - ____   (There are no more letters, the scan was a success)
``````

Posted: Wed Aug 16, 2006 6:36 pm
Quibbler wrote:Anagram solver? Well for a N letter word there are N! permutations - far too many. I have written a similar program and the best approach is to search a dictionary file.
First check is the length, then if the anagram and a dictionary word have the same length use INSTR to check the letters are all there.
Interesting approach, but where can you get such a dictionary file? To be used by a QB program, it would also have to be a plain ASCII text file.

*****

Posted: Thu Aug 17, 2006 1:42 am
I think its possible to get few most common words pretty easily.

Non native english person speaks good english if he knows 500 to 2K words.
Person who speaks english as hes/her home language, knows 2K to 10K words.

Here is first 850 http://www.langmaker.com/wordlist/basiclex.htm

Alltho, if i do remember right, ATM, english dictionary knows 200K words

Posted: Thu Aug 17, 2006 9:45 am