Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Challenge: 8 Letters, Most Words

by Limbic~Region (Chancellor)
on Oct 05, 2013 at 03:42 UTC ( #1056997=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Challenge: 8 Letters, Most Words
in thread Challenge: 8 Letters, Most Words

choroba,
I am bleary eye tired but I wanted to review your code because you mentioned it didn't consider all combinations - only possible combinations.

If I have understood what you have done, this is not guaranteed to produce the correct answer on all dictionary files. It happens to get the right answer for 2of12inf.txt however. You appear to only be considering the combinations of letters of individual words rather than considering taking some from one word and some from another. Consider the following dictionary:

abcd acdb adbc dabc bcad efgh fgeh hegf egfh fegh abcdxy efghlm
The obvious answer is 'abcdefgh' which will get 10 words but your code chooses both 'abcdxy' and 'efghlm' with 6 words each.

Cheers - L~R


Comment on Re^5: Challenge: 8 Letters, Most Words
Download Code
Re^6: Challenge: 8 Letters, Most Words
by choroba (Abbot) on Oct 05, 2013 at 07:27 UTC
    One should probably postprocess the results if the winner is shorter than 8. I will look into it later.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Something like the following? It slows the algorithm terribly, though...
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Another idea: preprocess the input, adding all the combinations of the shorter words. Then run the original code without postprocessing. I will try to test it later, not much time at the moment...
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2014-12-18 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (67 votes), past polls