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.
There is an issue with the question. It assumes the input to have the first element as the number of students (not a grade). However, my code only worked when considering the first element (grades[0] in python)..
Code
def complement(x, m):
return (m - (x % m)) % m
def gradingStudents(grades):
result = [] # Create a new list instead of modifying grades
for grade in grades:
if grade < 38 or grade % 5 < 3:
result.append(grade) # No rounding needed
else:
result.append(grade + complement(grade, 5)) # Round up properly
return result # Return a new list
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Grading Students
You are viewing a single comment's thread. Return to all comments →
There is an issue with the question. It assumes the input to have the first element as the number of students (not a grade). However, my code only worked when considering the first element (grades[0] in python)..
Code
def complement(x, m): return (m - (x % m)) % m
def gradingStudents(grades): result = [] # Create a new list instead of modifying
grades