Kodewick
Start learning →
Basic←→0 / 70

How did the game go?

#047BasicFunctionsSlices3 min

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.

Examples
Rounds([]int{4, 9, 2})→(15, 9)
Rounds([]int{7})→(7, 7)
The functionfunc Rounds(points []int) (int, int)
main.go
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
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.