Words that contain given letter sequence def words_with_letters(words, letters): This might be a good place to bring in some general discrete math terminology that makes our problem specifications...



Words that contain given letter sequence

def words_with_letters(words, letters):




This might be a good place to bring in some general discrete math terminology that makes our problem specifications less ambiguous. A substring of a string consists of characters taken in order from consecutive positions. Contrast this with the similar concept of subsequence of characters still taken in order, but not necessarily at consecutive positions. For example, each of the five strings '', 'e', 'put', 'ompu' and 'computer' is both a substring and subsequence of the string 'computer', whereas 'cper' and 'out' are subsequences but not substrings.



Note how the empty string is automatically a substring of every possible string. Every string is always its own substring, although not a proper substring the same way how all other substrings are proper. Concepts of sublist and subsequence are defined for lists in an analogous manner.

Since sets have no internal order on top of the element membership in that set, sets can meaningfully have both proper and improper subsets, whereas the concept of subsequence would be nonsensical for sets and dictionaries.


Now that you know all that, given a list of words sorted in alphabetical order, and a string of required letters, find and return the list of words that contain letters as a subsequence.


letters<br>Expected result (using the wordlist words_sorted.txt)<br>'klore'<br>['booklore', 'booklores', 'folklore', 'folklores',<br>'kaliborite', 'kenlore', 'kiloampere',<br>'kilocalorie', 'kilocurie', 'kilogramme',<br>'kilogrammetre', 'kilolitre', 'kilometrage',<br>'kilometre', 'kilooersted', 'kiloparsec',<br>'kilostere',<br>'kiloware']<br>['bronchiectatic', 'bronchiogenic', 'bronchitic',<br>ombrophilic', 'timbrophilic']<br>'azaz'<br>['azazel', 'azotetrazole', 'azoxazole',<br>'diazoaminobenzene', 'hazardize', 'razzmatazz']<br>

Extracted text: letters Expected result (using the wordlist words_sorted.txt) 'klore' ['booklore', 'booklores', 'folklore', 'folklores', 'kaliborite', 'kenlore', 'kiloampere', 'kilocalorie', 'kilocurie', 'kilogramme', 'kilogrammetre', 'kilolitre', 'kilometrage', 'kilometre', 'kilooersted', 'kiloparsec', 'kilostere', 'kiloware'] ['bronchiectatic', 'bronchiogenic', 'bronchitic', ombrophilic', 'timbrophilic'] 'azaz' ['azazel', 'azotetrazole', 'azoxazole', 'diazoaminobenzene', 'hazardize', 'razzmatazz']
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here