Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Goal: Unscramble permuted words by generating all permutations of Jumble string and searching for a word in Unix dictionary. Unix Dictionary: dict.txt Details: Write a

  • Goal: Unscramble permuted words by generating all permutations of Jumble string and searching for a word in Unix dictionary.
  • Unix Dictionary: dict.txt

Details:

  1. Write a method called get_permutations that inputs a string like "dog". Your method should return an array of all permutations of the Jumble string. . For example:
    s = "dog" perms = get_permutations(a) print(perms) Output: ['dog', 'dgo', 'odg', 'ogd', 'gdo', 'god'] 
    Rewrite the script for obtaining permutations and the end of the Comments, Hints, and Observersions section below to a script that defines the method get_permutations.
  2. Compare the words in the Unix dictionary to the permutation strings in the array. Print any matches that are found. Here is some pseudocode that might help you:
    Define get_permutations method (Item 2. # Start main script. # Indicate in a comment the Jumble strings you # use for testing. Include at least two test strings. Input Jumble string from keyboard. Obtain array of permutations from array using get_permutations method. Open Unix dictionary file to obtain file object fin. Get first line of dictionary file. while more lines in dictionary file get line Get word from current line by removing at end of line. if word starts with a lower case letter for each permutation in array called perm if perm is equal to word print word exit script (optional) end end end Get next line of dictionary file. end Close file object fin. 
    The reason we only consider words that start with lower case letters is that Jumble strings never represent proper names.

Python Programming.

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

If p-value

Answered: 1 week ago