view combinations_permutations/similar_words/question.rst @ 0:20fea762903e

Import some exercises and solutions
author Louis Opter <kalessin@kalessin.fr>
date Sat, 29 Jun 2013 19:30:31 -0700
parents
children
line wrap: on
line source

Similar Words
=============

Write a function that take a word in argument. Return the list of words that
have a distance <= 1 from the given word. (i.e: the list of words that are only
different by one letter from the given word).

Possible edits: add, remove or change a letter.

A function ``is_in_dictionary(word) → bool`` is provided.

For example, if we had this dictionary: ['bat', 'cat', 'batt', 'beetle']::

    similar('bat') → ['bat', 'cat', 'batt']
    similar('cat') → ['bat', 'cat']