Grading Students

  • + 0 comments

    A rust solution:

    fn gradingStudents(grades: &[i32]) -> Vec<i32> {
        grades.iter()
            .map(|&x| {
                let modulo = 5 - (x % 5);
                if x >= 38 && (modulo > 0 && modulo < 3) {
                    x + modulo
                } else {
                    x
                }
            })
            .collect()
    }