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.
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
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
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
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.
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.
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.
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)
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.
I may even be able to find my Qbasic program that reads it. The program was actually to do those competitions of the type: - how many words can you make from "petes qb site is best".