Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help debugging the following question in Hackerrank. I've attached images on the problem, code, and error I am getting. Fast response would be

I need help debugging the following question in Hackerrank. I've attached images on the problem, code, and error I am getting. Fast response would be greatly appreciated.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. How many Sentences? LL Given an array of words and an array of sentences, determine which words are anagrams of each other. Calculate how many sentences can be created by replacing any word with one of its anagrams. 1 Example wordSet = ['listen! silent! it vis? sentence = "listen it is silent N 2 Determine that listen is an anagram of silent. Those two words can be replaced with their anagrams. The four sentences that can be created are: ::::::: listen it is silent listen it is listen silent it is silent silent it is listen Function Description Complete the countSentences function in the editor below. countSentences has the following parameters: string wordSet[n]: an array of strings string sentences[m]: an array of strings Returns: intl: an array of mintegers that denote the int[]: an array of mintegers that denote the number of sentences that can be formed from each sentence ALL Constraints 01: count-countdict[s] arr.append(count) I return arr 26 27 28 29 30 31 32 33 34 35 36 37 38 39 46 41 42 -ds at word=0 sentences=0 naint (input) for 1 fn range(n): strsinput() word.append(str) int(input) for 1 in range(m): strainput() sentences.append(str) 45 47 48 49 50 51 52 53 54 arracount Sentences (word, sentences) for i in arr: print (1) Test Results Custom Input Language Python 3 Autocomplete Ready mine many of its words that 44 str=input() 45 word.append(str) 46 maint(input) 47 for 4 in range (m): 48 strainput) 49 sentences.append(str) 58 51 arrucount Sentences (word, sentences) 52 for 1 in arr: 53 print (1) 54 55 vif __name__main__': 56 fptr = open(os.environ('OUTPUT_PATH'), 'W') 57 58 wordSet_count = int(input().strip) 59 68 wordSet 61 62 for in range(wordSet_count): I 63 wordSet 1tem input 64 wordset.append(wordset_iten) 65 66 sentences_count = int(input().strip()) 67 68 sentences - 69 70 for in range(sentences_count): 71 sentences_item = input() 72 sentences.append(sentences_item) 73 74 result = count Sentences (wordset, sentences) 175 76 fptr.write(' '.join(map(str, result))) 77 fptr.write(' ') 78 79 fptr.close() BO w af Test Results Custom Input sentences - 1 for - in range(sentences_count): sentences_iten input() sentences.append(sentences item) result = countSentences (wordset, sentences) 1 2 3 4 es 14 77 75 19 BO fptr.write(''.join(nap (str, result))) fptr.write(' ') fptr.close() Test Results Custom Input Run Code Run Tests Compiled successfully Run all test cases Compiler Message Runtine Error Error at Traceback (most recent call last) File "/tr/uniesien/20220121/01/48/hackerrank-1163205eabsafdafd6924033254533/code/Solution.py", line sa inchedule wordSet_count = int(input().strip) EOFErreri EF when reading a line Inout in MacBook Pro R G Search or type URL + # ( A 20 & 7 ) 0 : 5 6 8 9 { } 0 T U Y I [ sentences count - int (input().strip()) 67 Sentences for in range(sentences_count): sentences its input() sentences.append(sentences sten) result = count Sentences (wordset, sentences) 71 T2 73 14 25 76 T7 78 79 30 fptr.write(' '. Join(map(str, result))) fptr.write(' ') fptr.close() Test Results Custom Input un Code Run Tests Compiled successfully. Run all test cases 6 the bats Labs cat act 1 cat the bats In the act act tabs in MacBook Pro Search or type URL ( & % 5 00 6 7 8 9 0 { T Y U 0 P La Python Autocompleteady sentences_count - int (input().strip) Sentences = 1 67 GA 69 70 7 for in range(sentences_count) sentences ten - input() sentences.append(sentences Iten) result - count Sentences (wordset. sentences) Ta TA 75 TO 77 78 TO 20 fptr.write('in'.join(map(str, result))) fptr.write('in fptr.close() Test Results Custom Input Hun Code Tests Compiled successfully. Run all test cases Your Output - no response on stdout - Expected Out 2 Detai op 2 MacBook Pro G Search or type URL R ( 5 6 7 8 ) 0 WT 8 9 { T Y U 0 P

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions