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.
Grading Students
Grading Students
Sort by
recency
|
4010 Discussions
|
Please Login in order to post a comment
Python solution
Python solution
def complement(x, m): return (m - (x % m)) % m
def gradingStudents(grades): result = [grade if grade<38 or grade%5<3 else grade + complement(grade, 5) for grade in grades] return result
I tested my solution in VSCode and results are correct, but i cannot submit as I get message the results are wrong. Could you check please?
function gradingStudents( grades ) {
const rounded = []; const gradesOnly = [...grades]; gradesOnly.shift(); for( let grade of gradesOnly ) if( grade < 38 || grade % 5 === 0 ) rounded.push(grade); else if( Math.floor(grade / 5) * 5 + 5 - grade < 3) rounded.push(Math.floor(grade / 5) * 5 + 5); else rounded.push(grade); return rounded;
}