1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aleksklad [387]
3 years ago
5

An anagram of a string is another string with the same characters in the same frequency, in any order. For example 'ab', 'bca, a

cb), 'bac', 'cba, 'cab' are all anagrams of the string 'abc'. Given two arrays of strings, for every string in one list, determine how many anagrams of it are in the other list. Write a function that receives dictionary and query, two string arrays. It should return an array of integers where each element i contains the number of anagrams of queryll that exist in dictionary.
Computers and Technology
1 answer:
nlexa [21]3 years ago
4 0

Answer:

from collections import Counter

def anagram(dictionary, query):

   newList =[]

   for element in dictionary:          

       for item in query:

           word = 0

           count = 0

           for i in [x for x in item]:

               if i in element:

                   count += 1

                   if count == len(item):

                       newList.append(item)

   ans = list()

   for point in Counter(newList).items():

       ans.append(point)

   print(ans)        

mylist = ['jack', 'run', 'contain', 'reserve','hack','mack', 'cantoneese', 'nurse']

setter = ['ack', 'nur', 'can', 'con', 'reeve', 'serve']

anagram(mylist, setter)

Explanation:

The Counter class is used to create a dictionary that counts the number of anagrams in the created list 'newList' and then the counter is looped through to append the items (tuple of key and value pairs) to the 'ans' list which is printed as output.

You might be interested in
Iglesias intends to use a word processing program to create a web page. Which of these options should Iglesias use?
Murrr4er [49]
He should view the Outline THEN the Layout and finally preview in web browser.
6 0
3 years ago
3 ᴍᴜʟᴛɪᴘʟᴇ-ᴄʜᴏɪᴄᴇ Qᴜᴇꜱᴛɪᴏɴꜱ
Damm [24]
4, 1, and 3

The last one I am going to say three because I know that friends show other friends so I wouldn’t call that “private”
6 0
2 years ago
Downlad the file and write a program named Lab10b_Act2.py that does the following: Opens the CSV file for reading Reads the CSV
a_sh-v [17]
他們會不會是因為這樣就是說他們的問題,他們會會覺得委屈覺得我
5 0
2 years ago
Your friend Amy calls you asking for help with her new LCD monitor. She says the monitor isn't showing the whole picture. What i
swat32

Answer:     probably 1080p (which is HD)

Explanation:    Lcd monitors mainly support 1080p.

3 0
2 years ago
Microsoft acknowledged that if you type a res:// url (a microsoft-devised type of url) which is longer than ____ characters in i
cluponka [151]
Which is longer than 20 characters
5 0
3 years ago
Other questions:
  • Who are the founders of Microsoft?
    5·1 answer
  • assume an int array, candy, stores the number of candy bars sold by a group of children wherecandy[j] is the number of candy bar
    7·2 answers
  • The primary benefit of a VPN that uses _________ is that an intercepted packet reveals nothing about the true destination system
    6·1 answer
  • Five examples of technology in community​
    7·2 answers
  • 4.11 lesson practice edhesive
    8·2 answers
  • The use of a concept or product from one technology to solve a problem in an unrelated one
    11·1 answer
  • Arrange the Jumbled letters 1.eilf ngrihsa ________________ 2.cersityu ourreecs ________________ 3. ngrihsa ________________ 4.
    12·1 answer
  • Assume the size of an integer array is stored in $s0 and the address of the first element of the array in the memory is stored i
    10·1 answer
  • ASAP 50 POINTS
    14·1 answer
  • How ict tools changed the way we live explain it​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!