Using Python, given a reference string followed by four more strings, create a program that determines whether those 4 strings are anagrams of the reference string. The output should be a list of boolean values that show if those strings are anagrams (respectively).  There is no need to check if a string is a valid word or not. Do not use sorted() and Counter An anagram means that each string has the exactly the same number of each letter. Given this, count the letters of the string by Using a dictionary and use each letter as a key into the dictionary ; this will give you a dictionary of letter counts. Compare the counts by maintaning one set of counts and increment the counts for the first string, and then decrement the counts for the second string. The strings are anagrams if all the counts end up as zero.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question

Using Python, given a reference string followed by four more strings, create a program that determines whether those 4 strings are anagrams of the reference string. The output should be a list of boolean values that show if those strings are anagrams (respectively). 

There is no need to check if a string is a valid word or not.

Do not use sorted() and Counter

An anagram means that each string has the exactly the same number of each letter.

Given this, count the letters of the string by Using a dictionary and use each letter as a key into the dictionary ; this will give you a dictionary of letter counts.

Compare the counts by maintaning one set of counts and increment the counts for the first string, and then decrement the counts for the second string. The strings are anagrams if all the counts end up as zero.

User inputs the following strings (first string is the reference string):
listen
silent
lentss
lentis
slents
Output:
[True, False, True, False]
Transcribed Image Text:User inputs the following strings (first string is the reference string): listen silent lentss lentis slents Output: [True, False, True, False]
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT