Skip to content

danielkummer/kata_word_chains

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code kata - word chains

See the official kata page

Exercise

Write a program that solves word-chain puzzles. There’s a type of puzzle where the challenge is to build a chain of words, starting with one particular word and ending with another. Successive entries in the chain must all be real words, and each can differ from the previous word by just one letter. For example, you can get from “cat” to “dog” using the following chain.

  1. cat
  2. cot
  3. cog
  4. dog

The objective of this kata is to write a program that accepts start and end words and, using words from the dictionary, builds a word chain between them. For added programming fun, return the shortest word chain that solves each puzzle. For example, you can turn “lead” into “gold” in four steps (lead, load, goad, gold), and “ruby” into “code” in six steps (ruby, rubs, robs, rods, rode, code). Once your code works, try timing it. Does it take less than a second for the above examples given a decent-sized word list? And is the timing the same forwards and backwards (so “lead” into “gold” takes the same time as “gold” into “lead”)?

My solution

Install by running

	bundle install

Program args:

	Usage: word_chains.rb [options] [file]
Mandatory options:
    -s, --start START_WORD           Enter a start word
    -e, --stop STOP_WORD             Enter a stop word
    -v, --verbose                    Verbose output
    -h, --help                       Display this screen
If no file is supplied it detects based on wordlist.txt

About

Code kata about building word chains

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages