------art_1684_4926274.1125395212538
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I updated my solution:

- No longer outputs solution in reverse order
- Can calculate a chain along multiple words
- Nicer commandline parsing

an example follows:

bschroed@black:~/svn/projekte/wordchain$ time ruby wordchain.rb -d
/usr/share/dict/british-english ruby duck send self
Loading database
Searching connection between ruby and duck
ruby
rubs
dubs
duns
dunk
duck

Searching connection between duck and send
duck
fuck
funk
fund
fend
send

Searching connection between send and self
send
wend
weld
well
sell
self


real    0m3.796s
user    0m3.356s
sys     0m0.439s

regards,

Brian

-- 
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/

------art_1684_4926274.1125395212538
Content-Type: application/x-ruby; name="wordchain.rb"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="wordchain.rb"

IyEvdXNyL2Jpbi9ydWJ5IC13IC1LdQoKIyBCdWlsZCBhIGNoYWluIG9mIHdvcmRzLCB3aGVyZSBl
YWNoIG5leHQgd29yZCBpbiB0aGUgY2hhaW4gY2hhbmdlcyBvbmx5IG9uZSBsZXR0ZXIgYWdhaW5z
dCB0aGUgZm9ybWVyLgojCiMgV2h5IGlzIG15IHNvbHV0aW9uIGZhc3Q6CiMgMSkgSSB1c2UgdGhl
IEEqIGFsZ29yaXRobQojIDIpIEkgdXNlIGEgcmVhbCBwcmlvcml0eSBxdWV1ZSBpbXBsZW1lbnRl
ZCBpbiBDIHdpdGg6CiMgICAgICBhbW9ydGl6ZWQgTygxKSBpbnNlcnQsIGRlY3JlYXNlX3ByaW9y
aXR5CiMgICAgICBhbW9ydGl6ZWQgTyhsb2cgbikgZGVsZXRlX21pbiAgCiMKIyBJIGNhbGN1bGF0
ZSB0aGUgbmVpZ2hib3VycyBsYXppbHkgd2hlbiBuZWVkZWQuCiMgSSB1c2UgYSBuaWZ0eSBwYXJ0
aXRpb25pbmcgb2YgdGhlIHdvcmRzIHRoYXQgbWFrZXMgbmVpZ2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XNjdWUgPT4g
ZQogICAgcHV0cyAiSW52YWxpZCBDb21tYW5kbGluZSBBcmd1bWVudHMiCiAgICBwdXRzIGUKICAg
IHB1dHMgb3B0aW9ucwogICAgZXhpdAogIGVuZAoKICBpZiBvcHRpb25zLmhlbHAgCiAgICBwdXRz
IG9wdGlvbnMKICAgIGV4aXQKICBlbmQKCiAgIyMjIE1ha2UgaGltIHdvcmsgIyMjCgogIHdhcm4g
IkxvYWRpbmcgZGF0YWJhc2UiCiAgd29yZG5ldCA9IFdvcmROZXQubG9hZChvcHRpb25zLmRhdGFi
YXNlKQoKICBvcHRpb25zLndvcmRzWzAuLi0yXS56aXAob3B0aW9ucy53b3Jkc1sxLi4tMV0pIGRv
IHwgZnJvbSwgdG8gfAogIHdhcm4gIlNlYXJjaGluZyBjb25uZWN0aW9uIGJldHdlZW4gI3tmcm9t
fSBhbmQgI3t0b30iCiAgICBwdXRzIHdvcmRuZXQuZmluZF9jaGFpbihmcm9tLCB0bykKICAgIHB1
dHMKICBlbmQKZW5kCg------art_1684_4926274.1125395212538--