We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I noticed that noone (including the test cases themselves) do any kind of validation. Not even against the constraints clearly noted in the problem itself?
Is there a reason for this?
I've tried submitting the below code, but it fails a few of the test cases. Unfortunately, I can't check why as the custom test input does not accept the input from the test cases due to size constraint. This tells me that for some of the test cases, the constraints are not met, and the test cases should have failed?
importretry:num_of_words=int(input())exceptValueError:raiseException("Input was not a number")ifnum_of_words<1ornum_of_words>10**5:raiseException("Too many words")try:word=input().strip()exceptEOFError:raiseException("No input")word_dict={}word_len_acc=0whileword:ifre.match(r".*([A-Z]).*",word)orre.match(r".*([0-9]).*",word):raiseException("No capital letters are allowed")ifwordnotinword_dict.keys():word_dict[word]=1else:word_dict[word]=word_dict[word]+1word_len_acc+=len(word)ifword_len_acc>10**6:raiseException("Sum of word lengths can not exceed 1,000,000")try:word=input().strip()exceptEOFError:breakprint(len(word_dict.keys()))fornuminsorted(word_dict.values(),reverse=True):print(num,end=" ")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Word Order
You are viewing a single comment's thread. Return to all comments →
I noticed that noone (including the test cases themselves) do any kind of validation. Not even against the constraints clearly noted in the problem itself?
Is there a reason for this?
I've tried submitting the below code, but it fails a few of the test cases. Unfortunately, I can't check why as the custom test input does not accept the input from the test cases due to size constraint. This tells me that for some of the test cases, the constraints are not met, and the test cases should have failed?