https://github.com/danielkummer/kata_word_chains
Code kata about building word chains
https://github.com/danielkummer/kata_word_chains
Last synced: 11 months ago
JSON representation
Code kata about building word chains
- Host: GitHub
- URL: https://github.com/danielkummer/kata_word_chains
- Owner: danielkummer
- Created: 2015-03-31T12:18:57.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-31T12:28:50.000Z (about 11 years ago)
- Last Synced: 2025-07-10T21:27:04.740Z (11 months ago)
- Language: Ruby
- Size: 953 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Code kata - word chains
See [the official kata page](http://codekata.com/kata/kata19-word-chains/)
# 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