Thursday, 4 February 2021

Step words anagram python

A step word is formed by taking a given word, adding a letter, and anagramming the result. For example, starting with the word "APPLE", you can add an "A" and anagram to get "APPEAL".

Given a global dictionary of words, create a function step(word) that returns a list of all unique, valid step words appearing in the dictionary.

Dictionary: https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt

I made a dictionary using the link using:

>>> words = open('words.txt', encoding='ascii').read().upper().split()

This assignment should be completed without any other library function calls. There are several solutions, but some are better and faster than others. How can you speed up your solution?

The solution should look like this.

>>> step("APPLE")

>>>['APPEAL', 'CAPPLE', 'PALPED', 'LAPPED', 'DAPPLE', 'ALEPPO', 'LAPPER', 'RAPPEL', 'LAPPET', 'PAPULE', 'UPLEAP']


from Step words anagram python

No comments:

Post a Comment