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
Which tab of the ribbon includes the links group for creating hyperlinks or internal references?
Deffense [45]
The correct answer is D.File
5 0
3 years ago
Read 2 more answers
Read the scenarios below, then use the drop-down menus to decide if you should use a database.
Romashka [77]

Answer:

A. The parent-teacher orginization keeps a log of cookies sales to raise money for the elementary school.

Explanation:

5 0
3 years ago
Which rule should be followed to stay safe online?
anyanavicka [17]

Answer:

Avoid sharing photos with anyone online.

Explanation:

People can track you down. Its not worth to be kidnapped. Stay safe.

4 0
3 years ago
The list below show test scores for 3rd period on a recent test.
Serhud [2]

Answer:

dshfjkahsdfkjhasdkjfasd

Explanation:

this is what u get for doing this to others foool

6 0
3 years ago
Which value for the display property is useful when configuring horizontal navigation within an unordered list?
ikadub [295]
The Block:Inline is the value for the display property which is very useful when configuring horizontal navigation within an unordered list.The element will be still supplied as an inline element even in actual it is really a block element.
6 0
3 years ago
Other questions:
  • A smart refrigerator can use _____ to detect when you are running low on milk, and then send a reminder to you on a wireless net
    14·1 answer
  • What runs a network, steering information between computers and managing security and users?
    11·1 answer
  • A personal career profile for can be used to match what you know about yourself to what you know about different careers
    7·2 answers
  • To resize columns in a subform, press and hold or right-click the subform in the navigation pane, and tap or click ____ on the s
    12·1 answer
  • The primary benefit of a VPN that uses _________ is that an intercepted packet reveals nothing about the true destination system
    6·1 answer
  • You wish to lift a 12,000 lb stone by a vertical
    7·1 answer
  • A researcher plans to identify each participant in a certain medical experiment with a code consisting of either a single letter
    10·1 answer
  • Write a program that allows two players to play a game of tic-tac-toe. Use a two dimensional char array with three rows and thre
    7·1 answer
  • Assume that a signal is encoded using 12 bits. Assume that many of the encodings turn out to be either 000000000000, 00000000000
    9·1 answer
  • Which of the following uses the proper syntax for creating an HTML comment?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!