Skip to main content

Word ladder find path between two words, changing one letter each step

Project description

Find path from one word to another, changing one letter each step, and each intermediate word must be in the dictionary, the dictionary is a text file with words separated by a line break like the one found in /usr/share/dict/words

Prerequisites

  • Python 3.4 and Linux

  • List of words separated by newlines

  • Virtual environment is recommended

Documentation

Installing

From PyPi

$ pip install word-ladder

Manually

Clone the repository (Pypi package comming soon)

$ git clone git@github.com:snebel29/word_ladder.git
$ cd word_ladder
$ pip install .

to install development dependencies as well

$ pip install -e .[dev]

Getting started

The word_ladder packges commes with both, a command line tool and a module that can be used to find word ladder paths

Command line tool

Once installed you can use the command line interface

$ word_ladder -h

Python module

You can import and use the module directly as well

>>> from word_ladder import WordLadder
>>> wl = WordLadder('tests/word_lists/linux_english_words')
>>> wl.find_path('fear', 'sail')
['fear', 'hear', 'heir', 'hair', 'hail', 'sail']
>>> wl.find_path('Abe', 'sail')
['Abe', 'be', 'bed', 'bid', 'aid', 'said', 'sail']
>>> wl.find_path('Am', 'sail')
['Am', 'am', 'aim', 'ail', 'sail']

Running the tests

You will have to use nose to run the tests

$ nosetests

Contributing

Clone development branch then create pull requests against it

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

word-ladder-1.1.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page