package main import ( "bufio" "fmt" "log" "os" "unicode" ) func main() { f, err := os.Open("input.txt") if err != nil { log.Fatal(err) } defer f.Close() sum := 0 scanner := bufio.NewScanner(f) for scanner.Scan() { line := scanner.Text() first := -1 last := -1 for _, c := range line { if unicode.IsNumber(c) { n := int(c - '0') if first == -1 { first = n last = n } else { last = n } } } sum += 10*first + last } fmt.Println(sum) if err := scanner.Err(); err != nil { log.Fatal(err) } }