From: Ruby Quiz Date: 2006-02-03T23:00:31+09:00 Subject: [QUIZ] Word Chains (#65) The three rules of Ruby Quiz: 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 Quiz by submitting ideas as often as you can: http://www.rubyquiz.com/ 3. Enjoy! Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone on Ruby Talk follow the discussion. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= When someone asked for a set of exercises on Ruby Talk this week, one of the answers was to check out the Code Katas by Dave Thomas. 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.