Skip to content

Commit c1ae641

Browse files
committed
chore: use common go utils
1 parent 987f84d commit c1ae641

File tree

35 files changed

+79
-715
lines changed

35 files changed

+79
-715
lines changed

go/2023/puzzles/day01/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"strings"
88
"unicode"
99

10-
"github.com/believer/aoc-2024/utils"
11-
"github.com/believer/aoc-2024/utils/files"
10+
"github.com/believer/aoc-utils/files"
11+
"github.com/believer/aoc-utils/utils"
1212
)
1313

1414
func main() {
@@ -61,7 +61,7 @@ func getCalibrationValue(l string) int {
6161
last := getLastDigit(l)
6262

6363
calibrationValue := strconv.Itoa(first) + strconv.Itoa(last)
64-
return utils.FromString(calibrationValue)
64+
return utils.MustIntFromString(calibrationValue)
6565
}
6666

6767
// The rune is the ASCII value of the number, by subtracing with '0' (48)

go/2023/utils/files/files.go

Lines changed: 0 additions & 97 deletions
This file was deleted.

go/2023/utils/utils.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

go/2023/utils/utils_test.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

go/2024/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ create-day:
1111
test:
1212
@go test ./puzzles/day$(PADDED_DAY)
1313

14+
test-all:
15+
@go test ./...
16+
1417
# run=XXX provide a regex that doesn't match any tests, effectively
1518
# skipping the testing phase and just running benchmarks
1619
bench:

go/2024/puzzles/day01/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"slices"
66
"strings"
77

8-
"github.com/believer/aoc-2024/utils"
9-
"github.com/believer/aoc-2024/utils/files"
8+
"github.com/believer/aoc-utils/files"
9+
"github.com/believer/aoc-utils/utils"
1010
)
1111

1212
// Part 1 couldn't be improved much in terms of performance.

go/2024/puzzles/day02/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"slices"
66
"strings"
77

8-
"github.com/believer/aoc-2024/utils"
9-
"github.com/believer/aoc-2024/utils/files"
8+
"github.com/believer/aoc-utils/files"
9+
"github.com/believer/aoc-utils/utils"
1010
)
1111

1212
// Took me some time to wrap my head around solving part 2

go/2024/puzzles/day03/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"regexp"
66
"strings"
77

8-
"github.com/believer/aoc-2024/utils"
9-
"github.com/believer/aoc-2024/utils/files"
8+
"github.com/believer/aoc-utils/files"
9+
"github.com/believer/aoc-utils/utils"
1010
)
1111

1212
// Wasted a couple of minutes when I didn't see that the test input had

go/2024/puzzles/day04/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package main
33
import (
44
"fmt"
55

6-
"github.com/believer/aoc-2024/utils/files"
7-
"github.com/believer/aoc-2024/utils/grid"
6+
"github.com/believer/aoc-utils/files"
7+
"github.com/believer/aoc-utils/grid"
88
)
99

1010
// Changed part 1 to take a similar approach to what I did in part 2
@@ -34,7 +34,7 @@ func part1(name string) int {
3434
// Do we have enough items to check?
3535
offByThree := grid.Point{X: x + 3*dx, Y: y + 3*dy}
3636

37-
if _, ok := xmasGrid.Contains(offByThree); !ok {
37+
if _, ok := xmasGrid.TryGet(offByThree); !ok {
3838
continue
3939
}
4040

@@ -71,11 +71,11 @@ func part2(name string) int {
7171
continue
7272
}
7373

74-
if _, ok := xmasGrid.Contains(point.Add(grid.TOPLEFT)); !ok {
74+
if _, ok := xmasGrid.TryGet(point.Add(grid.TOPLEFT)); !ok {
7575
continue
7676
}
7777

78-
if _, ok := xmasGrid.Contains(point.Add(grid.BOTTOMRIGHT)); !ok {
78+
if _, ok := xmasGrid.TryGet(point.Add(grid.BOTTOMRIGHT)); !ok {
7979
continue
8080
}
8181

go/2024/puzzles/day05/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"slices"
66
"strings"
77

8-
"github.com/believer/aoc-2024/utils"
9-
"github.com/believer/aoc-2024/utils/files"
8+
"github.com/believer/aoc-utils/files"
9+
"github.com/believer/aoc-utils/utils"
1010
)
1111

1212
// Was able to improve performance a bunch by doing less work (shocker!)

0 commit comments

Comments
 (0)