diff --git a/day-03/internal/one/solve.go b/day-03/internal/one/solve.go index f4e9bf6..0d73083 100644 --- a/day-03/internal/one/solve.go +++ b/day-03/internal/one/solve.go @@ -5,8 +5,6 @@ import ( "bytes" "io" "regexp" - - "github.com/onyx-and-iris/aoc2024/day-03/internal/util" ) var reMul = regexp.MustCompile(`mul\(([0-9]{1,3}),([0-9]{1,3})\)`) @@ -28,7 +26,7 @@ func parseLines(r io.Reader) (int, error) { for scanner.Scan() { matches := reMul.FindAllStringSubmatch(scanner.Text(), -1) for _, m := range matches { - sum += util.MustConv(m[1]) * util.MustConv(m[2]) + sum += mustConv(m[1]) * mustConv(m[2]) } } diff --git a/day-03/internal/util/util.go b/day-03/internal/one/util.go similarity index 53% rename from day-03/internal/util/util.go rename to day-03/internal/one/util.go index b02895e..c7b6c6c 100644 --- a/day-03/internal/util/util.go +++ b/day-03/internal/one/util.go @@ -1,10 +1,8 @@ -package util +package one -import ( - "strconv" -) +import "strconv" -func MustConv(s string) int { +func mustConv(s string) int { n, err := strconv.Atoi(s) if err != nil { panic(err) diff --git a/day-03/internal/two/solve.go b/day-03/internal/two/solve.go index e76cbbb..3a6591c 100644 --- a/day-03/internal/two/solve.go +++ b/day-03/internal/two/solve.go @@ -6,8 +6,6 @@ import ( "io" "regexp" - "github.com/onyx-and-iris/aoc2024/day-03/internal/util" - log "github.com/sirupsen/logrus" ) @@ -43,7 +41,7 @@ func parseLines(r io.Reader) (int, error) { if do { if m[1] != "" && m[2] != "" { log.Debugf("%s * %s\n", m[1], m[2]) - sum += util.MustConv(m[1]) * util.MustConv(m[2]) + sum += mustConv(m[1]) * mustConv(m[2]) } } } diff --git a/day-03/internal/two/util.go b/day-03/internal/two/util.go new file mode 100644 index 0000000..92da662 --- /dev/null +++ b/day-03/internal/two/util.go @@ -0,0 +1,11 @@ +package two + +import "strconv" + +func mustConv(s string) int { + n, err := strconv.Atoi(s) + if err != nil { + panic(err) + } + return n +}