Hi codeguy,
I thought about permutations and then thought nah! won't work with real words at varying lengths.
But I could be wrong, wouldn't be first time.
Wanna race? You modify your code for checking for real words and I will see if I can optimize Zeppellin's code some more.... post in 24 hours?
Hi codeguy,
I thought about permutations and then thought nah! won't work with real words at varying lengths.
But I could be wrong, wouldn't be first time.
Wanna race? You modify your code for checking for real words and I will see if I can optimize Zeppellin's code some more.... post in 24 hours?
Here's how I'd go, I think:
First, reduce the word list to exclude any words > 9 digits. No need to search for impossible combinations.
Then count letters. Save these in an array WordLetters(1 TO WordCount,1 TO 26).
Then count letters in the target word.
Compare. If target count > word count then it's a match!
************************
The word list is going to be rather limited (less than 50k words I'd imagine), and most searches will terminate rather quickly. (need an "A", don't have any? Quit the search at this point.)
I really don't think you'd need to worry about optimizing for speed any more than that, to be honest.
Cra...
Sorry about your name Steve, my eyes are going bad.
And funniest thing??
The local government says we can change the name, as long as WE are willing to pay the $$$$$ to change the road signs.
Two little signs, only needing an extra "l" in them, and yet to comply to state standards, they cost over $2600 each!
It's no damn wonder our government is broke, trying to hit such costs just to stay within regulation. On a low traveled, rural as heck road like mine, a $2.00 slab of wood, $1 can of white paint, and $1 can of black paint for lettering, would be more than sufficient to serve the needs of the community...
And yet... The sign has to be a certain gauge steel, painted X coats of reflective green, with Y coats of Z-size white paint, mixed with XX percent reflective beads....
(And, just in case you want to see how nutty regulations are for government stuff, here's the regs on signs: http://www.vdot.virginia.gov/business/resources/TED/final_MUTCD/2013_sup/Revision_1_Part_2_Signs.pdf --- Well, it's the BASIC regulations. There are 14 supplements, with 5 supplements to supplement the supplements also...l)
Yep, for shorter strings Steve's loop count is a winner!
But for longer strings this current version is a winner.
Hi codeguy,
For stevemcneill, 2 l's on end, I am getting 392 words with Steve's code and my version.
I don't know about just a letter? is t a word? I know I is. ;)
And for those who are having trouble understanding how my last 2 examples work, the secret is in the letter counter.
Take APPLE as an example... Instead of searching to see if the In$ has those 5 letters, we instead count the letters first, when we load the dictionary. 1 A, 2 P, 1 L, 1 E... All we have to check is a maximum of 4 times, instead of 5; we just check to make certain In$ has 2 Ps in it once, rather than checking twice...
In some cases, this reduces a ton of letter checks. MISSISSIPPI. Instead of 11 letters, we check 4... (1 M, 4 I, 4 S, 2 P).
Minimal conditional checking makes for maximum performance. ;)
And for those who are having trouble understanding how my last 2 examples work, the secret is in the letter counter.
Take APPLE as an example... Instead of searching to see if the In$ has those 5 letters, we instead count the letters first, when we load the dictionary. 1 A, 2 P, 1 L, 1 E... All we have to check is a maximum of 4 times, instead of 5; we just check to make certain In$ has 2 Ps in it once, rather than checking twice...
In some cases, this reduces a ton of letter checks. MISSISSIPPI. Instead of 11 letters, we check 4... (1 M, 4 I, 4 S, 2 P).
Minimal conditional checking makes for maximum performance. ;)
PLUS, if you want to save even more time, save the processed Word List back into a new Data File, once and forever preprocessed!
Peter smiles, he ain't feel'in so broke no more.