String manipulation

  • Thread starter Thread starter David Turner
  • Start date Start date
D

David Turner

I have a 9-letter word and would like to ,using VBA code,
piece together as many different other words of 3-9
letters as possible (not duplicating any of the letters),
and then check them against a dictionary table.

I have managed this by using a table with all the
possible combinations, but it takes a long time to run
and was hoping you maybe able to provide me with some
pointers on code.

Thanks
 
-----Original Message-----


How are you checking possible letter combination against the
dictionary table?

This is done by having a table with all the combinations
(i.e. [1]&[2]&[3] etc), these are then run in a query
linked to the dictionary table and all the matches
displayed.
 
Since the number of possible words using this algorithm would be 623,448
(assuming that the nine-letter word contains no duplicated letters), I would
think this could take a while to generate the words and also the comparison SQL
might take a bit of time, especially if you hadn't indexed the possible words in
the table.

Could you post your code and table structures? Perhaps someone could see a way
of improving your code and SQL statement.
 
Whoops! Bad math. Number of possible words is not 623K plus, it is 985,824
words of 3 to 9 characters.


John Spencer (MVP) said:
Since the number of possible words using this algorithm would be 623,448
(assuming that the nine-letter word contains no duplicated letters),

SNIP
 
David said:
-----Original Message-----


How are you checking possible letter combination against the
dictionary table?

This is done by having a table with all the combinations
(i.e. [1]&[2]&[3] etc), these are then run in a query
linked to the dictionary table and all the matches
displayed.

Well, yeah, you said that before. What I meant to ask is:

Is there any way to skip impossible combinations of letters
so they don't go into the table?

How are you adding the records to the table?

How are you managing the indexes on the two tables? Having
an index on the table when you're adding records to it will
slow it down. Not having a unique index on both tables when
you run the matching query will be abismally slow.

Even though I think the number of records is 986328 ;-)), I
agree with what John said, it's a LOT of work to deal with
such a large number of records. It's a fundamental law of
the universe that the more work that has to be done, the
more time it takes to do it ;-). Note: at this time, it's
not clear if the laws of the universe apply at the quantum
level, so there is still hope ;-))
 
Back
Top