Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Play and win the word morph game with the help of Perl :)

by Ieronim (Friar)
on Jun 29, 2006 at 10:56 UTC ( [id://558284]=note: print w/replies, xml ) Need Help??


in reply to Re: Play and win the word morph game with the help of Perl :)
in thread Play and win the word morph game with the help of Perl :)

I learned some new tricks from your code :)

But i think that my way is better ;)
The main advantage of my solution over yours is the possibility of work with given words not included in the dictionary: e.g. the script can find find a path from 'phil' to 'kate'.
And the second advantage is speed — my script works only with data stored in memory, and your uses the hard disk very much. So, as i have measured, my transform function is about 3 times faster than your findpath.

Bug fixed :)

Thank you :)

Replies are listed 'Best First'.
Re^3: Play and win the word morph game with the help of Perl :)
by Limbic~Region (Chancellor) on Jun 29, 2006 at 12:11 UTC
    Ieronim,
    I am glad you learned something from my code. It was intended to be concise while also being straight forward. DBM::Deep is not currently designed to be fast as it is written in pure perl. If you want speed - try the version below which uses Storable. I believe it outperforms yours though I have not Benchmarked it.

    I admit that I have not had a chance to disect your code but I am interested in how you build bridges for words not in the dictionary. If it is only the endpoints, then modifying my code to do the same would be trivial. I am going to spend some time disecting your code and may update the version below if all you are handling is end-points.

    Cheers - L~R

      of course the non-dictionary words can appear only at the endpoints.

      The variant with Storable is about 10 time faster than mine :) great :)

        Ieronim,
        I truly like the elegance of my previous solution. It is Concise, straight forward, and fast. You can even remove the build_db() after the database has been compiled as I have shown below in about 20 lines of code: For the sake of completeness, I am providing the following version which allows you to use non-dictionary words at the endpoints. Feel free to adjust this as you see fit.

        Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found