Skip to content

Instantly share code, notes, and snippets.

@erhaem
Created October 6, 2025 14:25
Show Gist options
  • Select an option

  • Save erhaem/ad2e1705a42ceac3ef085dbbbd194309 to your computer and use it in GitHub Desktop.

Select an option

Save erhaem/ad2e1705a42ceac3ef085dbbbd194309 to your computer and use it in GitHub Desktop.
rounding students grades hackerrank
package main
import (
"fmt"
)
func main() {
grades := []int32{73, 67, 38, 33}
fmt.Println(grades)
ngrades := gradingStudents(grades)
fmt.Println(ngrades)
}
func gradingStudents(grades []int32) []int32 {
for i := 0; i < len(grades); i++ {
grade := grades[i]
next := ((grade / 5) + 1) * 5
diff := next - grade
if diff < 3 && grade > 38 {
grades[i] = next
}
}
return grades
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment