remove internal/util

This commit is contained in:
onyx-and-iris 2025-01-07 17:20:07 +00:00
parent a6295375aa
commit feb0ae4617
4 changed files with 16 additions and 11 deletions

View File

@ -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])
}
}

View File

@ -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)

View File

@ -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])
}
}
}

View File

@ -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
}