add-a-gram

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Wed Feb 20 05:15:34 EST 2002


In article <mailman.1014175232.10747.python-list at python.org>, Jason
Orendorff wrote:
>Jason wrote:
>> Here is a puzzle that was floating around comp.lang.lisp, and I was
>> wondering what a Python solution would be.
>
>I solved this in Python in a few minutes, then converted it to C++
>for efficiency and found that it ran slower in C++ (because I used
>map<> and string.  Python's stuff is more efficient.)
>
>Then I wrote my own hashtable and my own string type and managed
>to get the C++ down to about 8x faster than the Python.
>It solves their WORD.LST in <1 second on my PC.

That's pretty quick... Anyway, if you ignore the setup-time (reading
in the file and storing it in a useful way; this took 6 seconds),
the search for a solution took 0.9 seconds on my PC -- implemented in
Python, mind you. (Of course ignoring the setup isn't very realisting
in this case, where there is only one solution -- but if you were to
be able to find an addagram of a user-supplied length, for instance,
that would be realistic.)

>I solved the other puzzles too...  They still didn't hire me.  :)
>
>## Jason Orendorff    http://www.jorendorff.com/
>

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list