Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for python users ! Write a function all strings which takes as input a string alphabet without duplicate characters and a non-negative integer n and

for python users ! image text in transcribed
Write a function all strings which takes as input a string alphabet without duplicate characters and a non-negative integer n and which returns a list consisting of all strings (without duplicates of length n such that each character in s belongs to alphabet For example: all strings('A', ) should return 01 all strings('A', 1) should return L'Al. all strings('A', 2) should return t'A'. all strings (AB', 2) should return 'A', 'AB, BA', 'BB' or some rearrangement of that list. all strings ('ABC', 2) should return 'AA', 'AB', 'BA', '88, 'AC', 'CA, CC, BC, CB'1 or some rearrangement of that .allstrings ("AB, 3) should return (AAA, AAB', ABA', 'ABB', 'BAA', 'BAB', 'BBA', 'BBB') or some rearrangement of that list Hint. Recursion 1 : def all strings (alphabet, n): # YOUR CODE HERE raise Not ImplementedError() - 1 1: assert all strings('A',0) [1: assert all strings('A', 1) = ('A'I Ul: assert set all strings ('ABC', 2)) = set('AA', 'AB', 'AC, 'BA', 'BB', 'BC', 'CA', 'C', 'C' 1 1: assert set all strings AB', 3)) - set('AAA', 'AAB', 'ABA', 'ABB, BAA', 'BAB', 'BBA'. *B881) 1

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

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions