adventofcode/01dec/invcaptcha.go
2017-12-02 19:42:50 +01:00

31 lines
371 B
Go

package main
import (
"fmt"
"strconv"
"strings"
)
var in string
var p string
var f string
var sum int
func main() {
fmt.Scanf("%s", &in)
for _, d := range strings.Split(in, "") {
if p == "" {
f = d
} else if p == d {
incr, _ := strconv.Atoi(p)
sum += incr
}
p = d
}
if f == p {
incr, _ := strconv.Atoi(p)
sum += incr
}
fmt.Println(sum)
}