aoc21/d8/p1.go

22 lines
347 B
Go
Raw Normal View History

2022-02-21 22:28:30 +02:00
package d8
import (
"strings"
)
func P1(in string) int {
lines := strings.Split(strings.TrimSpace(in), "\n")
sum := 0
for _, line := range lines {
for _, digit := range strings.Split(strings.Split(line, "|")[1], " ") {
if len(digit) == 2 || len(digit) == 3 || len(digit) == 4 || len(digit) == 7 {
sum++
}
}
}
return sum
}