# Word Chains (#65)

**URL:** <https://www.ruby-forum.com/t/word-chains-65/100645>\
**Category:** Ruby\
**Created:** [February 3, 2006, 3:02pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645 "2006-02-03T15:02:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:02pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/1 "2006-02-03T15:02:50Z")

</div>

The three rules of Ruby Q.:

1. Please do not post any solutions or spoiler discussion for this quiz  
until  
48 hours have passed from the time on this message.

2. Support Ruby Q. by submitting ideas as often as you can:

[http://www.rubyquiz.com/](http://www.rubyquiz.com/)

1. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem helps  
everyone  
on Ruby T. follow the discussion.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

When someone asked for a set of exercises on Ruby T. this week, one of  
the  
answers was to check out the Code Katas by Dave T… I’m a big fan  
of those  
problems myself, so let’s do one of them.

This week’s quiz is to write a program that takes two words as program  
arguments. The words will be the same length. Please also support a -d  
command-line option that can be used to switch dictionary files (one  
word per  
line), but it’s fine to use a reasonable default for your system.

The output of your program is to be a word chain, printing one word per  
line.  
The first word in the chain is the first argument to the program and the  
last  
word is the other argument. All other words in the chain vary by  
exactly one  
letter from the words surrounding it. If a chain can not be formed from  
the  
arguments using the selected dictionary, print a simple error message.

Here are some sample runs of my solution, so you can see how chains  
look:

```
$ ruby word_chain.rb work play
work
pork
pory
pony
piny
piky
puky
puly
paly
paty
katy
kath
hath
hash
pash
push
puss
poss
post
pout
prut
prat
plat
play
$ ruby word_chain.rb lead gold
lead
load
goad
gold
$ ruby word_chain.rb love hate
love
hove
have
hate

```

Aim for the shortest paths if you can find them (the above examples may  
not be  
them) and fast running times.

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:18pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/2 "2006-02-03T15:18:00Z")

</div>

- On Feb 3 23:00, Ruby Q. (removed\_email\_address@domain.invalid) wrote:

> When someone asked for a set of exercises on Ruby T. this week, one  
> of the answers was to check out the Code Katas by Dave T… I’m a  
> big fan of those problems myself, so let’s do one of them.

Pardon me if I’m missing something, James, but wasn’t this Quiz #44?

[http://www.rubyquiz.com/quiz44.html](http://www.rubyquiz.com/quiz44.html)

Tom

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:21pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/3 "2006-02-03T15:21:05Z")

</div>

déjà vu?

[http://www.rubyquiz.com/quiz44.html](http://www.rubyquiz.com/quiz44.html)  
(hope I am not violating rule #1)

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:21pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/4 "2006-02-03T15:21:05Z")

</div>

On Feb 3, 2006, at 8:15 AM, Thomas K. wrote:

> - On Feb 3 23:00, Ruby Q. (removed\_email\_address@domain.invalid) wrote:
> 
> > When someone asked for a set of exercises on Ruby T. this week, one  
> > of the answers was to check out the Code Katas by Dave T… I’m a  
> > big fan of those problems myself, so let’s do one of them.
> 
> Pardon me if I’m missing something, James, but wasn’t this Quiz #44?
> 
> [Ruby Quiz - Word Chains (#44)](http://www.rubyquiz.com/quiz44.html)

Boy I’m glad some of you are paying attention, because I’m  
obviously not!

Sorry, I get lots of duplicate ideas sent in. Looks like this is the  
first one I failed to catch.

I’ll get a another quiz out later today…

James Edward G. II

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/5 "2006-02-03T15:30:10Z")

</div>

- On Feb 3 23:20, James Edward G. II (removed\_email\_address@domain.invalid) wrote:

> Boy I’m glad some of you are paying attention, because I’m  
> obviously not!

No problem - we appreciate the work you put in! Love the quizzes, even  
if I’m usually quiet about them.

> I’ll get a another quiz out later today…

Shucks. I was hoping to do this one (avoiding the summary/solution, of  
course) to make up for missing the last 😉

Tom

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/6 "2006-02-03T15:42:17Z")

</div>

Patrick H. schrieb:

> déjà vu?
> 
> [http://www.rubyquiz.com/quiz44.html](http://www.rubyquiz.com/quiz44.html)  
> (hope I am not violating rule #1)

Haha!  
The page turned!  
I made once a submission to make a quiz to build regexp automatically to  
match a range of numbers.  
JEG2 told meto look at quiz4 😉

## errare humanum est

~waiting

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 3, 2006, 3:48pm UTC](https://www.ruby-forum.com/t/word-chains-65/100645/7 "2006-02-03T15:48:21Z")

</div>

On Feb 3, 2006, at 8:39 AM, Robert R. wrote:

> I made once a submission to make a quiz to build regexp  
> automatically to match a range of numbers.  
> JEG2 told meto look at quiz4 😉

My wife asked me a while back, “Hey, have you done a Su Doku quiz?”  
I’m only slightly embarrassed to admit that I had to go look to  
answer her. 🙂

James Edward G. II
