advent-of-code-2023/day-15/part1.go

21 lines
259 B
Go

package main
import (
"strings"
)
func part1(input string) int {
parts := strings.Split(input, ",")
sum := 0
for _, p := range parts {
lsum := 0
for _, c := range p {
lsum += int(c)
lsum *= 17
lsum %= 256
}
sum += lsum
}
return sum
}