Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part III: Are You a Permutation? (3 points) A permutation of a list or string is a rearrangement of the elements in the list or

Part III: Are You a Permutation? (3 points)

A permutation of a list or string is a rearrangement of the elements in the list or string. For example, given the list [1,2,3,4], permutations would include [2,4,1,3], [4,3,1,2] and [3,2,4,1]. Likewise, given the string dome, permutations would include edom, emod and mode.

Write a function permutations() that takes a string argument, opens the file words.txt (provided on Blackboard) and returns a list consisting of all permutations of the string argument found in the file (if any). The original word should not be included in the returned list. The function may return the words in any order inside the list.

Examples:

Function Call

Return Value

permutations(veil) 
[evil, levi, live, vile] 
permutations(tori) 
[riot, trio] 
permutations(dad) 

[add]

permutations(ado) 

[]

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions