You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
445 B
28 lines
445 B
package adventoc2024
|
|
|
|
import (
|
|
"io"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
type Day3 struct{}
|
|
|
|
func (d Day3) Part1(r io.Reader) string {
|
|
var bd strings.Builder
|
|
var sum int
|
|
io.Copy(&bd, r)
|
|
|
|
re := regexp.MustCompile(`mul\((\d{1,3}),(\d{1,3})\)`)
|
|
|
|
matches := re.FindAllStringSubmatch(bd.String(), -1)
|
|
|
|
for _, match := range matches {
|
|
sum += atoi(match[1]) * atoi(match[2])
|
|
}
|
|
return printi(sum)
|
|
}
|
|
|
|
func (d Day3) Part2(r io.Reader) string {
|
|
return ""
|
|
}
|
|
|