Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • a word filter (Score:3, Informative)

    by jmm (276) <johnNO@SPAMperlwolf.com> on 2003.10.10 15:17 (#24821) Journal
    To filter words that could not be reversed can be expensive. A word, say "abcde" could be reversed in many ways.

    (1) "edcba" contained (anywhere) within a word as a (sub-)string

    (2} "e" at the end of one word and "dcba" at the beginning of another

    (3) "de" at the end and "cba" at the beginning

    (4) - (5) the obvious continuations.

    To fully test this would require having a hash of leading n-letter strings, trailing n-letter strings, and anywhere n-letter strings. That is going to be a large number of combinations. Filtering out a bunch of irreversible words might make additional words irreversible (since they might have only be able to be reversed using words that have been filtered). So, those hashes should contain a count of how many times that particular sub-string exists, and when a word is found to be unusable, all of its substrings must be subtracted out - if any substring counts went to zero then another round of checking may produce additional words that can be deleted.