This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # | |
| # Two words are "directly connected" if one word can transform into the other by any of: | |
| # * substitution of one character for another, e.g. "tan" => "ton" | |
| # * insertion of one character, e.g. "tan" => "than" | |
| # * deletion of one character, e.g. "tan" => "an" | |
| # | |
| # Two words are "connected" if applying the rules above repeatedly can directly connect words: | |
| # * e.g. "tan" => "ton" => "tone" => "one" => "on" | |
| # * e.g. "tan" => "an" => "in" => "pin" => "pink" |