[HackerRank] Grading Students

Jongmin Lee (SAVZAK)·2021년 5월 27일
0

HackerRank

목록 보기
4/39

[문제 내용]

Sam is a professor at the university and likes to round each student's according to these rules:

  1. If the difference between the grades and the next multiple of 5 is less than 3, round grade up to the next multiple of 5.
  2. If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.

[입력]

The first line contains a single integer n , the number of students.
Each line i of the n subsequent lines contains a single integer, grades[i].

[출력]

int[n] : the grades after rounding as appropriate.

[코드]

def gradingStudents(grades):
    # Write your code here
    for i in range(len(grades)):
        if(grades[i]<38):
            continue
        else:
            up = (grades[i]//5)+1;
            if((up*5) - grades[i] < 3):
                grades[i] = up*5
    return grades
profile
느리지만 단단하게 걷는 개발자

0개의 댓글