Hi anyone who's interested,

I was frustrated by a word puzzle in a newspaper which in Factor can
be stated as:

Find a permutation of the string "mtnymisei" which is a valid English word.

I gave up doing it in my head so I opened up Factor to solve it for
me. I needed a list of valid English words which I got from aspell:

cd ~/tmp
wget http://ftp.gnu.org/gnu/aspell/dict/en/aspell6-en-6.0-0.tar.bz2
tar xjvf aspell6-en-6.0-0.tar.bz2
cd aspell6-en-6.0-0
preunzip en-common.cwl # outputs en-common.wl which is a
newline-separated list of words

The easy part was Factor:
"mtnymisei" all-permutations unique values [ >string ] map ! leaves a
seq of the 90720 strings which are unique combinations of "mtnymisei"
"/Users/ajc/tmp/aspell6-en-6.0-0/en-common.wl" ascii [ lines ]
with-file-reader ! leaves a seq of valid English words
intersect

... and that's it! I'm left with an array containing the one word that fits :)

Of course my path to the solution wasn't quite such a fairy tale, but
it only took around 30 minutes in total, and most of that was trying
to find a valid word list. I originally tried to print each
permutation in the listener, but that kept crashing Factor.

Anyway, I had fun so I thought I'd share. Apologies to littledan if
I'm not using the latest set protocol words, I haven't updated in a
week or so.

Alex

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to