A little runner dashes along a path, and each character of path is one square: c a coin, +1; g a gem, +5; x a spike, -3; . nothing. The score never goes below 0. Write Score(path) to return the score at the end of the run.
Score("c.cg")→7Score("xc")→1Score("")→0func Score(path string) intpackage main
func Score(path string) int {
score := 0
for _, ch := range path {
// your code here: switch on ch, add or take away points; below 0 goes back to 0
}
return score
}
Run tries the examples. When they look right, Submit.