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 of the following terms describes surgery through a small incision in the abdomen?
ra1l [238]
Which of the following terms describes surgery through a small incision in the abdomen? Laparoscopy. Laparoscopy is super done by using a fiber-optic instrument that is inserted through the abdomen. When this type of instrument is used, the incision is small and there are smaller cuts made to the person being operated on. 
4 0
3 years ago
5. The best way to clear your Reader is to
Fantom [35]

Answer:

Mark all posts as read

Explanation:

I've did it before

7 0
3 years ago
Read 2 more answers
Hey yall! Its spoopy season! I am having a live stream on the Spoon app under the username teendragonqueen️‍ if yall wanna join!
Aleks [24]

Answer:

Ok sounds cool.

Explanation:

3 0
3 years ago
Read 2 more answers
Special computers, called __________, keep databases of IP addresses and their corresponding names
vitfil [10]
Name servers.
-----------------------------------------------------------
4 0
3 years ago
PLEASE HELP ME!!!!!
gizmo_the_mogwai [7]

Answer:

Unicode

Explanation:

This is a fairly large code and Is well known throughout my family since we study ancient codex and modern codes to solve crimes and find relics of the past, although our research has proven good and unicode is one that is being studied currently now, I have found it as long and very time consuming. Although ASCII is a computer code that consists of graphs and numbers it actually shortens the text. and hexadecimal has been proven to be less reliable and binary is a short code with little symbols

8 0
2 years ago
Read 2 more answers
Other questions:
  • I need a idea of a origami for my coding class and it needs to be easy to make
    15·2 answers
  • You have been hired to set up a network for XYZ Enterprises. What factors will you consider to determine the type of network nee
    7·2 answers
  • A(n ____ with a drop down menu provides consistency in function and appearance making it easy for users to learn and work with t
    7·1 answer
  • Whats the Sioux City school wifi?
    15·2 answers
  • How many apostrophes or quotation marks in a row should you use to begin and end a multi-line string?
    14·2 answers
  • Can you plug a usb 2.0 into a 3.0 port on your computer
    12·1 answer
  • __________ has led to the belief that the Internet is "free".
    8·1 answer
  • The ____ refers to a world where everyday physical objects are connected to, and uniquely identifiable on, the Internet so they
    6·1 answer
  • A _____ is a number that summarizes an encrypted information. digital certificate hash function message digest hash algorithm
    8·1 answer
  • Which tool can be used to increase the space between a bullet point or a number and text?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!