You are viewing a single comment's thread. Return to all comments →
My solution in Scala:
def gradingStudents(grades: Array[Int]): Array[Int] = { grades.map(number => { if (number < 38) { number } else { val nextMultipleOf5 = ((number / 5) + 1) * 5 if (nextMultipleOf5 - number < 3) nextMultipleOf5 else number }}) }
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 →
My solution in Scala:
def gradingStudents(grades: Array[Int]): Array[Int] = { grades.map(number => { if (number < 38) { number } else { val nextMultipleOf5 = ((number / 5) + 1) * 5 if (nextMultipleOf5 - number < 3) nextMultipleOf5 else number }}) }