http://www.perlmonks.org?node_id=558386


in reply to Re: A Better Word Morph Builder
in thread A Better Word Morph Builder

Solo,
My EA idea, which is likely flawed, would work as follows:

Assuming you start with a distance of 7 and the current word is a distance of 3 - any paths that would increase this distance above 3 wouldn't be allowed to survive.

Do you mean Hamming distance?

Since we are only using valid words, no path could ever be shorter than the Hamming distance.

...but at least you could avoid testing for the solution until you're past the minimum distance.

love - shit (Hamming Distance = 4) love-lore-sore-sort-soot-shot-shit (Actual Distance = 6)

Not testing may seem like a win but I doubt it. This is because there is no significant difference between $cur_dist > $min_dist and $word eq $tgt.

Just trade space for speed and precompute every path

If you mean precompute every path from every word to any other word it can reach, this certainly would be faster runtime. Unfortunately, I doubt this would be practical. If you mean precompute all paths from the source and then only look at the paths that are beyond the minimum distance, this is a gamble because you won't know how many paths exist beyond the actual solution. The current method is to abort searching when a path is found.

Cheers - L~R