A game has several rounds (at least one), and points has each round's score. Write Rounds(points) to return the total and the best round at once.
Rounds([]int{4, 9, 2})→(15, 9)Rounds([]int{7})→(7, 7)func Rounds(points []int) (int, int)package main
func Rounds(points []int) (int, int) {
total, best := 0, points[0]
for _, p := range points {
// your code here: add to total; if it beats best, replace best
}
return total, best
}
Run tries the examples. When they look right, Submit.