mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 06:10:47 +00:00
remove internal/util
This commit is contained in:
parent
a6295375aa
commit
feb0ae4617
@ -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])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
@ -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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
day-03/internal/two/util.go
Normal file
11
day-03/internal/two/util.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user