Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What are the answers using Python? Words that contain given letter sequence def words_with_letters (words, letters): This might be a good place to bring in

image text in transcribedimage text in transcribed

What are the answers using Python?

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, hereas 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 'klore' Expected result (using the wordlist words_sorted.txt) ['booklore', 'booklores', 'folklore' 'folklores', 'kaliborite' 'kenlore', 'kiloampere' 'kilocalorie', 'kilocurie', 'kilogramme' 'kilogrammetre', 'kilolitre', 'kilometrage', 'kilometre', 'kilooersted', 'kiloparsec', 'kilostere', 'kiloware'] 'brohiic' ['bronchiectatic', 'bronchiogenic', 'bronchitic', ombrophilic', 'timbrophilic'] azaz' ['azazel', 'azotetrazole', 'azoxazole', diazoaminobenzene', 'hazardize' 'razzmatazz'] Taxi zum zum def taxi_zum_zum (moves): A taxicab cruising around the Manhattan street grid starts at the origin (0,0) of the infinite two- dimensional lattice grid of all pairs of integers, denoted by Z2. This taxicab has a direction that is always one of the four main compass directions, initially heading north. The taxicab then faithfully executes the given sequence of moves, guaranteed to be a string made up of the characters 'L' for turning 90 degrees left (while standing in place), 'R' for turning 90 degrees right (ditto), and 'F' for moving one step forward towards the current heading. This function should return the final position of the taxicab in the integer grid coordinates of this infinitely spanning Manhattan. moves Expected result RFRL' (1, 0) 'LFFLF' (-2, -1) 'LLFLFLRLFR' (1, 0) 'FR' * 1000 (0, 0) 'FFLLLFRLFLRFRLRRL' (3, 2) As an aside, why do these problems always seem to take place in Manhattan and evoke nostalgic visuals of Jackie Mason or that Woodsy Allen fellow talking with the grumpy immigrant cabbie and various colourful bystander characters, instead of being set in, say, the mile high city of Denver whose street grid is rotated 45 degrees from the main compass axes to equalize the amount of daily sunlight on streets laid out in both orientations? That ought to make for an interesting variation to many problems of this spirit. Unfortunately, diagonal moves always maintain the total parity of the coordinates, which makes it impossible to reach any coordinates of opposite parity in this manner, as in that old joke with the punchline "Gee... I don't think that you can get there from here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions