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
States that processing power for computers would double every two years
hodyreva [135]

Answer:

Moore's Law

Explanation:

4 0
2 years ago
Jenny is working on a laptop computer and notices that the computer is not running very fast. She looks and realizes that the la
nirvana33 [79]

Answer:

SO-DIMM DDR3

Explanation:

Based on the information provided within the question it can be said that the module that Jenny needs to order is known as SO-DIMM DDR3. This is the type of module that would work on her laptop computer. DDR3 is the most common generation of these RAM modules and SO-DIMM are rams that support 72, 100, 144, or 204 pins and is alot smaller than regular DIMM modules, coming in at about 3 inches.

8 0
3 years ago
Iaz005<br> plz make a new zoom
AURORKA [14]

ohhhhh okkkkkkkk??!! haha

7 0
3 years ago
Read 2 more answers
A slideshow that accompanies an oral report is known as what?
pychu [463]
Presentation :)))))))))))))
5 0
4 years ago
IT professionals should help to protect users’ personal information, such as bank account information or Social Security numbers
sesenic [268]

To prevent theft of account information, identity theft, money, important passwords, and personal information.


Hope it helps ❤️

8 0
4 years ago
Read 2 more answers
Other questions:
  • I found a random Nether Portal in my Minecraft Singleplayer world. Why is it there?
    8·2 answers
  • Why do i have to wait and watch videos
    11·1 answer
  • "Because Standard Error and Standard Ouput represent the results of a command and Standard Input represents the input required f
    6·1 answer
  • A function ________ contains the statements that make up the function.
    5·1 answer
  • Create a dictionary that will hold AT LEAST 3 categories for food with at least 3 foods for each category. E.g. Fruits --&gt; Ap
    6·1 answer
  • Assume that a single page of printed text requires 52 lines of text, and that each line of text averaged 80 characters. If each
    9·1 answer
  • If you were writing a story set in our time, what would you include to give readers a sense of our world? Check any that apply.
    5·1 answer
  • One tool of Lean that is a container, card, or visual limit that signals when work needs to be done or replenishment needs to be
    13·1 answer
  • What is the best Genshin impact ship? My favorite is Xiao x Lumine. Put yours bellow.
    13·2 answers
  • ____ is Windows XP system service dispatch stubs to executables functions and internal support functions.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!