Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python only Question 1: AnagramsSolver [100 marks] Anagrams are words made by rearranging the letters of other words. For example, cheater is an anagram of

Python only

image text in transcribedimage text in transcribed

Question 1: AnagramsSolver [100 marks] Anagrams are words made by rearranging the letters of other words. For example, "cheater" is an anagram of "teacher", or "dictionary" is an anagram of "indicatory". Anagrams have been around since the ancient Greeks and are used in different ways from showing mystical meaning in names to anagrammatic poetry. An interesting example of using anagrams is how scientists announce new discoveries in the 17th century. In 1610, the Italian astronomer Galileo Galilei used the anagram "smaismrmilmepoetaleumibunenugttauiras" for "Altissimum planetam tergeminum observavi" ("I have observed the most distant planet to have a triple form") for discovering the rings of Saturn. You are asked to write a program called AnagramSolver to find the number of all lists of words that are anagrams of each other in a given list of strings. To define more exactly, two words are considered anagrams if 1) There is the same number of characters in both words, and 2) You can form one word by rearranging the characters of another word. AnagramSolver works as follows: - It takes a positive integer n as the first input. Integer n determines the number of words that AnagramSolver is supposed to receive from the user. AnagramSolver assumes the user provides a number greater than zero. - Subsequently, AnagramSolver receives the words in n separate lines. - AnagramSolver is case-insensitive, meaning that it does not discriminate between uppercase and lowercase letters. - AnagramSolver should ignore space and comma characters in the user-provided words. For example, Eleven plus two should be considered as Elevenplustwo. - AnagramSolver should find all sets of words that are anagrams of each other and print out the size of the largest set in a separate line. Three examples are shown in table 1. In example 1, first, the user entered 6 for the number of words. This means AnagramSolver should take 6 words in separate lines from the user. Next, the user entered the words eat, tea, tan, ate, nat and bat. Now, AnagramSolver processes the given words to find the set of words that are anagrams of each other. There are two such sets: { eat, tea, ate } and {tan,nat}. The largest set size is 3 and AnagramSolver prints out 3 . The same logic is applied to other examples. You are free to use the modules introduced during the semester (and nothing beyond) to solve the problem. Note that your program input and output format should be exactly the same as the format of the examples shown in Table 1. Table 1: The AnagramSolver Sample Input and Output

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 Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago