Faster way to do this?
Lulu of the Lotus-Eaters
mertz at gnosis.cx
Wed May 21 21:46:03 EDT 2003
"John Wilson" <tug at wilson.co.uk> wrote previously:
|I think that there's a problem with the regexp.
|Looks like a single letter matches multiple times.
pat = re.compile('(?im)^[%s]+$' % sys.argv[1].lower())
Hmmm... I thought the original spec said "only the listed letters
occur". I guess 'letter' is ambiguous between "type" and "token", I
thought of the first meaning.
Nonetheless, even assuming the latter meaning, using my regex can winnow
down the wordlist in 1/20th the time of the original approach.
Post-filtering the resulting 20 words should still be possible in less
than 19/20ths the time taken to filter all 50k dictionary words (all
numbers given only for general scale, not precise figures :-)).
Yours, Lulu...
--
mertz@ _/_/_/_/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY:_/_/_/_/ v i
gnosis _/_/ Postmodern Enterprises _/_/ s r
.cx _/_/ MAKERS OF CHAOS.... _/_/ i u
_/_/_/_/_/ LOOK FOR IT IN A NEIGHBORHOOD NEAR YOU_/_/_/_/_/ g s
More information about the Python-list
mailing list