Compare commits
52 Commits
3308431dfa
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bcd7daea9e | |||
| 9c2e2c68dd | |||
|
|
90083f28e5 | ||
|
|
7f6c31c003 | ||
|
|
015607cde3 | ||
| 358249e78a | |||
| d730d3c444 | |||
| 759b9c9544 | |||
|
|
a529516bab | ||
|
|
ba588cbc77 | ||
|
|
225d74acf9 | ||
| 3e69c5b463 | |||
| 6ab021face | |||
| 1ee00e8d45 | |||
| 952def48a0 | |||
| 08b38c2bd3 | |||
| 29387606b0 | |||
|
|
4619bc7775 | ||
|
|
305ce52a98 | ||
|
|
a5b1227979 | ||
|
|
53557adddb | ||
|
|
5b8676f6e0 | ||
|
|
ee128f3aa8 | ||
|
|
d93049c434 | ||
|
|
507cb1a907 | ||
|
|
a64c3ef3c4 | ||
|
|
2c9b7766e3 | ||
|
|
ae293fe5a2 | ||
|
|
c1c89faef8 | ||
| b1a4969f6d | |||
|
|
e2ab6dce9a | ||
| f8c29be7ef | |||
| 19c4afdc98 | |||
|
|
616618c7e2 | ||
|
|
360ae5edbd | ||
|
|
88938a8627 | ||
| 235999524b | |||
|
|
f6f5a10270 | ||
| 8f4649e0aa | |||
| e0b4f292c2 | |||
|
|
8f5cb6b236 | ||
|
|
c133fe757c | ||
| ab9bdc63b1 | |||
| 0034691f2a | |||
| 2584df5496 | |||
| 6753ed26ca | |||
| e9a6c5178a | |||
| 3948cbaa8c | |||
| 84e8207917 | |||
|
|
c53e7db1ea | ||
|
|
d730b7ff9d | ||
|
|
7e3eae9e60 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
2024
|
||||
2023/*
|
||||
|
||||
103
2022/go/day12/day12.go
Normal file
103
2022/go/day12/day12.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package day12
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"adventofcode2022/utils"
|
||||
"adventofcode2022/utils/grid2d"
|
||||
)
|
||||
|
||||
type cell struct {
|
||||
height int
|
||||
distance int
|
||||
}
|
||||
|
||||
type coord struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
startCoord, grid := parseInput(input)
|
||||
fillGrid(grid)
|
||||
printGrid(grid)
|
||||
c := grid.Get(startCoord.x, startCoord.y)
|
||||
return c.distance
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
_, grid := parseInput(input)
|
||||
fillGrid(grid)
|
||||
min := utils.MaxInt
|
||||
for j := 0; j < grid.SizeY(); j++ {
|
||||
for i := 0; i < grid.SizeX(); i++ {
|
||||
c1 := grid.Get(i, j)
|
||||
if c1.height == 0 {
|
||||
min = utils.Min(min, c1.distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
func parseInput(input string) (coord, *grid2d.Grid[*cell]) {
|
||||
lines := strings.Split(input, "\n")
|
||||
grid := grid2d.NewGrid[*cell](len(lines[0]), len(lines), nil)
|
||||
startCoord := coord{-1, -1}
|
||||
for j, line := range lines {
|
||||
for i, c := range line {
|
||||
newCell := &cell{height: int(c - 'a'), distance: utils.MaxInt}
|
||||
if c == 'S' {
|
||||
newCell.height = 0
|
||||
startCoord.x = i
|
||||
startCoord.y = j
|
||||
} else if c == 'E' {
|
||||
newCell.height = 25
|
||||
newCell.distance = 0
|
||||
}
|
||||
grid.Set(i, j, newCell)
|
||||
}
|
||||
}
|
||||
return startCoord, grid
|
||||
}
|
||||
|
||||
func fillGrid(grid *grid2d.Grid[*cell]) {
|
||||
done := false
|
||||
for !done {
|
||||
done = true
|
||||
for j := 0; j < grid.SizeY(); j++ {
|
||||
for i := 0; i < grid.SizeX(); i++ {
|
||||
c1 := grid.Get(i, j)
|
||||
if c1.distance == utils.MaxInt {
|
||||
continue
|
||||
}
|
||||
moves := [][]int{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}
|
||||
for _, move := range moves {
|
||||
x2 := i + move[0]
|
||||
y2 := j + move[1]
|
||||
c2 := grid.Get(x2, y2)
|
||||
if c2 == nil {
|
||||
continue
|
||||
}
|
||||
if c2.height < c1.height-1 {
|
||||
continue
|
||||
}
|
||||
if c2.distance > c1.distance+1 {
|
||||
c2.distance = c1.distance + 1
|
||||
done = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func printGrid(grid *grid2d.Grid[*cell]) {
|
||||
r := grid.StringWithFormatter(func(c *cell, i, j int) string {
|
||||
if c.distance == utils.MaxInt {
|
||||
return "?? "
|
||||
}
|
||||
return fmt.Sprintf("%02d ", c.distance)
|
||||
})
|
||||
fmt.Println(r)
|
||||
}
|
||||
27
2022/go/day12/day12_test.go
Normal file
27
2022/go/day12/day12_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package day12
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`Sabqponm
|
||||
abcryxxl
|
||||
accszExk
|
||||
acctuvwj
|
||||
abdefghi`)
|
||||
require.Equal(t, 31, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`Sabqponm
|
||||
abcryxxl
|
||||
accszExk
|
||||
acctuvwj
|
||||
abdefghi`)
|
||||
require.Equal(t, 29, r)
|
||||
}
|
||||
41
2022/go/day12/input.txt
Normal file
41
2022/go/day12/input.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
abccccaaaaaaaaaaaaaccaaaaaaaacccccccccaaaaaaaaccccccccaaacaaacccccccaaaaaaccccccccccccccccccccccaaaacccccccccccacccccccccccccccccccccccccccccccccccccccccccccccaaaa
|
||||
abccccaaaaacaaaaaaccccaaaaaaccccccccccaaaaaaacccccccccaaaaaaacccccaaaaaaaaaacccccccccccccccccccaaaaaacccccccccaaaaaaaaccccccccccccccccccccccccccccccccccccccccaaaaa
|
||||
abcccaaaaaccaaaaaaccccaaaaaaccccccaacccaaaaaacccccccccaaaaaacccaaaaaaaaaaaaaaacaaccacccccccccccaaaaaaccccccccccaaaaaacccccccccccccccccccccccccccccccccccccccccaaaaa
|
||||
abccccccaaccaaaaaaccaaaaaaaaccccccaaacaaaacaaacccccccaaaaaaaaccaaaaaaaaaaaaaaacaaaaacccccccccccccaaccccccccccccaaaaaaccccccccccccccccccccccccccccacccccccccccaaaaaa
|
||||
abccccccccccaaccaaccaaaaccaacccccccaaaaaaaccccccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccaaaaccccccccccccccccaaaaaaaacccccccccccccccccccccccccccaaccccccccccccccaa
|
||||
abcccccccaaaaacccaaaaaaaacccaaccccaaaaaaccccccccccccaaaaaaaaaaaaaaaacaaaaaaaccaaaaaaccccccaaaaaccccccccccccccaaaaaaaaaaccaccccccccccccccccccccccccaccccccccccccccca
|
||||
abcccccccaaaaacccaaaaaaaaccaaaaccaaaaaaaaccccccccccccccaaacaaaaaaaaacaaaaaacccccaaaacccccaaaaaaccccccccccccccaaaaaaaaaaaaacccccccccccccccllllllccccdccccccccccccccc
|
||||
abccccccaaaaaacccccaaaaccccaaaaacaaaaaaaaccccccccccccccaaacccccaaaccccaaaaaacccaaccccccccaaaaaacccccccccccccccccaaaaaaaaaacccccccccccccklllllllllcddddccaccaaaccccc
|
||||
abccccccaaaaaacccccaaaaaaaaaaaaaaaccaaccccccaacaacccccccaaccccccccccccaaacaacccccccccccccaaaaaacccccccccccccccccaaaaaaaaaacccccccccccckklllppllllcddddddddaaaaccccc
|
||||
abccccccaaaaaaccccaaacaaaaaaaaaaaaccaaccccccaaaaaccccccccccccccccccccccccccccccccccccccccccaaccccccaaccccccccccccaacaaaaaaaccccccccccckklpppppplllmdddddddddacccccc
|
||||
abccccccccaaacccccaacccaccaaaaaaccccccccccccaaaaaaccccccccccccccccccccccccccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccccckkkkppppppplmmmmmmddddddaacccc
|
||||
abccccaaacaaacccccccccccccaaaaaaccccccccccccaaaaaacccccccccccccccccaaaccccccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccccckkkppppuppppmmmmmmmmddeeeacccc
|
||||
abccccaaaaaaacccccccccccccaaaaaacccaccccccccaaaaaacccccccccccccccccaaaacccccccccccccccccccccaaacccaaaacccccccccccaaaacaaaccccccccccckkkpppuuuuuppqqmmmmmmmmeeeacccc
|
||||
abcccccaaaaaaccccccccccccaaaaaaaacaaccccccccccaaaccccccccccccccccccaaaaccccccccccccccccccccaaaaccccccccccccccccccaaaaaaaacccccccccckkkkpppuuuuupqqqqqqqmmmmeeeccccc
|
||||
abcccccaaaaaaaacccccccccccaccccaaaaacccccccccccccccccccccccccccccccaaaccccccccccccccaaaccccaaaacccccccccccccaaccaaaaaaaaccccccccckkkkkrrpuuuxuuuqqqqqqqqmmmmeeccccc
|
||||
abccccaaaaaaaaaccccccccccccccaaaaaacccccccacaacccccccccccccccccccccccccccccccccccccaaaaaacccaaaccccccccccaaaaccaaaaaaacccccccccckkkkrrrrruuuxxuvvvvvvqqqqnnneeccccc
|
||||
abcccaaaaaaaaaaccccccccccccccaaaaaaaacccccaaaaacccccccccccccccaaaaaccccccccccccccccaaaaaaccccccccccccccccaaaaaaaaaaaaacccccccccjjjkrrrrruuuxxxxvvvvvvvqqqnnneeccccc
|
||||
abcaaaaacaaacccccccccccccccccaaaaaaaacccccaaaaaccaacccccccccccaaaaaccccccccccccccccaaaaaccccccccccccccccccaaaaaccaaaaaacccccccjjjrrrrruuuuuxxxyvyyyvvvqqqnneeeccccc
|
||||
abcaaaaacaaaccaaccccccccccccccccaacccccccaaaaaaaaaaaccccccccccaaaaaaccccccccccccccccaaaaaccccccccccccccccaaaaacccaaaaaaaacaaacjjjrrrtttuuxxxxxyyyyyvvvqqnnneeeccccc
|
||||
abaaaaaccaacccaaaccaacccaaccccccaccccccccaaaaaaaaaacccccccccccaaaaaaccccccccccccccccaacaacccccccccccccccccccaacccaaccccaaaaaacjjjrrrtttxxxxxxxyyyyyvvvrrnnneeeccccc
|
||||
SbaaaaacccccccaaaaaaaccaaaacccccccccccccccaaaaaaaaacccccccccccaaaaaaccccccccccccccccccccccccccccccccccccccccccccccaacccaaaaaacjjjrrrtttxxxEzzzzyyyvvvrrnnneeecccccc
|
||||
abcaaaaacccccccaaaaaaccaaaacccccccccccccccaaaaaaaaacccccccccccccaaccccccccccccccccccccccccccccaaccccccccccaaccccacaaaacaaaaaaajjjrrrtttxxxxxyyyyyvvvrrrnnnfffcccccc
|
||||
abcaacccccccaaaaaaaacccaaaaccccccccccccccccaaaaaaaaaaccccccccccccccccccccccccccccccccccccccaaaaaccccccccccaaccccaaaaaaaaaaaaaajjjqqqttttxxxxyyyyyyvvrrrnnnfffcccccc
|
||||
abccccccccccaaaaaaaaaccccccccccccccccccccaaaaaaaaaaaaacccccccccccccccccaacccccccccccccccccccaaaaaccccccaacaaaaaccaaaacaaaaaaaacjjjqqqqttttxxyywyyyywvrrnnnfffcccccc
|
||||
abccccccccccaaaaaaaaaacccccccccccccccccccaaaaaaaaacaaacccccccccccccaaacaacccccccccccccccccccaaaaaccccccaaaaaaaaccaaaaccccaaacccjjjjqqqqtttxwywwwyywwwrrnnnfffcccccc
|
||||
abcccccccccccccaaaaaaacccccccccccccccccccaaaaaaaaaaaaaaaacccccccccccaaaaaccccccccccccccccccaaaaacccaaccccaaaaccccaacaacccaaaccccjjjiqqqtttwwywwwwwwwwrrroofffcccccc
|
||||
abcccccccccccccaaaccccccccccccccccccccccaaaaaaaaaaaaaaaaaccccccccccccaaaaaacccccccccccccccccccaaacaaaccccaaaaaccccccccccccccccccciiiiqqqttwwwwwswwwwrrrroofffcccccc
|
||||
abcccccccccccccaaccccccccccccaaaacccccccaaaaaaaaccaaaaacccccccccccccaaaaaaacccccccccccccccccccaaaaaaacccaaacaacccccaaaaacccccccccciiiqqqttwwwwsssssrrrrroofffaccccc
|
||||
abcccccccccccccccccccccccccccaaaaccccccccacaaacccaaaaaaccccccaaccccaaaaaaccccccccaacaaccccccccaaaaaaccccaaaacacccccaaaaacccccccccciiiqqqtsswsssssssrrrrooofffaccccc
|
||||
abcccccccccccccccccccccccccccaaaaccccccccccaaaccaaaaaaaccccccaaaaccaacaaaccccccccaaaaacccccccccaaaaaaaaccaaacacccccaaaaaacccccccccciiqqqssssssspposrrroooofffaccccc
|
||||
abccccaaacccccccccccccccccccccaaacccccccccccccccaaacaaaccccaaaaaacccccaaaccccccccaaaaaacccccccaaaaaaaaaaaaaaaaaccccaaaaaaccccccaccciiiqqpsssssppppooooooogffaaccccc
|
||||
abccccaaaaaacccaaaccccccccccccccccccccccccccccccccccccaccccaaaaacccccccccccccccccaaaaaaccccccaaaaaaaaaaaaaaaaaaccccaaaaaacccaaaaccciiiqqppppppppppoooooogggfaaacccc
|
||||
abcccaaaaaaacccaaaccccccccccccccccccccccccccccccccccccccccccaaaaaccccccccccccccccaaaaaaccccccaaacaaaccccaaaaaacccccccaacccccaaaaaacciiipppppppphgggggggggggaaaacccc
|
||||
abccaaaaaaaacccaaacaaacccccccccccccccccccccaacccccccccccccccaacaacccccaacccccccccccaaacccccccccccaaacccccaaaaacccccccccccccccaaaaacciiihppppphhhhgggggggggaaccccccc
|
||||
abccaaaaaaacaaaaaaaaaacccccccccccccccccccccaaaccccccacccccccccccccccccaaccccccccccccccccccccccccaaaaccccaaaaaaccccccccccccccaaaaacccciihhhhhhhhhhgggggggccaaccccccc
|
||||
abccccaaaaaaaaaaaaaaacccccccccccccccccccaaaaaaaaccccaaacaaaccccccccccaaaaccaaccccccccaacaacccccaaaaaaacccaacccccccccccccccccaacaaccccchhhhhhhhhaaaacccccccccccccccc
|
||||
abccccaaaaaacaaaaaaaccccccccccccccccccccaaaaaaaaccccaaaaaaaccccccccccaaaaaaaacaccccccaaaaaccccccaaaaacccccccccccccccccccccccccccccccccchhhhhhacaaaaaccccccccccccccc
|
||||
abccccaaccccccaaaaaacccccccccccccaaccccccaaaaaacccccaaaaaaccccccaaaaaaaaaaaaaaaccccccaaaaaacccaaaaaaacccccccccccccccccccccccccccccccccccccaaaaccaaacccccccccccaaaca
|
||||
abccccccccccccaaaaaaaccccccccccccaaccccccaaaaaacccaaaaaaaaccccccaaaaaaaaaaaaaacccccccaaaaaacccaaaaaaaaccccccaaacccccccccccccccccccccccccccaaaaccccccccccccccccaaaaa
|
||||
abccaaacccccccaaacaaacccccccccaaaaaaaacccaaaaaacccaaaaaaaaacccccaaaaaaaaaaaaaacccccccaaaaaccccaaaaaaaaccccccaaaaccccccccccccccccccccccccccaaaccccccccccccccccccaaaa
|
||||
abcaaaacccccccaaccccccccccccccaaaaaaaacccaaccaacccaaaaaaaaaaccccccccaaaaaaacaacccccccccaaaccccccaaacaaccccccaaaacccccccccccccccccccccccccccccccccccccccccccccaaaaaa
|
||||
86
2022/go/day13/day13.go
Normal file
86
2022/go/day13/day13.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
_ "fmt"
|
||||
"encoding/json"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func Part1(input []string) int {
|
||||
sum := 0
|
||||
for i := 0; i < len(input); i += 3 {
|
||||
left, right := input[i], input[i+1]
|
||||
|
||||
if isOrderRight(left, right) {
|
||||
sum += i/3 + 1
|
||||
}
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
func Part2(input []string) int {
|
||||
var trimmed []string
|
||||
for _, str := range input {
|
||||
if str != "" {
|
||||
trimmed = append(trimmed, str)
|
||||
}
|
||||
}
|
||||
trimmed = append(trimmed, "[[2]]", "[[6]]")
|
||||
sort.Slice(trimmed, func(i, j int) bool {
|
||||
return isOrderRight(trimmed[i], trimmed[j])
|
||||
})
|
||||
|
||||
start := 0
|
||||
end := 0
|
||||
for i, value := range trimmed {
|
||||
if value == "[[2]]" {
|
||||
start = i + 1
|
||||
}
|
||||
if value == "[[6]]" {
|
||||
end = i + 1
|
||||
return start * end
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func isOrderRight(left, right string) bool {
|
||||
var l, r = unmarshal(left, right)
|
||||
|
||||
if cmp(l, r) <= 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func unmarshal(left, right string) (any, any) {
|
||||
var l, r any
|
||||
|
||||
json.Unmarshal([]byte(left), &l)
|
||||
json.Unmarshal([]byte(right), &r)
|
||||
|
||||
return l, r
|
||||
}
|
||||
|
||||
func cmp(left, right any) int {
|
||||
l, lok := left.([]any)
|
||||
r, rok := right.([]any)
|
||||
|
||||
switch {
|
||||
case !lok && !rok:
|
||||
return int(left.(float64) - right.(float64))
|
||||
case !lok:
|
||||
l = []any{left}
|
||||
case !rok:
|
||||
r = []any{right}
|
||||
}
|
||||
|
||||
for i := 0; i < len(l) && i < len(r); i++ {
|
||||
if res := cmp(l[i], r[i]); res != 0 {
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
return len(l) - len(r)
|
||||
}
|
||||
67
2022/go/day13/day13_test.go
Normal file
67
2022/go/day13/day13_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"strings"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
input := `[1,1,3,1,1]
|
||||
[1,1,5,1,1]
|
||||
|
||||
[[1],[2,3,4]]
|
||||
[[1],4]
|
||||
|
||||
[9]
|
||||
[[8,7,6]]
|
||||
|
||||
[[4,4],4,4]
|
||||
[[4,4],4,4,4]
|
||||
|
||||
[7,7,7,7]
|
||||
[7,7,7]
|
||||
|
||||
[]
|
||||
[3]
|
||||
|
||||
[[[]]]
|
||||
[[]]
|
||||
|
||||
[1,[2,[3,[4,[5,6,7]]]],8,9]
|
||||
[1,[2,[3,[4,[5,6,0]]]],8,9]`
|
||||
stringSlice := strings.Split(input, "\n")
|
||||
r := Part1(stringSlice)
|
||||
|
||||
require.Equal(t, 13, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
input := `[1,1,3,1,1]
|
||||
[1,1,5,1,1]
|
||||
|
||||
[[1],[2,3,4]]
|
||||
[[1],4]
|
||||
|
||||
[9]
|
||||
[[8,7,6]]
|
||||
|
||||
[[4,4],4,4]
|
||||
[[4,4],4,4,4]
|
||||
|
||||
[7,7,7,7]
|
||||
[7,7,7]
|
||||
|
||||
[]
|
||||
[3]
|
||||
|
||||
[[[]]]
|
||||
[[]]
|
||||
|
||||
[1,[2,[3,[4,[5,6,7]]]],8,9]
|
||||
[1,[2,[3,[4,[5,6,0]]]],8,9]`
|
||||
stringSlice := strings.Split(input, "\n")
|
||||
r := Part2(stringSlice)
|
||||
|
||||
require.Equal(t, 140, r)
|
||||
}
|
||||
449
2022/go/day13/input.txt
Normal file
449
2022/go/day13/input.txt
Normal file
@@ -0,0 +1,449 @@
|
||||
[[[[8,6]],[8,[7],[6,7,6,2,4]],10,[[1,7,9],7,[7,9]]],[[4,[],[10,5],[5,4,7],5],8,9,[[5,3,3,6,9],[9,5,10],8],[[0,6,9],[8],4,6,8]]]
|
||||
[[[],3,[[10,6,9,6],[6,8,7],[1,2]],8]]
|
||||
|
||||
[[4,[4],[[10,7,2],[1,6,5,7,4],[7,3,3,1,5],[]],1],[[],[[7,6,3]],5,5]]
|
||||
[[[10]]]
|
||||
|
||||
[[[[7,9]],[[0,9]],0,[[2,1,1,2,9],4],[[5]]],[]]
|
||||
[[8]]
|
||||
|
||||
[[9,[[5,4,5,1,10]]],[[[6,9],3,[0,2]],5,6,[3,4,[2,2],10],[10,5,9]],[[[10,3,8],[],[6,9]],4]]
|
||||
[[[4,[7],[1,1,4,3,8],[3],[]],[[5,10,2,1],9,[2],6,7],4,[],[[10],[6,3,1,7]]],[4,[6],[[6],[6,6]]],[[[0,2,5],[3,5,10,7],[10,7,2,9],[],[0]],[[9,9,8],[]],[10,[2,10,7,7,3],4],[2,7]]]
|
||||
|
||||
[[[],2,2,9,[[9],[1,10,5,1]]],[[[],9,5,[8]],10,9,[[1,4,0],[5]]]]
|
||||
[[5],[3],[],[9,[[7,2,0,9,3],[6,8,6],[]]],[[[6],3],6,[[2,8],8]]]
|
||||
|
||||
[[]]
|
||||
[[[5,4],5]]
|
||||
|
||||
[[7,7,5]]
|
||||
[[[[4,7,3],[6,0],1,6],[6,1,4,5]],[]]
|
||||
|
||||
[[[[4,7,0,9,8],10,7,2]],[6,6,9],[[2,10],8,9,1,[1,[0,4]]],[[[2,0,2],[]]]]
|
||||
[[[[]],[],3],[],[[[],[8]],[[4,7,3,7,10],3,5]],[[9,[10,5,8,9,1]],0],[[[6,7,5,4,10],4,6,0,[8,3,1,2,7]],5,[10,1,5],10,0]]
|
||||
|
||||
[[],[[3,8,2]]]
|
||||
[[8,4],[5],[3]]
|
||||
|
||||
[[0,1,5,[[],[6,6,8,0],[0,2,5,9,9],[3,2,7],[5,2]],10],[],[[8,8],[1,3],3,2],[[[4,0],[]],[[4,1,2],[2],6,9,6],1,10,[[7],[0,7],5]],[4]]
|
||||
[[[],[6,[5,9,6,0,8],2,9,[4,2]],7,[9,6,0,10]]]
|
||||
|
||||
[[],[],[],[9,[[1],[6,3,4,9]],10,8]]
|
||||
[[1,[[2],10,[0,9,3]]]]
|
||||
|
||||
[[0,1,4,4],[[7,[6],[2,5,1,3],5],[[8,3,7],[6],[],8],8,1,[9,0,[]]],[[0,[3,9,3,5],[2,0,9,0,7],6]],[[[3,3,1,10,9]],[[0,7,1],8,[10,0],8],[[9,3,5,4],5,[0],5],8,[[3,6,10],0,2,6]]]
|
||||
[[[8,[1,2,10,9],2,[8,4,4]],[3,[5,5]],4],[[],2,[],6,3],[[10,7],[],7,[8,6,[5],4,3],2]]
|
||||
|
||||
[[[[],1,2],[[7,7,7],6,[1,7,1]]],[4,8],[]]
|
||||
[[3,1,[1,6,[9,9,5],5],[[1,7,0,6],[10,8,10],[3,8],[6,2,7,5]]]]
|
||||
|
||||
[[1]]
|
||||
[[[3],[[9,4,10,10],[8,9,1],[],[0,3,10,5]],[8,[]]],[[[10,6,0],2,1],5,0,[7],[[9]]],[[[],[9,9,3,2,3],5]]]
|
||||
|
||||
[[],[7,2],[5,[9,[]],1,[4,6,5],[[9,10,8,3],6]]]
|
||||
[[[[]],0,[1,8],[5,2,7,2],6],[],[[],[[2,1,3,9],6,9,5,3],2],[[[10],[0],[4,0,3,6,8]],4],[9]]
|
||||
|
||||
[[],[],[],[]]
|
||||
[[],[[3,6],6,[6],[[3,10,4],6],[]]]
|
||||
|
||||
[[8,7,10],[3],[9,[],[[5,1,6,10,4]],4,[[9,8,1,1],[0,0,2],1]]]
|
||||
[[[1,6,[4,5,3,1]]],[[],[[7,0,5,1,9],6,[0,9,4,3]]]]
|
||||
|
||||
[[2,2,1,8],[],[[[10,4,10,6],[2,8,3,10,6],[]],1,6],[6,0]]
|
||||
[[2,3,[8,[2,7]],8],[4,[[6,6,4,2],4,5,[7,5]],8,1,[]],[7]]
|
||||
|
||||
[[[],[1,[9,1,9],[8,8,8,5]],3,[4,9,4,[2,6,6]],[]],[[7,[1,9,6]],6,[[10,0,0],[4,7,1],4,9,7]]]
|
||||
[[[[],8,5,1],3,[[8,2,2],4,[2,1,2,3,7]],10,[2,[5,7,6],3,[9,6,5,0,9],4]],[],[9,3,2,7],[4,[[4,10],[8,3,8]],6,[],9]]
|
||||
|
||||
[[[],[[],[5]],4],[[0,[],9,[8,5,3,2,2]],[8]],[[[2,5]],[10,8,[7,8,7,3]],5,[[2,10],3,8,0,[6,9,10]],5],[[0,[7],[]],[[3,9,4,1,6],8],[[4,4,7,2],8],[[3],[],3],7]]
|
||||
[[[2,0,[7,5]],[1,5,7,6,[]],9,[2,1,[6,0],3,[3]]]]
|
||||
|
||||
[[1,3,10,[]],[],[7,[8,4],[[],0,[4,8],6],4,[[4,0],[5,0,8,3],[0,1],8,[2,9,7,6,5]]],[3,5],[9,[[8,3,6,0],[10,0,5],10],[[10,1,4,0],4,8,5],9,[7,[0],[7,9],7,2]]]
|
||||
[[2,9,0,[[5,8,10,10,5],8,4,[5,6,10]],10],[8,[0,[10],[6],4,[]],[[9,4,0],[],[2,10,3,3,4],[3]],1,10],[[[],0,7,3,3],9,[[5,3,0],5,[4,6,6,7]],[]],[6,[[3,1],10,[0,8],0],8,[4,[],[8,0,7,9]],7],[9,4,[10],[[2,10,7,6]],1]]
|
||||
|
||||
[[[],8,9,2,[6,[0,2,10,2],[4,9,7,2,10]]],[9,[[3,4]],5,9]]
|
||||
[[9],[[],[1,6,[5,9,9,9,0]],6]]
|
||||
|
||||
[[5,2,10],[2,[[],7,9,3],0,[7,[]]],[[9,[5,6,5,0],4,0,3],10,1,[]],[8,10,3,9]]
|
||||
[[[2,[3]],9]]
|
||||
|
||||
[[],[6,[3,[],[]],8,[[7,7,8,2],4],0]]
|
||||
[[[[0,5,7]],[[]],7,[4,[9,0,5],7,3]],[5,[[0,8,10,0],3],[1,4],[10],[]]]
|
||||
|
||||
[[1,5],[10,[[9,7,1]],0,[9,[6,3],[7],9,[]]]]
|
||||
[[5,[2,[4,0,4,7,8],[4]]],[8,[2,9],5],[],[4,2]]
|
||||
|
||||
[[7,[[0,0,5,4]],4],[[[2,4]],[1,[3,2,8],[9,1,8,2,2],0,1],2],[[[4,7],3,3,9]]]
|
||||
[[],[[[8],0,10,[0,4]],2,[9,2]],[10,4],[2,[7],10]]
|
||||
|
||||
[[[],10],[[6,7,[8,6,6],2],5,[9,[5,7,9,0],[10,6],7]],[[],[5],10,[[6],6,7,6,[6]]],[[]]]
|
||||
[[[[],[]],[]],[[[6],[9],[4,0,8,5]],[3],[[8,2,7,7]],[],[3,[5,1],[9],[7,1]]],[[7,[0],[],3],[2]],[[]]]
|
||||
|
||||
[7,10,4,6]
|
||||
[7,10,4,6,9]
|
||||
|
||||
[[9]]
|
||||
[[7,2,6],[[6,9,[]],[5,3,6],[2],[[0,7,1],[0],[2],[9,9,0,8,2],[9,5,7,6,8]]],[[8,6,10,0,8],[9,[3,10],4,[2,4,3,4,4],5]],[],[]]
|
||||
|
||||
[[[3,8,[]],1,7],[[4],[10]],[[[2],8,8],[[1,0,6,5],4],6,[4]],[[[],[9,8,7,10,6],2,[1]],[[],9,3,[1,6,5],[]],6,4,9]]
|
||||
[[8,[2,[3,7,1,0]]],[8,4,[[9,4],[0,3,5,5]]],[8,[[2,10,4],7,5,[9,0,5,0,4]],3,9,[8,8,3,3,0]],[[9,4,[0],4,[6]],[[0,10,0],6,[9,4,10,0]]]]
|
||||
|
||||
[]
|
||||
[[[[0,4,6,7],3],2],[5,[10,[8],[4,9,4],[],5],6,[[0,6],[4,7,7],[],10,[]]]]
|
||||
|
||||
[[[3],8,10,[[8],2]],[9,8,10],[[[],[],3,[]],[],[1,9]]]
|
||||
[[2,0,0,9],[[],[[10,2],[]],[7,[1],4,[2,5,8,1,2],6]],[[8],[[9,3,3,8],2,[5,5,2,9],2],[5,[],6,[2,1,4,10,1],7]],[],[]]
|
||||
|
||||
[[[[1],[7,1,9]],[[],0,[0,7]],[6],9,[]],[]]
|
||||
[[[[2,8,7,3],[4,2],10,[8,4],7]],[],[[7,[3,2]]],[[[8,7],8,10],0,2]]
|
||||
|
||||
[[[1,[6,7,0,8]],6],[2],[6,7],[],[[[1,9,2,10],[9],[0,4,3,1],[6,10,2,4],[4,0,10,6]],[6,5],6,[5,10,[1,0,10,1,2],[5,10,5],9],[[3]]]]
|
||||
[[[[3,9,0,6,3],[]],1,7,4,[[9,8,5],1,6,[]]]]
|
||||
|
||||
[[],[[[]],9,[[2,6,2,9,5],9,[6,6]],[[1,0,7],[4,4]]]]
|
||||
[[1,[[5]],1,0],[2,[[9,9,1,8],2,8,[0,5]],[]],[0,[5,8,4],[[6,2],[3,6,0,8],[4,2,5],[5,10,4,6,6],[5,5,6]],[7,2,10,[]]],[7,[]]]
|
||||
|
||||
[[5,[4],[0,[5,3,2],[]],0],[3,[10,2,7,[]]]]
|
||||
[[],[4,9],[[[2],[0,10,6,1],1,[0],[9,4,8,1,9]],0,[[0],8,9,[1,1,10,10]],7],[[[3,10],10],10,2,[10,3]],[[5]]]
|
||||
|
||||
[[4,[],[[0,3,5]],[[]],1],[9,[0,4,7],[3,[5,10,9,2],6,2,6]],[]]
|
||||
[[[1,4,[10,3,8],[7,7]],[1,[]],[[1,2,5]],9],[],[],[0,6,2,8]]
|
||||
|
||||
[[[[5,9,4,1]]],[0,1,[],7],[[[]],[9,[2,5,10],5,1],[[]],[[9],[6,4,0,4,9],1],[8]],[[10,1,7],6,10,7,6]]
|
||||
[[[8,9,[0,9,2,5]],10]]
|
||||
|
||||
[[9,[[4,8,2,0],[0,1,7,7],5,[4,3,0]],6,[1,[3,9],[3,10,10,3,1],6]]]
|
||||
[[],[5,[[4,0,9,5],1,[2,0,5,6],8,3],1,[[9,3,10,10],[],[10],7]]]
|
||||
|
||||
[[[[4,7,4,1],8],1],[[8,0,0,5,[0]],2,[]],[[[5,8,6,10,0],[],7,[],1],[7,[7,8,0,2,5],9,[8,5]],[8,[7,4]]],[10,[9,3,[0,5],[2]]],[[6,3,6],6,[[7,1,10],5,4,[3,5,1,7,10],9],[1,5,[2],[5],[3,7,0]]]]
|
||||
[[],[[],10],[0,[],5],[2,[8,2,0],[3]]]
|
||||
|
||||
[[2,3,[3,6,8],5,2]]
|
||||
[[],[0,0,[],8,2],[[[],[0]],[[],4,6,0,[8]],5,7,10],[[],[[1,6,3],[6],[6,7,0],4],[],[[1,10,4],2,0]],[[9,[1,0,7,1,7],3],3,9]]
|
||||
|
||||
[6,1,3,9,6]
|
||||
[6,1,3,9]
|
||||
|
||||
[[3,10],[8,[[8,4]],0],[],[0]]
|
||||
[[[[6,6,9,5]],[[4,0,0],[9,8,10,9]],6],[[1,[1,8,7,9],[]],4]]
|
||||
|
||||
[[[],4],[[[]],6,1],[[4,1,[8,8,9,3],6,9],1,8,[],3],[[[3,4,6,0]],9,0,0,[]],[[[5],[4,7,9,6]],2]]
|
||||
[[9],[[[3,2,2,3],0],5,[[6,6,0,9,6],[10,3,3],3],[]]]
|
||||
|
||||
[[],[],[],[7]]
|
||||
[[[4,[5,0,7],[5,5,4,4,2],9,[8,0,0]]]]
|
||||
|
||||
[[7,[[0,3]],4],[9]]
|
||||
[[],[4,[[7,10,4,7,6],[3,8,2,1,6],8,8],2,5],[7]]
|
||||
|
||||
[[[4,0],0,7,[0]]]
|
||||
[[1,[8,[4,2],6,2],0,[],8],[[]]]
|
||||
|
||||
[[],[0],[[[7,2,10]],3,[[8],2,[5,2,1,5],1],[8,[9,9],1]],[],[2,[[10,3,8],0,[8,6,0,5,1]],[2,7],[[3,6,7]],[2,[0,7,2,4]]]]
|
||||
[[],[[],6,7],[3,5,[0]]]
|
||||
|
||||
[[10,7,[[9,2,5,10],[],3,[2,3]]],[[[1,0,10],0],[[6,6,2,9,6],[2,3],4,[2,4,5,2]],7,[5,7,8,[10,4,10,4],9],4],[]]
|
||||
[[[9,9,3,2]]]
|
||||
|
||||
[[5,0,9,8,1]]
|
||||
[[3,5,[[],5,0],7],[7,9,9,[[6,0,4,4],2,[10,3],5,6]],[]]
|
||||
|
||||
[[0],[[],[],[1,[7]],[]]]
|
||||
[[],[[4],[8,[0,1,5,2],[0,9,3]],9],[1,[1,[],4,9],6,[],8],[[2],[[7,3,4,9],10,6,[5,7,10],8],5,1,5]]
|
||||
|
||||
[[],[9,[[],3,4],[],3,[1,[8,5,1,9,7],[1,9,3,2],[2],4]],[[1,4,1,[0]],[[6,6,3,6],[2,2,6,9,5],0]],[[3],[]]]
|
||||
[[],[[[2,8,10,3]],10,[[5,3],4,8,[8]]],[1,1,[[]]],[],[]]
|
||||
|
||||
[[],[7,[6,[1,4],9],10,8,[[],6,1,3,8]]]
|
||||
[[9,0,[[7,0]]],[],[2,9,3],[[[5,8,8,8],9],[6],0,[[1],9,8,[]],2],[[],[5,0,[],8],[[9,4,0,2],9,1,9],3]]
|
||||
|
||||
[[[5],[[3,1,7,10,3],8,[],7,[1,7]],5,0]]
|
||||
[[[2,[3,4,9,8,10],[5,6],[9,10,8],[6]],[1,[10,7,3,7],[8],4],3,9,9],[[2,[5,1,10,8],[1,9,8,9,9],10],6,2,[]]]
|
||||
|
||||
[[9,[],[[1,0,4],[7,5],[0]],[2,2,[5,3,10,9],[8,4,6,0,0]],[1,[4,2]]]]
|
||||
[[[[5,6,4,3,6],4,[3,5,10,7]],1,[8,[7,5,9,10,7],2,5,7],0],[[6,[0],[],[3,3,2]],[[5,2,4,2,3],10,2,4,8]]]
|
||||
|
||||
[[[],8],[6],[[[7]],6,[[9,7,5],[5,0,3,3],[2,2,0,8,3],[5,7,8,1,3],[1,6,4]]],[8,[6,4,[],0]]]
|
||||
[[[[3,3,3],7,10,2,[0,1]],[[2,4,3,2,2],[7,2,4,4],10,[8,1,1]],4],[4,3,[[],5,[1],[0,7]]],[8,6,10,[]],[[5,[7,0,6]],3,10,10],[7,0,[10,4,3,7],3,2]]
|
||||
|
||||
[[[7,[0,2],[],3,[5,0,6,9,0]],0],[[[8],[6,8,4,2],[8,6,4,8],4,3]],[[3,2,4],[6,2],10,[[6],3,[2,6,0]],[[7],4,6,[]]],[]]
|
||||
[[7,1,2,1,[[2,0,8,10,10],[5,6,1],[6],[5]]],[[6,[10,5,10,1,1],6],1],[[[8,1,2,5,8],0],[10,9,[2,4,4,8]],6,[2,[1],0],6]]
|
||||
|
||||
[[9,3,8,[1,[1,2,6,8,0],9,0]],[[6,[9],[6,2,1,5],[3,6,0,0]],[[6,0,1]]],[[[3,9,8,8,5],[1,8,3,10,5]]],[1,[[3,4],4,[9,7]]]]
|
||||
[[0],[[[],7,[8],[7,8,9],3],[[],3,[9,7,7]],[8,[3],0],[1,4],[[8],[]]],[[[6,10,0,1],[4,6,1,5],[6,3,1,4,0]],2,4],[]]
|
||||
|
||||
[[[[2,0],[10,1,7,7,7],[8,4],[],[7,4,5]],4,[],1,4],[7],[4,7,9,[3],[[3,4],3,4,[5,6,4,7,10]]],[3,7,8,[2,7,[8,0],4]]]
|
||||
[[8,7,9],[[[3,7,9,8,8],[5,6,5],1],9,[[0,5],[]],[5]],[[[8,2,7,9,0],1],1,[],[],[[4,2,0,10],[],0,[2]]],[]]
|
||||
|
||||
[[[],3,5,[[],[6,10],[7],5]],[[[9,7,0]],[0,4,3],9,[[],0,[5,5,1],10],[8,[]]],[[[3,3,10,3]],0],[[1,[3,3],[],0],[[],8,7,[5,3,6,2],[7,6,9,3,5]],6,2]]
|
||||
[[[[1,4,6,8]],0,[3,0,[],8]],[1,8],[7,[]],[7,[6,7,4],10,[3,0,[7,3],7,7],1],[5,[8,[2,4],3],[3],1]]
|
||||
|
||||
[[[1,0,2],[5]]]
|
||||
[[[9],[[1,3,9],[4,3,9,2,4],[7,0,1,10,1]],[0]],[3,[[2,7],4,[6,1,5,5,6],10],9,7,[[8,7,8,9],9,[],[0,2,3,4,10],0]],[4,[[6,6,1,9,0],2,0,[2,10,6]],6,0,3],[3,5,9,[]]]
|
||||
|
||||
[[0,0,0,[10]],[[[1,7,4,0,5]],7,2]]
|
||||
[[[[9,10,9,10,7],1],[],1,[[]],4],[8],[3,[7,5,9,[0,0,5,10]],6,10,2],[5,3,4,[[7],7],3]]
|
||||
|
||||
[[[[6,2],5,10],0,8,[[10,1,4,4]]],[[[1],5,7]],[[[2,7,9,5,7],4,10],[[8,8,2],[],6,0,[3,8]],[[],[],[],[6,7,8],9]],[[6,4,[6,10],1,[3,2,8]],[],1,[[0,3,9,5,2],[3,2],9,8],1],[]]
|
||||
[[2,[7,[3,5,6,0],4,1],6,[[7,2,3,10],3]],[],[6]]
|
||||
|
||||
[[8,[],[],[10,8,[0,7,8,8,3]],[[7,3,7],[8,8,10,10]]],[8,10,[4],7]]
|
||||
[[[]]]
|
||||
|
||||
[[9,[[3,10]],5,10],[9,1],[5,4]]
|
||||
[[[]],[6,6,5],[[1]],[6],[]]
|
||||
|
||||
[[6,[5,2],9],[6,9],[4,[[4,4],1,[0,2,4],8,1],0,8]]
|
||||
[[[8]],[[[5,6],2,3,6],[2,9,[7,0,0,7,3]]],[[[],3]]]
|
||||
|
||||
[[[],10,[5,[3,3,3,6,0],[7,8,2]]],[],[]]
|
||||
[[5,[8]]]
|
||||
|
||||
[[[4,[],[],[1,6,4,7,9]]],[[9,[1,4,7,10],9,[9,3,1,7]],2],[],[]]
|
||||
[[[[2,6]],0,10,[1,10,0],[5,[5]]],[4],[4]]
|
||||
|
||||
[[10,[],10,2],[],[5]]
|
||||
[[[]],[6,5,8,10,[[0],[5,9],[8]]],[],[10,[[8,2],7]],[[[],9],6,[[8,8],[1,3,7,3],6,8,[9,3,0,9,8]],[],9]]
|
||||
|
||||
[[[[],[7,10],0,5],[0,[]],9],[2,7]]
|
||||
[[3,[]],[[6,10],[1,[7],[2,0],7,[]],[[6,8],1]]]
|
||||
|
||||
[[[],3]]
|
||||
[[[3,9,6],9,[6,3,[0,8]],[6,8,5,[10,5,9,10]]]]
|
||||
|
||||
[[[7,2,10,[]],7,[[],[],[],10]],[0,0,9]]
|
||||
[[],[[[1,1,8,1],[1],6,8],[[8,3,0],9,[3]],[4,[7],5,[1,2,9,8],[6]]],[8,[[],[7,2,4,6,5],[1,4,6,7]]],[[1,3,2,9],[[0,3,4,0,0],3],3,9],[5,[[5,7],[5,7,3,8,3],[6,0,2,3]],5]]
|
||||
|
||||
[[],[[1]],[5],[2,[],[2,[9,7,1,4],[9,4,4,2,4]],3]]
|
||||
[[3],[],[6,[[10,10,10],2],[3,2],5],[]]
|
||||
|
||||
[[],[[9,[10,3],[1,4]]]]
|
||||
[[5],[[],[[5,6],[],9],[]]]
|
||||
|
||||
[[5,5,10]]
|
||||
[[[[10,9],[2,10,0,8],[4]]]]
|
||||
|
||||
[[],[[10,[]],[[8,7,3,9],2,10,7],1,7,[1,0]]]
|
||||
[[[[6,4,3],0,5,3,9],[],9,[3,[4,4,0,1,9],10],[10,[0,2],[7,7,1,5,9]]],[2,3,3],[[],[2,1,[]],9,9],[[3],[5,9],[2,[10,7,3,4],[2],10]],[]]
|
||||
|
||||
[[5],[[],5,8,7],[[[0,0,10,6,5],3,[10,4,8],[]],[[3,5],[2,0,2,7],9],9,[7,9],[1]],[],[[0,5]]]
|
||||
[[8,[8],3,[[4],8],[5]],[8,4,5,[7,1,[4,7,1,2],4,9]]]
|
||||
|
||||
[[2,9,4,[[10,8,10,2,6],[],7,[7,0,6,8,2]]]]
|
||||
[[5,[],10],[2,[3,6],[],[],[]],[[6]],[9,7,[0]],[]]
|
||||
|
||||
[[1,1],[0]]
|
||||
[[7,[9,10,5],[[5,6,5,6,7]],0,[[1,8,4,10,1]]],[],[[8],[[],9,6],10,9],[[[],10,0,3,10],[[3,3,8,5]]],[[1,6,10,5,[2,0,3,5,0]],[8,[],10,10]]]
|
||||
|
||||
[[[8,2,[],[],8],[[9,3],10]],[]]
|
||||
[[[4,10,9,2],5,2],[[10]],[[1,7],[10,5,2],2,5,4]]
|
||||
|
||||
[[[9],4,4,9,[1]],[[7],5]]
|
||||
[[],[8,6,[],[[0,4],[],[7,4,6],7,7],[]],[[4],[[7,3,6,8],5,1],[8,7,5],[2,7,[3,4,6,2],[],[]],8],[2],[[1,9,[9,8,9,2,7]],3,[],3,[]]]
|
||||
|
||||
[[2,[10,2],[[6],10,[10,6,8],[5,8,7,5,6]]],[2,8,9],[]]
|
||||
[[5,[[4,10,6,10],5,[1,1,10,8],9,[4,1,4,0,3]],9,9]]
|
||||
|
||||
[[6,5],[[7,0]],[7,4,7]]
|
||||
[[[7,[],[2,6],1,4],8,7,9],[[[]]],[[5,4,[2,9,1]],10,2]]
|
||||
|
||||
[[[[0,2,4,8]],[[6,10,8,6,1],10,[4],7,7],10,[[6,5],[],3,[8,6],[]],[[]]],[[9,10,7]],[],[7,6,[[]]],[[4,8,[6,5,3,5],9],6,[[7,8],[1,0,8,10,7],[7,3]],[7,2,0,8,[5,7]]]]
|
||||
[[[[7,3,6],3,[6,1,10,9],7,[5,0,7]],10]]
|
||||
|
||||
[[[6,[6],9,[3,1,7,3]],6,[[6,9,6,10,0],[],5,4,3]],[[[10,1,2,4,2]],[2,[],[6],8],[[5,4],[3,4,9],[4],5],0]]
|
||||
[[[[1,4],[2,5,8]]],[9,[4,0,1],[10,8,[3,9],6,7],[[3],1,[0,1],[3,0]],[[9],1,1,9]],[[9,[3],8],3,3],[]]
|
||||
|
||||
[[2,6,[2]],[4,2,9],[],[7,4,[2]]]
|
||||
[[[[2,8,1,3],[],9,2],8,[],[8,[]]],[[],[[2,9,2,0],9,[],1],5],[8,[[7,7,3,8,3]],8,3],[[[]],[6,2,[6,8,6,1],8],[[0,6],[3,9,2],[8,7,4],9],[2],[6]],[2,8,9,[[5,2,4]],10]]
|
||||
|
||||
[[[]],[],[[[],10],[2,9,5],0,[[9,4,3,10,10],[2,0,8,9],[1,6,6],1,[]],[[10]]],[7,6,[[],[5],[2,6,7,10,5],8],[],[[],9,2,5,2]],[[3,3,[6,10,10]],6,8]]
|
||||
[[1,0,4,[7],[7,9]],[10,[[1],[],2,8,0],0,7]]
|
||||
|
||||
[[[],10,6,3],[1,[[5,5,8],4]],[5,4]]
|
||||
[[[[8],[2,7],[0,3,3,7]],1,[2,[1,5,5,5],[],[2]],1],[[[4,9,8,9],[8,10,4,2,3]],[],3],[[[10,0,6,10,7],6,[8,4,5,3,9],[1,7]],10],[[[9,3],9,[]],8,3,10,[10,10,[5,1,2,7,4]]]]
|
||||
|
||||
[[[[]],[[9],[4,1,4,4,0],7,1,3],8,[8,[10,8,6,1,3],[],[7,2],0],[]],[0,5,6],[5,[10,[0,3],4],[6,[5,9,7],[3,8],[4,1],9],3,[]],[5,[],10,[]],[0,9,[],3]]
|
||||
[[10,3,8],[],[],[0,[6,0],[6],[[],0,[10,0,6,3]]]]
|
||||
|
||||
[[[[7,6,6],[7,1,0,9],6,5,[]],[0],[]],[6,0,5,0],[10,[[4,6]],[[3]]],[[],[[0,5,6,10],2,[3]],5]]
|
||||
[[3,1,[[9],8],[9,10,2]]]
|
||||
|
||||
[[[],[4,3],[[],[9,3,6,9,7],10,[0,2]]],[[8,7,10],8]]
|
||||
[[[3,9,[],[10],0],[2,10,2,0]],[10],[],[0,[3,[2,2]],10,3],[[[3,4,4,7,1],1,9],2,[3,[7,7],[4,4,0]],0,[]]]
|
||||
|
||||
[[6,8,[[0,4,0],2],[[3,2,9,2],0,[8,7,0,5,9],[3,8,2,6]]],[7,3,2],[6,[[]],[8,1,[8,4,2,0,7]],[],[[3,4,1,8,0],[7,5],6,[4,9],7]],[5,[4,[],1],[[8],1],6],[]]
|
||||
[[[7,[]]],[1,10]]
|
||||
|
||||
[[0,3,9],[1],[3,0],[4],[[9,[4,8,8],[],8,[]]]]
|
||||
[[[[0,10],[2,10,7],1,10]],[8,8,2,[6]],[[1],[2,[9,6,9],3,4],3],[5,2,[],[0,4],1],[[2,10,[0,3,6],7],9,[3,[5,7,4,8,3],4,4,0]]]
|
||||
|
||||
[[[4,[0,10,9],3,[]],2,0,[5,5,9,[],0],10],[[6,4,[6,2,9,9,2],[9,1,9,6],2]],[],[[],6,6,4,[]],[[],8,[[9,9,7],[2,0,3,8,0]]]]
|
||||
[[],[4],[[4,[0,9,5,7,3]],3],[[9,[5,1],[6]],5]]
|
||||
|
||||
[[6,[[5],2],7,[0,9,[6,3,5,0,6],2],[[4,7,3,8],[9,8,6,5],8,8]],[]]
|
||||
[[[[4,2,3,10],[],0]],[[[9,0,7,4],[6],3,8,5],[],3,3],[[3,[3],[],[3,5,2,4,1],[7,3,5]],9,4,1],[],[5,6,[1]]]
|
||||
|
||||
[[1,[],[6,[7,1]],10,[[1,7,2],8,[9,6,3]]],[4,[[],[8,8,5,5,3],1]],[[[]],6,2,[2],[[],3]]]
|
||||
[[6,2,[3,6,0,5],[9,[9,8,9,3,10]]],[4,[6,7,8,[],[2]]],[4,[[1,9],[],[7,9,6,10,7],9,8],6,0],[]]
|
||||
|
||||
[[[[8]],[9,8,[3,2,6,2,7],[3,6,2,5],8],[[3,6],0]]]
|
||||
[[[[5,3],1,7],9,3,[9,0,[3,2]],[10,9,[4,9,6,8,8],[],[7,5]]]]
|
||||
|
||||
[[4,2,5,6,[1,1,5,[8,2]]],[[0,[3],3],0,0,0],[7,[3,[9,9,5,1],[],3],[]],[4,[[9,8],[6]]]]
|
||||
[[],[2,0,[[],[8,5,4,7],9,[3,5]],[9,2,[8,4],[7,5,6,7,3]],7]]
|
||||
|
||||
[[1],[[10,5],[[],[],[],3],7,4],[[10,[6,4,9,1],6,0,[2,0,0,6]],[5,2,9,[8,1]],[[9,0,2,3]],[],6]]
|
||||
[[7,[2,[6],1,1,[1,8,1,6]],[],4],[7,[7]]]
|
||||
|
||||
[[[[5],10,[10],[],[8,6,4,2]],5],[8,[[5],6,[],[8,4,9]],[10,0]],[[3],[],9],[4,[6,6],[]]]
|
||||
[[1],[4],[[7,[],[3,9],1],5,[[9,0,8,4],7,[8,6,3],[10,9,4,2],9],10],[[8,7,[2,8,10,9,9],9],5,[]]]
|
||||
|
||||
[[[[5,1,5],[8,4,6,5],[9,10,0]],7,4],[[[7,2,8,5],0,[]],[],3,4],[[4,3,[2,6,9,9,6],9,[8,7]],5,10],[1,[],9],[9,[[9,9]],[1,6]]]
|
||||
[[[[9,5,9,10],[]]],[9],[]]
|
||||
|
||||
[[[[3,3,6,0],6],10]]
|
||||
[[[3,2,[0],0],[],[[6]]],[5]]
|
||||
|
||||
[[[2],[]],[1],[[[9],10],5]]
|
||||
[[8],[10,7],[],[4,6]]
|
||||
|
||||
[[[[5],10,[1,8,1,5,1]]],[[],[9,8,8]]]
|
||||
[[3,1],[],[3,4,[[7,3],5]]]
|
||||
|
||||
[[3,10],[[4,7,[1,8,6,10,8],5]]]
|
||||
[[[10,[8,6,7,6,10],[1]],[[10,4,5,5],[5,5,9,4,1]],5]]
|
||||
|
||||
[[[10,8,2]],[],[]]
|
||||
[[[[0,9,0],[6],[0],6],8],[[10,[0,1]]]]
|
||||
|
||||
[[[]],[[[9,9,8],[],[8,10]]]]
|
||||
[[5,[[0,6,0,2,1],4,9,[6,2]],9,[[4,4,8,0,0]],[[],[5,3,1]]],[8],[[[6,10]],2,6]]
|
||||
|
||||
[[[[6,1,5,10],6,[8,7,3]],5,[1,[10,5,7],2],[[7],8,6,8]],[[[10,10,5,4]],3]]
|
||||
[[],[10,10,[9,[8,2,0,10],9,[7,7]],8,[6,9,[6,8],[5,5,10,5],4]],[5,8,10,[0]],[[[10]],[5,10,5,[0,5,9,10]],3],[]]
|
||||
|
||||
[[[[4,1,2,9],[8,5,10,5,7],0],[[0,3,6],10],8]]
|
||||
[[[3,[2,2],[5],[8,2,0,0,9],4]],[8,7,[[3,8,9,4],10],7]]
|
||||
|
||||
[[9,9,[10,[0,5,1,5],[5,9],[7,10,9,10]],8],[1,0],[],[5,3,[5,10],2]]
|
||||
[[[0,8,8,8]]]
|
||||
|
||||
[[5,[[10]]],[[],1,[[9],[10,6,6,0],4],[7,8,6]],[[5,[2]],[],[8,[10],1],10],[[10,[5,5,1],6,0],0]]
|
||||
[[10,[9,1,[7,5,3],8],[[10],8]],[[6,[6]],[10,0,6,0,2]],[[[],0],[10,9,8,4,[1,6,8,3]]],[9,9,6],[10,[]]]
|
||||
|
||||
[[[[6],[1]],4,[[5,10],[0,10],6],[[5,7,10,10],[6,5,0,10],[],[3,9,8,1,0]],4],[],[[0],3,1,0],[6,[[9]],[[5,9],4,[9]]]]
|
||||
[[[[9,8,6]]]]
|
||||
|
||||
[[10,6]]
|
||||
[[],[4,[[0,3,8,8,1],[0,10,7,7,7],[],[8]],[[],[1,1,10],4],2,[[6,3,1,5]]],[]]
|
||||
|
||||
[[[],0,5,8]]
|
||||
[[3,[10],10,[],7],[[[5],[8,8,6]],[[7,2,0],6],0,6],[[5],[[3,6,1,8,6],8,5],[[],[9,7,0,9,4],0,9],10,5]]
|
||||
|
||||
[[],[]]
|
||||
[[1,0,[[5,4,5,2],0,6,[7,2,8],4],[[2,10],9,3],4],[4],[[4]],[[6,3,[],4],0,4],[4,[]]]
|
||||
|
||||
[[[[4],[2,4],6,[]],1],[10,[3,0,4,[2,0,4,3]],[[5,6,0,1,2]],[[3],0,[]],[[6,10]]],[4],[],[2,2]]
|
||||
[[[3,[4,1,4,2],[1,3],[6,6]],[[10],9,[2,0,1]]],[3,9,[3,[5,9,5],7,[1,10,9],8],10],[[3,[7,9,1,10,4],[5,8],[9,10,8,7,1],5],9,2,[[3,7,0],10,[],[7,6,2,5,1],[]],[]]]
|
||||
|
||||
[[[[2,9],[]]],[[10,[2,10],[],[7,1,2],9]]]
|
||||
[[5,9,6,[0,[2,9,6],[2,2,1]]],[1,[[8,4],[9,1],[7,1,10,5,4],[9,4]],9,6],[4]]
|
||||
|
||||
[[[0,[10,3,10,0],5,4,1],[],8,1,10],[[],[[7],[8,3,7,8],[3,9,2,0],9,[9,5,7,4,1]]],[],[0,10,[0,[9,5,0,5],[7,9,7,10,9],0,[]]],[]]
|
||||
[[1,1,7,0],[10,7],[[1,0,[8],5],6]]
|
||||
|
||||
[[[8,4,[5,5,2],3]]]
|
||||
[[0,7,[6,[],[10,5]],5],[3],[9,8,[],[[2],[1],9,[3,6]],[[]]],[0]]
|
||||
|
||||
[[[6],[[2,6,10],[8,3,10,1,10]],2],[[[8,2,8,10,3],5]]]
|
||||
[[[[]],8,[[8,4],[],[],[4,4,1,0,10],[1,5,2,4,6]],3,[0,[8,0,2]]]]
|
||||
|
||||
[[8,3,[4,[]],[[3,5,5,7,8],[2],1]],[]]
|
||||
[[[[6,5,1,3],0,6]],[7,9,[],0]]
|
||||
|
||||
[[4,0,[[8,0,10,7],10,1,[10,1,8,10],[]],4,10],[7,1],[8],[7,[[4,0,7,1]],[7],[]],[]]
|
||||
[[8,[[10,8,4,7,10]],[[10,2]],[5],[[1,5,2,6]]],[[[4,4,3,4,4],6],9,[6],[0,[9,6,5,1],[9],[8,5,0],[0]]],[8,5,[8,[2,6,0,3,4],7,4],8,[6,[4,0,10],[]]],[[[8],[0,2,8,0]],[6,[1]],[],1],[]]
|
||||
|
||||
[[2],[[[8]],6],[2,[[7],10,0,[8,7]],9,[9]],[]]
|
||||
[[2,[[4,9],4,[],9]],[[1,[8,7,3],0,2],2],[[],5,2],[0,10]]
|
||||
|
||||
[[4,7,0,[],[0,[0],[3,2,10,1],[0,4,4]]],[7,5,[[0,4,6]],[[2,9,1,4,0],9,[8,10,5,7]]],[6,[5,9,[8,0]],[5],[]]]
|
||||
[[[6,[4,1,6,0,2],10,[2,5,3]],[5],9]]
|
||||
|
||||
[[8,[2],[]],[1,10,3],[10,[[1,8,6,7],9,6,0,5],[3,10,0]],[[[1,9]],5],[10]]
|
||||
[[[[],[6,6,4,6,2],10,[7,5,8]],[[3,8,7,3],2,9],0],[2,1,[9,[7,7,3]],[9,8],[[3,9],[8,10],[7,10,6],0,[]]],[0,2,5],[[[3,6,6,10,3],[],[3,6,5,0],[]],[9,[4,6,8,5,9]],[[8],[1,1,8,1],7,4,[2,10]],8],[10,[6,[],[]]]]
|
||||
|
||||
[[[3],[],8,[[3,9,9]]]]
|
||||
[[[[3,0,3],9,[3],2,10],6],[[],[0,7,8,8,[5]],9,[8]]]
|
||||
|
||||
[[1,3,[[5],[3,7,1],7,[10,8,5,10,6]]],[[10,5,4],7,[0,[4,8,1,4,5],[5,0,5,4,8],5,8]],[6],[7],[[[7,6]],9,[0,[9,10,10],9],2,9]]
|
||||
[[5,10],[6,5,[]],[2,2,1,[],5]]
|
||||
|
||||
[[[9,[3,7,5,0,10],[2,4,8],[8,9,5]],[],2],[10,8],[[[10,6,4,9],[5,5,3,0,10],[8,10,3,7,5],[8,4,3,5]]]]
|
||||
[[[1]],[[],6,[1,[4,3,6,8,8],7,[3,3,4,9],[9,8,1,3]],[[7,8],0,1]],[5,[8],8],[[[0],4,[1],[7,0,7,8,8],7],[6,5,[5,0]],10,[[7],[6],9]],[3,10,[2],[[8,2,4]],0]]
|
||||
|
||||
[[[3,9],5,3,7],[2,2,4],[[[7,1],3,4],[]],[[[8,1,10,9,10],7,[7,10,3,8],1,3]],[[10]]]
|
||||
[[[0]],[]]
|
||||
|
||||
[[[]],[[4,8,[8,0,7,3]],5,3,1],[5,8,[8,[2,7,9,3,2],[5,0,1,4,7],5],8,[[9],3,[9],[8,2,5,3],[5,8,4]]],[9,1,1,[7],[]],[6,[2,[1,3]],[3,4,[8,6],0,2]]]
|
||||
[[[2,7,2],[]],[6,3,[8]],[4]]
|
||||
|
||||
[[],[[2],[[5,8,1,9,6],[],7],4],[],[[6,9,[7],2,1],[8]]]
|
||||
[[[3,7,[],6,3],[6],5,3]]
|
||||
|
||||
[[3,8,[[3,4,1,2,3]],[0,[1],[7,3,8,10,9]],[[2,10,7]]],[[[0,3,8,9],[0,6,8],8,1,2],7,[9,0,7,[9,5,0]],[[]],[[5,3,6]]]]
|
||||
[[10,[]],[2,[4],[]],[[[0],[0,6,5],[7,4,3,2,3]]],[]]
|
||||
|
||||
[[4,[[8],[5,10,9,6,5]],9,5],[2],[2,10,5,[]],[[[0,10,8,1],3,6],8,8,[[5,10,9,6,10],[4,10,9,9],4,10]],[2,[4,[9]],8,1,[7,7,1,[]]]]
|
||||
[[[8,5,0,[10,6,5],[0,6,1,0]],[[1,1,3],[6,6,3,7,5],9,10,[8]],[[3,3],7,[5,0],4,[9,3,9]]],[[4],[[6,6,0],7,5,3]],[],[3,[0,[10,8,10],[3,0],8],[3,3]],[[[10]],[[7,6],[2,7,10,0,5],6,0],[[9,3,10,2],8,[5,8,1]],10]]
|
||||
|
||||
[[[],6,9,[2,[10,4,6,9,1]]],[[[8,6,4,5],1,[5,5,3,7,8],[]]],[[[5,5,10,7]],[[2,4],0,[2,2],10,[]],[[1],[0],[1,1,7,3,8],[4,10,0,0]]]]
|
||||
[[7,5,[[],10,[],6,[4,1,1,1]],[8,4,[4,0,9,0]],[]]]
|
||||
|
||||
[[[[4,0],[]]]]
|
||||
[[[6],7],[[6],3],[6,[[2,6,10,7,8],1,2,10,4],[[1],6,5,6]],[]]
|
||||
|
||||
[[8,[2],[4]],[],[]]
|
||||
[[[[6,8,10,8,5]],9],[]]
|
||||
|
||||
[[[]],[],[[[8,3,5,4,4],[9,5,4],[2],[9,4,3],[3,7,3,9]]],[4,[3,[]],0,[[10,9,0],2,8,[1],[]]]]
|
||||
[[],[7,[]]]
|
||||
|
||||
[[],[1,[2,5,[]],4,10,2],[0,8,5,[[10,9],1],[[],3,[3,6,0,7,2],0,[2]]],[[[7,2,9,2],[],[3],8,[]],10,[8,0,[6]],[10]],[5,[[9,10],2,[9]],3,[9,[4,9,5,9,7]]]]
|
||||
[[[[2],[5,1,3,2,10]],[7,[3,7,4,2,7],[9,2,6,8],1],[[8,4,3],[8,8,5],5,6,6]],[]]
|
||||
|
||||
[[6],[7,[[0]],[3,7,[7,5,8,0,9]]],[],[7,[3]],[0,0]]
|
||||
[[0,0],[[9,0],[[10,7],[2,5,8,8],6],[[9,5,3,3,9],[7,4],8,6,2]]]
|
||||
|
||||
[[[],[3],1],[[[0,4,0,8,0],3,[5,1,9,5]],8,8,6]]
|
||||
[[2,1,5]]
|
||||
|
||||
[[],[[8,[6,1,0,9],6],9,3,1]]
|
||||
[[],[4]]
|
||||
|
||||
[[[[3,5,4,10,4],10,[2,3],9],8,[4,[2,4,3,10,6]],5]]
|
||||
[[0,8,[]],[10],[8,[2,[9,6,9,9],[10,9]],8,[1,0,2],7],[[8,5,[1,2],[7,7,5,1],[1,5,6,6,0]],8,[],[0,[9],1,[3],[8,4]]],[[6],9,8,5,[0,3,[8,10,4,9]]]]
|
||||
|
||||
[[[1,[5,2,4,0],[3,8,7,3],[6,4],[]]],[],[],[7,8]]
|
||||
[[[[7,4],7,[5,8,2,4,9],8,[8,7,10,7]]],[[5,[],8,[0,9,4,5,8]],[[5,1,8],10,[],7,8],0,[],1],[[[0,3,3],[]],2]]
|
||||
|
||||
[[],[[7,[7,10,3,8,8],[],6]],[3,[[2,0,8,2],[],2],[[4,7,2,7,10],5,[0,6]],10,[[],[8,0,8,9,0],[0,1,10,8,1],3,9]],[[[3,3,0,6]],[[10,1,0,5,8],7,3]],[0,[4,[1,1,0,10,10],5,1],[[1,4,8,2],8,[6,9,1],8],1]]
|
||||
[[10,10],[6,6,[5,[],6,[4,4,9,9]],4],[],[7]]
|
||||
|
||||
[[],[[[8,5,2,0]],7,4],[[8,[7]],1],[],[0,0,[1,[0,6,10],[4],[],1],[4],3]]
|
||||
[[[[],[10,1],9,[2,6]],[[],9],[3,[7,0,10,3,8],[0,6]],3],[1,[[3,7,6,5]]],[[]],[[],[10,2,0,[8,3]]]]
|
||||
|
||||
[[[0]],[4,7,[[3,8,4],9],[[8,1,5],[1,1,7,6,2]]],[],[]]
|
||||
[[[5,0],[3],[1],[]],[[[5,1],6,7,0,10]],[[[6,0,1],0,[]],[9],[],[[9]],[9,[6,0,4,1]]],[]]
|
||||
|
||||
[[10],[],[3]]
|
||||
[[[[5,2,0,3],5,[],[7,1,5,7]]]]
|
||||
|
||||
[[[5,10,[3,4,5,4],8,0]],[[4],[[3,9,2,8,0],6,6]],[[],7,5,[0,0,[],[10]]]]
|
||||
[[2,3,5,[[9,5],6],0],[[[4,5,7,6,5],[6,1,9],8,[6,6,6],8],[7],8,5],[0,[6,[0,9,3,5],[9,1,9],3,7],[]],[[[1,6,0,5,0],[1,2,5,6,8],0,8],7]]
|
||||
|
||||
[[[],9],[]]
|
||||
[[8],[[[]],[],[3,3,[10,7,9,0,6],0],9],[],[[[5,10,5,8,10],[5,1,8,10,8]],6,0,[3],[[]]]]
|
||||
|
||||
[[7,[]]]
|
||||
[[[],9,[[0,9,1],[6],9,[8,4,10,4,7],[6]]],[3,[2,[0,5],7,9],2],[[[9],7,[1,7],9]]]
|
||||
56
2022/go/utils/inputFile.go
Normal file
56
2022/go/utils/inputFile.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GenInputFile(day int) string {
|
||||
var d string
|
||||
if day < 10 {
|
||||
d = fmt.Sprintf("0%d", day)
|
||||
} else {
|
||||
d = fmt.Sprintf("%d", day)
|
||||
}
|
||||
|
||||
pwd, _ := os.Getwd()
|
||||
path := fmt.Sprintf("%s\\day%s\\input.txt", pwd, d)
|
||||
fi, _ := os.Stat(path)
|
||||
if fi != nil {
|
||||
return path
|
||||
}
|
||||
|
||||
fmt.Println("Creating new input file...")
|
||||
f, _ := os.OpenFile(path, os.O_CREATE, 0700)
|
||||
f.WriteString(readHttp(2022, day))
|
||||
return path
|
||||
}
|
||||
|
||||
func readHttp(year, day int) string {
|
||||
fmt.Println("Fetching data into file...")
|
||||
|
||||
url := fmt.Sprintf("https://adventofcode.com/%d/day/%d/input", year, day)
|
||||
session := os.Getenv("sessionAoC")
|
||||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
req.AddCookie(&http.Cookie{Name: "session", Value: session})
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return string(body)
|
||||
}
|
||||
|
||||
61
2023/gareth/day01/day01.go
Normal file
61
2023/gareth/day01/day01.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package day01
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
total := 0
|
||||
lines := strings.Split(input, "\r\n")
|
||||
for _, line := range lines {
|
||||
regex := regexp.MustCompile("[a-zA-Z]")
|
||||
numbers := regex.ReplaceAllString(line, "")
|
||||
number := string(numbers[0]) + string(numbers[len(numbers)-1])
|
||||
i, _ := strconv.Atoi(number)
|
||||
total += i
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
values := map[string]string{
|
||||
"one": "1",
|
||||
"two": "2",
|
||||
"three": "3",
|
||||
"four": "4",
|
||||
"five": "5",
|
||||
"six": "6",
|
||||
"seven": "7",
|
||||
"eight": "8",
|
||||
"nine": "9",
|
||||
}
|
||||
lines := strings.Split(input, "\r\n")
|
||||
s := ""
|
||||
|
||||
total := 0
|
||||
for _, line := range lines {
|
||||
numbers := []string{}
|
||||
for _, c := range line {
|
||||
s = s + string(c)
|
||||
if num, err := strconv.Atoi(string(c)); err == nil {
|
||||
numbers = append(numbers, strconv.Itoa(num))
|
||||
s = ""
|
||||
}
|
||||
for key, value := range values {
|
||||
if strings.Contains(s, key) {
|
||||
numbers = append(numbers, value)
|
||||
buffer := s[len(s)-1]
|
||||
s = "" + string(buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
number := numbers[0] + numbers[len(numbers)-1]
|
||||
i, _ := strconv.Atoi(number)
|
||||
total += i
|
||||
s = ""
|
||||
}
|
||||
return total
|
||||
}
|
||||
25
2023/gareth/day01/day01_test.go
Normal file
25
2023/gareth/day01/day01_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package day01
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`1abc2
|
||||
pqr3stu8vwx
|
||||
a1b2c3d4e5f
|
||||
treb7uchet`)
|
||||
assert.Equal(t, 142, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`two1nine
|
||||
eightwothree
|
||||
abcone2threexyz
|
||||
xtwone3four
|
||||
4nineeightseven2
|
||||
zoneight234
|
||||
7pqrstsixteen`)
|
||||
assert.Equal(t, 281, r)
|
||||
}
|
||||
40
2023/gareth/day07/day07.go
Normal file
40
2023/gareth/day07/day07.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package day06
|
||||
|
||||
type Race struct {
|
||||
Time int
|
||||
Distance int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
var Races []Race
|
||||
Races = append(Races, Race{56, 546})
|
||||
Races = append(Races, Race{97, 1927})
|
||||
Races = append(Races, Race{78, 1131})
|
||||
Races = append(Races, Race{75, 1139})
|
||||
|
||||
total := 1
|
||||
for _, r := range Races {
|
||||
halfTime := r.Time / 2
|
||||
for i := 0; i <= halfTime; i++ {
|
||||
raceDis := i * (r.Time - i)
|
||||
if raceDis > r.Distance {
|
||||
total = total * (r.Time - (i * 2) + 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
r := Race{56977875, 546192711311139}
|
||||
halfTime := r.Time / 2
|
||||
for i := 0; i <= halfTime; i++ {
|
||||
raceDis := i * (r.Time - i)
|
||||
if raceDis > r.Distance {
|
||||
return r.Time - (i * 2) + 1
|
||||
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
16
2023/gareth/day07/day07_test.go
Normal file
16
2023/gareth/day07/day07_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package day06
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(``)
|
||||
assert.Equal(t, 1624896, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(``)
|
||||
assert.Equal(t, 32583852, r)
|
||||
}
|
||||
1000
2023/gareth/day07/input.txt
Normal file
1000
2023/gareth/day07/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
99
2023/gareth/day08/day08.go
Normal file
99
2023/gareth/day08/day08.go
Normal file
@@ -0,0 +1,99 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Direction struct {
|
||||
Destination string
|
||||
Left string
|
||||
Right string
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
lines := strings.Split(input, "\r\n")
|
||||
dir := make(map[string]Direction)
|
||||
for _, line := range lines {
|
||||
pattern := `[A-Z]+`
|
||||
re := regexp.MustCompile(pattern)
|
||||
matches := re.FindAllString(line, -1)
|
||||
dir[matches[0]] = Direction{matches[0], matches[1], matches[2]}
|
||||
}
|
||||
|
||||
currentloc := "AAA"
|
||||
m := "LRLRRLLRRLRRRLRLRRRLLRRLLLLRRRLRRRLRRLRRLRRRLRRRLLRRLRLRRLRRRLLLRRLRRLLRLLRRRLRRRLLRLRRRLRLLRRLLLRLRRRLRRRLRRRLLRLRRRLLRRLRLRLLRRLRRRLRRLRLLRLRRRLRRLRLRLRRLRRRLRRRLRRRLRRLRRRLLRRLRRLLRRRLLRLRLRLRLLLRRLRLRRLRRLRRLRRLRRRLRRRLRLRRRLRLRRRLRRLRLLRLRRLRLRLLLRLLLRRRLRRLLLRLRRRR"
|
||||
moves := strings.Split(m, "")
|
||||
moveIndex := 0
|
||||
total := 0
|
||||
for {
|
||||
move := moves[moveIndex]
|
||||
if move == "R" {
|
||||
currentloc = dir[currentloc].Right
|
||||
} else {
|
||||
currentloc = dir[currentloc].Left
|
||||
}
|
||||
total++
|
||||
if currentloc == "ZZZ" {
|
||||
return total
|
||||
}
|
||||
moveIndex = int(math.Mod(float64(moveIndex+1), float64(len(moves))))
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
lines := strings.Split(input, "\r\n")
|
||||
dir := make(map[string]Direction)
|
||||
for _, line := range lines {
|
||||
pattern := `[A-Z1-9]+`
|
||||
re := regexp.MustCompile(pattern)
|
||||
matches := re.FindAllString(line, -1)
|
||||
dir[matches[0]] = Direction{matches[0], matches[1], matches[2]}
|
||||
}
|
||||
var startingLoc []string
|
||||
for _, loc := range dir {
|
||||
des := loc.Destination
|
||||
if des[2] == 'A' {
|
||||
startingLoc = append(startingLoc, des)
|
||||
}
|
||||
}
|
||||
|
||||
m := "LRLRRLLRRLRRRLRLRRRLLRRLLLLRRRLRRRLRRLRRLRRRLRRRLLRRLRLRRLRRRLLLRRLRRLLRLLRRRLRRRLLRLRRRLRLLRRLLLRLRRRLRRRLRRRLLRLRRRLLRRLRLRLLRRLRRRLRRLRLLRLRRRLRRLRLRLRRLRRRLRRRLRRRLRRLRRRLLRRLRRLLRRRLLRLRLRLRLLLRRLRLRRLRRLRRLRRLRRRLRRRLRLRRRLRLRRRLRRLRLLRLRRLRLRLLLRLLLRRRLRRLLLRLRRRR"
|
||||
moves := strings.Split(m, "")
|
||||
moveIndex := 0
|
||||
startingLocIndex := 0
|
||||
currentloc := ""
|
||||
total := 0
|
||||
for {
|
||||
for _, loc := range startingLoc {
|
||||
currentloc = loc
|
||||
move := moves[moveIndex]
|
||||
if move == "R" {
|
||||
currentloc = dir[currentloc].Right
|
||||
} else {
|
||||
currentloc = dir[currentloc].Left
|
||||
}
|
||||
startingLoc[startingLocIndex] = currentloc
|
||||
startingLocIndex = int(math.Mod(float64(startingLocIndex+1), float64(len(startingLoc))))
|
||||
}
|
||||
total++
|
||||
endFlag := false
|
||||
for _, loc := range startingLoc {
|
||||
if loc[2] == 'Z' {
|
||||
endFlag = true
|
||||
} else {
|
||||
endFlag = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if endFlag == true {
|
||||
return total
|
||||
}
|
||||
moveIndex = int(math.Mod(float64(moveIndex+1), float64(len(moves))))
|
||||
fmt.Println(total)
|
||||
}
|
||||
return -2
|
||||
}
|
||||
25
2023/gareth/day08/day08_test.go
Normal file
25
2023/gareth/day08/day08_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`AAA = (BBB, BBB)
|
||||
BBB = (AAA, ZZZ)
|
||||
ZZZ = (ZZZ, ZZZ)`)
|
||||
assert.Equal(t, 6, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`11A = (11B, XXX)
|
||||
11B = (XXX, 11Z)
|
||||
11Z = (11B, XXX)
|
||||
22A = (22B, XXX)
|
||||
22B = (22C, 22C)
|
||||
22C = (22Z, 22Z)
|
||||
22Z = (22B, 22B)
|
||||
XXX = (XXX, XXX)`)
|
||||
assert.Equal(t, 6, r)
|
||||
}
|
||||
746
2023/gareth/day08/input.txt
Normal file
746
2023/gareth/day08/input.txt
Normal file
@@ -0,0 +1,746 @@
|
||||
PNM = (QGP, BFT)
|
||||
HNH = (JPB, GMH)
|
||||
FNN = (DDN, PTB)
|
||||
VJS = (LHL, THF)
|
||||
KPV = (JFQ, TRN)
|
||||
BDQ = (BCP, LNN)
|
||||
SDC = (CVC, THN)
|
||||
MKN = (HXP, RHH)
|
||||
KXH = (FPR, GTC)
|
||||
TPD = (SPS, LFR)
|
||||
GQT = (TKX, SHR)
|
||||
CHM = (VBJ, SBV)
|
||||
FMR = (BSR, TTH)
|
||||
VVT = (PMJ, LDH)
|
||||
DCX = (KNH, GKT)
|
||||
HMK = (VNX, XRC)
|
||||
LDP = (JHJ, SLT)
|
||||
TBS = (QDR, PNM)
|
||||
QPG = (GFN, XGN)
|
||||
DRB = (CBX, NBL)
|
||||
BQP = (QQL, BVH)
|
||||
QRR = (TJT, DMP)
|
||||
CLL = (LMC, HXV)
|
||||
NLX = (CJS, RVR)
|
||||
DPT = (SKJ, TDH)
|
||||
GQV = (NDN, TPD)
|
||||
NTG = (MSK, VMX)
|
||||
LHP = (VBJ, SBV)
|
||||
JKC = (TLG, CNT)
|
||||
JKL = (GNF, RFM)
|
||||
KTS = (NKH, RJC)
|
||||
MHM = (SLG, JQX)
|
||||
ZZZ = (LFM, MHM)
|
||||
MKB = (RQJ, GKB)
|
||||
LLC = (MBV, QKM)
|
||||
LNT = (XFG, CGX)
|
||||
XDB = (TSB, NSM)
|
||||
RFD = (DCT, TMM)
|
||||
BCL = (JXM, JXM)
|
||||
JTM = (CHM, LHP)
|
||||
GFN = (VRT, VSS)
|
||||
KBV = (FXC, JDS)
|
||||
THM = (GMG, GMG)
|
||||
PPH = (KTK, MXN)
|
||||
RJD = (LQG, NHJ)
|
||||
QDQ = (GDQ, KQG)
|
||||
VJL = (QKM, MBV)
|
||||
NXN = (JGX, QKD)
|
||||
LQR = (BPL, CJF)
|
||||
VMM = (FMR, XMJ)
|
||||
DFA = (TJT, DMP)
|
||||
MHK = (XGH, SBK)
|
||||
QVR = (LKM, FNR)
|
||||
GMN = (DPT, TBK)
|
||||
CGX = (PTT, NSL)
|
||||
KSM = (CNT, TLG)
|
||||
BVH = (MQD, JSL)
|
||||
HHX = (FVT, PGL)
|
||||
JQH = (DCT, TMM)
|
||||
TTH = (VVT, GNH)
|
||||
GMG = (MHM, LFM)
|
||||
RMP = (XMV, MLT)
|
||||
SXH = (VJL, LLC)
|
||||
MGP = (SHN, GHV)
|
||||
GDQ = (VQM, TRH)
|
||||
XFG = (NSL, PTT)
|
||||
BLA = (XLR, VNR)
|
||||
RVL = (PQK, BQH)
|
||||
STC = (THR, NQM)
|
||||
TLT = (TTK, GLQ)
|
||||
BKS = (XCC, SLX)
|
||||
QNP = (RQR, XPH)
|
||||
CKR = (TKG, MVD)
|
||||
SNQ = (LSP, SGQ)
|
||||
MCM = (THX, PXM)
|
||||
THF = (CTS, QHD)
|
||||
PLT = (MTF, FRP)
|
||||
FRS = (KSN, RKG)
|
||||
RTB = (SRD, BDR)
|
||||
SGV = (BCL, BCL)
|
||||
NBL = (VKC, QJV)
|
||||
PTT = (HJT, TFN)
|
||||
STJ = (CMM, JXD)
|
||||
CTP = (XFP, TLT)
|
||||
SRD = (DXH, DPG)
|
||||
KMP = (MRK, JHM)
|
||||
FXP = (NMP, QXT)
|
||||
HLL = (NKR, HSN)
|
||||
TNQ = (CVC, THN)
|
||||
TRQ = (KMP, LVQ)
|
||||
GGV = (HQQ, RRH)
|
||||
SDM = (JJB, DCG)
|
||||
FNB = (CBB, VXB)
|
||||
GBX = (CRK, NXN)
|
||||
FPB = (DGR, KPV)
|
||||
SJT = (STQ, JKL)
|
||||
LXC = (CQB, GSG)
|
||||
GTC = (PTF, XDB)
|
||||
VTT = (KVR, KVR)
|
||||
XMX = (RMN, JTD)
|
||||
FFP = (JNV, QPG)
|
||||
QBF = (TGN, TMP)
|
||||
CMB = (FQC, JNX)
|
||||
CJS = (NGV, GDB)
|
||||
VRM = (QJJ, LXC)
|
||||
MPG = (SGC, CHD)
|
||||
PRV = (GNT, QDP)
|
||||
CBH = (SQM, DRP)
|
||||
DDR = (MCM, BDK)
|
||||
FGM = (NDQ, SJQ)
|
||||
QHV = (FQC, JNX)
|
||||
QXF = (MVV, DRB)
|
||||
FFL = (BPX, KMG)
|
||||
KJM = (MVD, TKG)
|
||||
XBX = (QDR, PNM)
|
||||
FRD = (XPG, GDL)
|
||||
KDG = (CBB, VXB)
|
||||
KDM = (KVR, HPN)
|
||||
MCP = (HCQ, SHT)
|
||||
SVP = (LKM, FNR)
|
||||
LBC = (JLT, DVR)
|
||||
GXQ = (HSN, NKR)
|
||||
FSF = (NQS, QCK)
|
||||
PRF = (CNF, TKF)
|
||||
TPL = (DFS, MCH)
|
||||
DVR = (KDJ, QSR)
|
||||
LVT = (MKK, VCB)
|
||||
RHK = (LRM, JJV)
|
||||
MTJ = (KKQ, BDB)
|
||||
CCH = (MTJ, JGS)
|
||||
JDS = (KMQ, FNN)
|
||||
GPG = (BGT, MNM)
|
||||
XLC = (DDV, LVT)
|
||||
HMV = (TLC, LDT)
|
||||
JHJ = (HNX, XCF)
|
||||
QXT = (HLL, GXQ)
|
||||
NNS = (MRQ, FGM)
|
||||
PGL = (JLX, SKT)
|
||||
PPJ = (QTS, XVR)
|
||||
TSB = (JTK, LMH)
|
||||
JJV = (QJH, KCX)
|
||||
SSX = (BXM, BQC)
|
||||
QGP = (DLQ, MXH)
|
||||
TKX = (JCX, XRP)
|
||||
XQR = (BJG, GMN)
|
||||
SLX = (BLK, SJG)
|
||||
XGH = (DTT, MBM)
|
||||
SFM = (VTT, KDM)
|
||||
RRT = (RQJ, RQJ)
|
||||
HDC = (TKX, SHR)
|
||||
GQC = (CLL, SJR)
|
||||
HSN = (JTS, FLC)
|
||||
BLR = (NTL, LTR)
|
||||
JCS = (KMP, LVQ)
|
||||
BTG = (SDC, TNQ)
|
||||
GNT = (CVP, QBX)
|
||||
KVH = (TXL, MKX)
|
||||
LXS = (MGP, TTL)
|
||||
CTS = (QBL, NKN)
|
||||
LSP = (CXH, TGR)
|
||||
HLR = (JXD, CMM)
|
||||
MBM = (TCF, PRV)
|
||||
DNQ = (FRR, VNJ)
|
||||
GBK = (MSG, PDG)
|
||||
TTL = (SHN, GHV)
|
||||
SLG = (SPK, MFB)
|
||||
SGS = (RQC, TGB)
|
||||
KMQ = (DDN, PTB)
|
||||
MJJ = (RTK, LVN)
|
||||
JHM = (PGH, GGX)
|
||||
SMD = (JQS, FKR)
|
||||
JNP = (CMS, GSM)
|
||||
NDD = (MSK, VMX)
|
||||
XXK = (JVR, FSF)
|
||||
TXL = (RDM, VJS)
|
||||
MTF = (GTK, QJK)
|
||||
TTK = (KJM, CKR)
|
||||
NVL = (JLF, BNV)
|
||||
KHX = (KSS, GPG)
|
||||
FVR = (FVT, PGL)
|
||||
KSN = (VDX, SVM)
|
||||
FXF = (SQQ, TQC)
|
||||
NPS = (FKR, JQS)
|
||||
XVR = (CHL, PLN)
|
||||
MFB = (CFL, PBB)
|
||||
VXC = (LNT, MLQ)
|
||||
LHL = (CTS, QHD)
|
||||
TXX = (DMS, DFR)
|
||||
MQJ = (TXX, VMR)
|
||||
QPK = (JBH, KXM)
|
||||
LMC = (XLC, CRR)
|
||||
TFN = (JTM, RPB)
|
||||
PDG = (NKS, CBH)
|
||||
PGH = (PVM, XXK)
|
||||
KPX = (HXP, RHH)
|
||||
HLV = (BXM, BQC)
|
||||
JGK = (JCS, TRQ)
|
||||
KKQ = (SFK, MCF)
|
||||
PQF = (HBK, RMP)
|
||||
KXM = (RTB, FFQ)
|
||||
NPR = (QQT, SNQ)
|
||||
FRP = (QJK, GTK)
|
||||
DGX = (PDF, HCB)
|
||||
PLP = (KTK, MXN)
|
||||
TCM = (XFT, KPH)
|
||||
QQL = (JSL, MQD)
|
||||
QTS = (PLN, CHL)
|
||||
QFG = (RXM, PHM)
|
||||
JJB = (LXS, KTH)
|
||||
LGS = (VXF, BGH)
|
||||
MBV = (BTJ, BRH)
|
||||
BTJ = (FKB, QTL)
|
||||
VNR = (TKS, LQR)
|
||||
GVN = (PJR, XMX)
|
||||
XLL = (GSK, RXC)
|
||||
GNF = (RVL, BTC)
|
||||
LMD = (NXN, CRK)
|
||||
NNN = (QQK, BDQ)
|
||||
QBD = (VQR, XJB)
|
||||
GSM = (LVR, VMJ)
|
||||
NKN = (RFD, JQH)
|
||||
HMC = (GSK, RXC)
|
||||
LVN = (KDG, FNB)
|
||||
CBX = (QJV, VKC)
|
||||
RRF = (GQT, HDC)
|
||||
RCV = (XQR, HRK)
|
||||
DMS = (HNP, XKR)
|
||||
LXP = (LNJ, NVL)
|
||||
CFJ = (FXC, JDS)
|
||||
HPT = (BVS, FJQ)
|
||||
KTH = (TTL, MGP)
|
||||
XMV = (XNL, TDJ)
|
||||
STQ = (RFM, GNF)
|
||||
SJQ = (GGG, NQF)
|
||||
LKM = (GVN, SVX)
|
||||
VKK = (DCG, JJB)
|
||||
TCF = (QDP, GNT)
|
||||
XMQ = (XFT, KPH)
|
||||
QMD = (JHJ, SLT)
|
||||
KHB = (KMG, BPX)
|
||||
VPR = (CSD, BTG)
|
||||
PJB = (GGN, TSC)
|
||||
TVP = (SGC, CHD)
|
||||
BPX = (GQV, PQM)
|
||||
TSH = (QMD, LDP)
|
||||
KCV = (NMP, QXT)
|
||||
THX = (LMD, GBX)
|
||||
CFL = (CLR, GTN)
|
||||
FGK = (FJG, TRX)
|
||||
FKD = (XMJ, FMR)
|
||||
JVR = (NQS, QCK)
|
||||
RTK = (KDG, FNB)
|
||||
BHQ = (LPB, XMN)
|
||||
VNJ = (JGK, KHK)
|
||||
TMP = (JVK, PQF)
|
||||
KPT = (BNM, BVJ)
|
||||
QXX = (TMF, PNB)
|
||||
QBR = (HHX, FVR)
|
||||
TFL = (MCH, DFS)
|
||||
NQN = (DDR, RMX)
|
||||
LFG = (VTT, KDM)
|
||||
VDX = (SMD, NPS)
|
||||
VQM = (FPB, HGR)
|
||||
NDP = (SNQ, QQT)
|
||||
DGR = (JFQ, TRN)
|
||||
FFK = (VNJ, FRR)
|
||||
GTN = (DSP, MXS)
|
||||
MNH = (MCP, GFC)
|
||||
XRP = (KTT, BKX)
|
||||
LRM = (KCX, QJH)
|
||||
QKD = (TXT, MCK)
|
||||
VFH = (GMH, JPB)
|
||||
KVR = (THM, THM)
|
||||
MLQ = (CGX, XFG)
|
||||
RPB = (CHM, LHP)
|
||||
JNC = (BQS, TRT)
|
||||
RXC = (HRN, VKG)
|
||||
JLD = (QDH, SSP)
|
||||
TDJ = (LHC, KCB)
|
||||
VFQ = (JJV, LRM)
|
||||
FLC = (SSQ, HVF)
|
||||
XPH = (SXH, BVX)
|
||||
CXL = (HDC, GQT)
|
||||
JSL = (CGL, MJJ)
|
||||
KQG = (TRH, VQM)
|
||||
QJP = (PDG, MSG)
|
||||
TNP = (KMD, XMB)
|
||||
DQC = (QSL, DJF)
|
||||
QKK = (RRH, HQQ)
|
||||
HGR = (DGR, KPV)
|
||||
MXS = (GBK, QJP)
|
||||
BVX = (VJL, LLC)
|
||||
FRR = (KHK, JGK)
|
||||
QQT = (SGQ, LSP)
|
||||
KHL = (SCN, PRB)
|
||||
SKJ = (DLN, LJQ)
|
||||
TKS = (BPL, CJF)
|
||||
DTT = (PRV, TCF)
|
||||
NPV = (XFP, TLT)
|
||||
QHB = (NNS, RCZ)
|
||||
JPB = (GGS, KLG)
|
||||
NFQ = (BXH, FGK)
|
||||
DJF = (VVQ, QCT)
|
||||
MNF = (FNH, SJT)
|
||||
XPG = (CFJ, KBV)
|
||||
SVX = (PJR, XMX)
|
||||
TGR = (TVP, MPG)
|
||||
NTL = (RRT, MKB)
|
||||
MKK = (FRD, MCS)
|
||||
LVL = (LBV, TVZ)
|
||||
SKT = (FCX, DQC)
|
||||
NKR = (JTS, FLC)
|
||||
XFP = (TTK, GLQ)
|
||||
QGN = (MTG, QVL)
|
||||
JXD = (MHK, JSS)
|
||||
PQK = (SVP, QVR)
|
||||
VBJ = (SSX, HLV)
|
||||
TDH = (LJQ, DLN)
|
||||
MRK = (GGX, PGH)
|
||||
HCB = (HST, GJF)
|
||||
NSM = (LMH, JTK)
|
||||
LQG = (TNP, SHH)
|
||||
PMT = (KLV, JVZ)
|
||||
CNF = (CJN, VSG)
|
||||
GGS = (VHV, QQF)
|
||||
QKM = (BRH, BTJ)
|
||||
KRN = (DTH, HFG)
|
||||
TKV = (RXM, PHM)
|
||||
GKB = (FNX, QHB)
|
||||
GNH = (PMJ, LDH)
|
||||
RCZ = (FGM, MRQ)
|
||||
HFP = (KSN, RKG)
|
||||
JLX = (DQC, FCX)
|
||||
CMS = (LVR, VMJ)
|
||||
RXM = (QXX, LJR)
|
||||
TRH = (HGR, FPB)
|
||||
TPR = (JBC, KHX)
|
||||
MCS = (XPG, GDL)
|
||||
GKT = (MKN, KPX)
|
||||
RKG = (VDX, SVM)
|
||||
BDB = (MCF, SFK)
|
||||
TLG = (HGG, DCX)
|
||||
KLG = (QQF, VHV)
|
||||
RVR = (GDB, NGV)
|
||||
JBC = (GPG, KSS)
|
||||
BVS = (BHQ, PNX)
|
||||
DLQ = (SGS, LFP)
|
||||
BNL = (GFC, MCP)
|
||||
KNH = (MKN, KPX)
|
||||
BNV = (LLX, CBT)
|
||||
GVJ = (JNT, QKQ)
|
||||
SHH = (KMD, XMB)
|
||||
BXH = (TRX, FJG)
|
||||
QBL = (JQH, RFD)
|
||||
XNF = (TPR, NHG)
|
||||
TKG = (KSM, JKC)
|
||||
PLN = (VGM, JNC)
|
||||
PRB = (RCX, MQJ)
|
||||
CVP = (VFL, KHL)
|
||||
XLM = (TSC, GGN)
|
||||
QPT = (SRM, QTT)
|
||||
BQH = (QVR, SVP)
|
||||
BMB = (FGK, BXH)
|
||||
CRR = (LVT, DDV)
|
||||
SXM = (NDD, NTG)
|
||||
SGR = (NHJ, LQG)
|
||||
SRM = (HLR, STJ)
|
||||
CLT = (TGN, TMP)
|
||||
FFQ = (SRD, BDR)
|
||||
NBF = (TQC, SQQ)
|
||||
JBK = (LBB, LBB)
|
||||
PXM = (GBX, LMD)
|
||||
VNX = (GKR, HQT)
|
||||
DLN = (VXC, SNP)
|
||||
XNL = (KCB, LHC)
|
||||
QJH = (HNH, VFH)
|
||||
BGT = (DGX, MGN)
|
||||
QSL = (VVQ, QCT)
|
||||
BPL = (VMM, FKD)
|
||||
VKC = (SGR, RJD)
|
||||
THR = (HDJ, NQN)
|
||||
KFD = (JNP, TQH)
|
||||
XMN = (NBF, FXF)
|
||||
MXH = (LFP, SGS)
|
||||
DRP = (TKV, QFG)
|
||||
CMM = (MHK, JSS)
|
||||
RCM = (TXL, MKX)
|
||||
JLF = (CBT, LLX)
|
||||
XGN = (VSS, VRT)
|
||||
KCH = (FSR, GVJ)
|
||||
LPB = (NBF, FXF)
|
||||
MQC = (SFM, LFG)
|
||||
JGQ = (KQG, GDQ)
|
||||
VVQ = (MNH, BNL)
|
||||
BDR = (DXH, DPG)
|
||||
GGN = (DNQ, FFK)
|
||||
TGA = (FRS, HFP)
|
||||
VLT = (DXD, GPN)
|
||||
LFB = (CXL, RRF)
|
||||
KVD = (CSD, BTG)
|
||||
FJV = (DGP, HMV)
|
||||
HFG = (GGV, QKK)
|
||||
CBB = (PLT, RPJ)
|
||||
LDT = (PLP, PPH)
|
||||
BJG = (TBK, DPT)
|
||||
NFM = (HRK, XQR)
|
||||
QBX = (KHL, VFL)
|
||||
JNV = (XGN, GFN)
|
||||
VSS = (DCV, NHB)
|
||||
BRH = (FKB, QTL)
|
||||
SSF = (VQR, XJB)
|
||||
RDP = (NQM, THR)
|
||||
PQM = (TPD, NDN)
|
||||
JST = (RHD, LVL)
|
||||
NCH = (KPT, BBK)
|
||||
VFL = (PRB, SCN)
|
||||
HQQ = (JPM, LKS)
|
||||
JTK = (NVT, FJV)
|
||||
NVT = (DGP, HMV)
|
||||
FNX = (NNS, NNS)
|
||||
GSG = (XLL, HMC)
|
||||
SQQ = (THB, DRD)
|
||||
KMG = (GQV, PQM)
|
||||
KDJ = (CHN, NHX)
|
||||
MQD = (MJJ, CGL)
|
||||
TVZ = (KHB, FFL)
|
||||
JGX = (MCK, TXT)
|
||||
CNS = (JLT, DVR)
|
||||
JBH = (RTB, FFQ)
|
||||
GGX = (PVM, XXK)
|
||||
TGN = (JVK, PQF)
|
||||
JNX = (VKS, PRF)
|
||||
TLC = (PLP, PPH)
|
||||
TQH = (GSM, CMS)
|
||||
KHK = (TRQ, JCS)
|
||||
KMZ = (VNR, XLR)
|
||||
SFK = (TSH, VJM)
|
||||
KTT = (TFL, TPL)
|
||||
MVV = (NBL, CBX)
|
||||
LVR = (NCH, SGM)
|
||||
BDK = (THX, PXM)
|
||||
HRN = (QQC, QQC)
|
||||
LFR = (CNS, LBC)
|
||||
CHN = (QLV, HPT)
|
||||
RHH = (PPJ, RHX)
|
||||
XJB = (JBK, RMR)
|
||||
FXC = (KMQ, FNN)
|
||||
RQC = (XXS, LGS)
|
||||
CGL = (RTK, LVN)
|
||||
SQV = (FRV, QNP)
|
||||
GXN = (RRF, CXL)
|
||||
FPR = (XDB, PTF)
|
||||
DDV = (VCB, MKK)
|
||||
BTC = (PQK, BQH)
|
||||
GDP = (MBH, FFP)
|
||||
PDF = (GJF, HST)
|
||||
SQM = (QFG, TKV)
|
||||
VLC = (MBH, FFP)
|
||||
PJS = (RDP, STC)
|
||||
RFM = (RVL, BTC)
|
||||
PTF = (TSB, NSM)
|
||||
MCF = (VJM, TSH)
|
||||
KCX = (HNH, VFH)
|
||||
GHV = (TJC, QPK)
|
||||
DDN = (QBF, CLT)
|
||||
DFR = (XKR, HNP)
|
||||
SXR = (XCH, SQV)
|
||||
GLQ = (KJM, CKR)
|
||||
DNJ = (SXR, XKT)
|
||||
QHD = (QBL, NKN)
|
||||
NHB = (VPR, KVD)
|
||||
SDR = (GVJ, FSR)
|
||||
CRK = (JGX, QKD)
|
||||
SJR = (HXV, LMC)
|
||||
FQC = (VKS, PRF)
|
||||
SLT = (XCF, HNX)
|
||||
QTF = (TQH, JNP)
|
||||
VMX = (LGN, CCH)
|
||||
QFS = (STC, RDP)
|
||||
FCX = (QSL, DJF)
|
||||
DFS = (VLC, GDP)
|
||||
LHC = (TNR, HMK)
|
||||
HBQ = (KCH, SDR)
|
||||
TRT = (QPT, QLG)
|
||||
QLV = (FJQ, BVS)
|
||||
FKB = (NGG, VLT)
|
||||
HST = (KTS, LCH)
|
||||
BBK = (BVJ, BNM)
|
||||
JQX = (SPK, MFB)
|
||||
TBK = (SKJ, TDH)
|
||||
CSD = (SDC, TNQ)
|
||||
SHN = (QPK, TJC)
|
||||
HQT = (NPV, CTP)
|
||||
TJC = (KXM, JBH)
|
||||
FDP = (FVR, HHX)
|
||||
QDR = (BFT, QGP)
|
||||
AAA = (MHM, LFM)
|
||||
GTD = (JXM, KMZ)
|
||||
TRN = (LTJ, FTV)
|
||||
TMF = (QGN, FTS)
|
||||
LVQ = (MRK, JHM)
|
||||
PNX = (XMN, LPB)
|
||||
KCB = (TNR, HMK)
|
||||
FJQ = (PNX, BHQ)
|
||||
TGB = (LGS, XXS)
|
||||
SSP = (QRR, MRZ)
|
||||
GGG = (BMB, NFQ)
|
||||
FNH = (STQ, JKL)
|
||||
LFD = (SJT, FNH)
|
||||
LLX = (JHS, GQC)
|
||||
BQS = (QPT, QLG)
|
||||
QJK = (RHK, VFQ)
|
||||
SBK = (MBM, DTT)
|
||||
QVL = (QHV, CMB)
|
||||
QQC = (GQQ, GQQ)
|
||||
HNX = (DNJ, XCP)
|
||||
BXM = (QSJ, BLR)
|
||||
TNR = (VNX, XRC)
|
||||
SHR = (XRP, JCX)
|
||||
VGM = (BQS, TRT)
|
||||
BSR = (VVT, GNH)
|
||||
LCH = (RJC, NKH)
|
||||
FVT = (SKT, JLX)
|
||||
HGG = (KNH, GKT)
|
||||
HVF = (XVP, HQR)
|
||||
JSS = (SBK, XGH)
|
||||
TKF = (VSG, CJN)
|
||||
XCF = (XCP, DNJ)
|
||||
MCK = (RTL, KRN)
|
||||
DGP = (LDT, TLC)
|
||||
FSR = (JNT, QKQ)
|
||||
JCX = (KTT, BKX)
|
||||
MGN = (PDF, HCB)
|
||||
BQC = (BLR, QSJ)
|
||||
KMD = (NPR, NDP)
|
||||
QCK = (XBX, TBS)
|
||||
GFC = (HCQ, SHT)
|
||||
JXM = (XLR, VNR)
|
||||
XKT = (XCH, SQV)
|
||||
THN = (SGV, JDB)
|
||||
XCP = (SXR, XKT)
|
||||
NHG = (JBC, KHX)
|
||||
HXP = (PPJ, RHX)
|
||||
NHJ = (TNP, SHH)
|
||||
QTL = (NGG, VLT)
|
||||
XVP = (SVC, SVC)
|
||||
FNR = (GVN, SVX)
|
||||
MDN = (MVV, DRB)
|
||||
LTR = (RRT, MKB)
|
||||
KSS = (BGT, MNM)
|
||||
SBV = (HLV, SSX)
|
||||
MXN = (PJB, XLM)
|
||||
MTG = (QHV, CMB)
|
||||
MLT = (TDJ, XNL)
|
||||
TSC = (DNQ, FFK)
|
||||
VCB = (FRD, MCS)
|
||||
CNT = (HGG, DCX)
|
||||
SSQ = (XVP, HQR)
|
||||
XKR = (VRM, DHN)
|
||||
BLK = (QBD, SSF)
|
||||
HPJ = (BDQ, QQK)
|
||||
JPM = (NNN, HPJ)
|
||||
KPH = (XNF, TXM)
|
||||
LDS = (GMG, ZZZ)
|
||||
LQN = (GQQ, PMT)
|
||||
HRK = (BJG, GMN)
|
||||
BGH = (KCV, FXP)
|
||||
BVJ = (SXK, SXM)
|
||||
GDB = (PSL, QBH)
|
||||
GPN = (BKS, DFX)
|
||||
RTL = (HFG, DTH)
|
||||
TMM = (KFD, QTF)
|
||||
GSK = (HRN, VKG)
|
||||
VKG = (QQC, LQN)
|
||||
RMX = (BDK, MCM)
|
||||
CBT = (GQC, JHS)
|
||||
RHD = (LBV, LBV)
|
||||
NMP = (GXQ, HLL)
|
||||
MRZ = (DMP, TJT)
|
||||
XMR = (SFM, LFG)
|
||||
QBH = (TCM, XMQ)
|
||||
PMJ = (FDP, QBR)
|
||||
QKQ = (MQC, XMR)
|
||||
JDB = (BCL, GTD)
|
||||
RCX = (VMR, TXX)
|
||||
LJR = (TMF, PNB)
|
||||
JVZ = (HFP, FRS)
|
||||
DRD = (JGQ, QDQ)
|
||||
SVM = (NPS, SMD)
|
||||
FTV = (KGH, QTD)
|
||||
QDH = (QRR, QRR)
|
||||
BCP = (RCV, NFM)
|
||||
DCT = (KFD, QTF)
|
||||
PVM = (JVR, FSF)
|
||||
SGM = (BBK, KPT)
|
||||
GQQ = (KLV, KLV)
|
||||
PJR = (RMN, JTD)
|
||||
VKS = (TKF, CNF)
|
||||
NKS = (DRP, SQM)
|
||||
JQS = (FSP, GLG)
|
||||
RRH = (LKS, JPM)
|
||||
SJG = (QBD, SSF)
|
||||
QSR = (NHX, CHN)
|
||||
SCN = (RCX, MQJ)
|
||||
NQS = (XBX, TBS)
|
||||
GLG = (LXP, RKL)
|
||||
QTD = (RCM, KVH)
|
||||
XFT = (TXM, XNF)
|
||||
DTH = (GGV, QKK)
|
||||
FSP = (LXP, RKL)
|
||||
JVK = (HBK, RMP)
|
||||
SPK = (CFL, PBB)
|
||||
NQF = (NFQ, BMB)
|
||||
KQV = (CJS, RVR)
|
||||
SGQ = (TGR, CXH)
|
||||
DXD = (BKS, DFX)
|
||||
KGH = (RCM, KVH)
|
||||
LBB = (RHD, RHD)
|
||||
RHX = (XVR, QTS)
|
||||
JHS = (SJR, CLL)
|
||||
SGC = (LFB, GXN)
|
||||
RQJ = (FNX, FNX)
|
||||
SHT = (QXF, MDN)
|
||||
THB = (JGQ, QDQ)
|
||||
RMR = (LBB, JST)
|
||||
RDM = (LHL, THF)
|
||||
JTS = (SSQ, HVF)
|
||||
RPJ = (FRP, MTF)
|
||||
QCT = (MNH, BNL)
|
||||
XLR = (TKS, LQR)
|
||||
VRT = (NHB, DCV)
|
||||
LDH = (FDP, QBR)
|
||||
SNP = (MLQ, LNT)
|
||||
FKR = (GLG, FSP)
|
||||
QLG = (QTT, SRM)
|
||||
VXB = (RPJ, PLT)
|
||||
LFP = (TGB, RQC)
|
||||
NDN = (LFR, SPS)
|
||||
TXT = (KRN, RTL)
|
||||
NSL = (HJT, TFN)
|
||||
QQK = (BCP, LNN)
|
||||
CJN = (MNF, LFD)
|
||||
PNB = (QGN, FTS)
|
||||
SPS = (CNS, LBC)
|
||||
XMB = (NPR, NDP)
|
||||
VJM = (LDP, QMD)
|
||||
MRQ = (SJQ, NDQ)
|
||||
MCH = (VLC, GDP)
|
||||
KLV = (FRS, HFP)
|
||||
HDJ = (DDR, RMX)
|
||||
LMH = (FJV, NVT)
|
||||
PTB = (QBF, CLT)
|
||||
MVD = (KSM, JKC)
|
||||
VXF = (KCV, FXP)
|
||||
HXV = (CRR, XLC)
|
||||
QJJ = (GSG, CQB)
|
||||
VMR = (DMS, DFR)
|
||||
TJT = (SDM, VKK)
|
||||
LNJ = (JLF, BNV)
|
||||
SVC = (QDH, QDH)
|
||||
VSG = (MNF, LFD)
|
||||
BFT = (DLQ, MXH)
|
||||
RJC = (KXH, DNV)
|
||||
FRV = (RQR, XPH)
|
||||
BNM = (SXK, SXM)
|
||||
LFM = (SLG, JQX)
|
||||
MSK = (CCH, LGN)
|
||||
JNT = (MQC, XMR)
|
||||
DHN = (LXC, QJJ)
|
||||
QTT = (STJ, HLR)
|
||||
QDP = (CVP, QBX)
|
||||
HPN = (THM, LDS)
|
||||
HNP = (DHN, VRM)
|
||||
NKH = (DNV, KXH)
|
||||
VHV = (HBQ, CND)
|
||||
CJF = (FKD, VMM)
|
||||
MKX = (VJS, RDM)
|
||||
CHD = (LFB, GXN)
|
||||
BKX = (TFL, TPL)
|
||||
DCG = (KTH, LXS)
|
||||
LTJ = (QTD, KGH)
|
||||
PQA = (FFL, KHB)
|
||||
GKR = (CTP, NPV)
|
||||
DSP = (QJP, GBK)
|
||||
XRC = (HQT, GKR)
|
||||
FJG = (PJS, QFS)
|
||||
XCC = (SJG, BLK)
|
||||
LKS = (HPJ, NNN)
|
||||
DPG = (NLX, KQV)
|
||||
PSL = (XMQ, TCM)
|
||||
NGV = (QBH, PSL)
|
||||
RMN = (GHT, BQP)
|
||||
NQM = (NQN, HDJ)
|
||||
CQB = (HMC, XLL)
|
||||
QJV = (RJD, SGR)
|
||||
MNM = (DGX, MGN)
|
||||
VQR = (JBK, RMR)
|
||||
XCH = (QNP, FRV)
|
||||
HCQ = (MDN, QXF)
|
||||
HJT = (RPB, JTM)
|
||||
VMJ = (SGM, NCH)
|
||||
DNV = (FPR, GTC)
|
||||
LGN = (JGS, MTJ)
|
||||
TQC = (DRD, THB)
|
||||
JFQ = (LTJ, FTV)
|
||||
JGS = (BDB, KKQ)
|
||||
RKL = (NVL, LNJ)
|
||||
CLR = (DSP, MXS)
|
||||
CQA = (MRQ, FGM)
|
||||
HQR = (SVC, JLD)
|
||||
DMP = (VKK, SDM)
|
||||
QSJ = (NTL, LTR)
|
||||
GDL = (KBV, CFJ)
|
||||
FTS = (MTG, QVL)
|
||||
DCV = (KVD, VPR)
|
||||
TRX = (PJS, QFS)
|
||||
KTK = (PJB, XLM)
|
||||
XMJ = (TTH, BSR)
|
||||
HBK = (MLT, XMV)
|
||||
CHL = (JNC, VGM)
|
||||
QQF = (CND, HBQ)
|
||||
DFX = (SLX, XCC)
|
||||
LJQ = (VXC, SNP)
|
||||
TXM = (NHG, TPR)
|
||||
NHX = (HPT, QLV)
|
||||
GJF = (KTS, LCH)
|
||||
LNN = (NFM, RCV)
|
||||
DXH = (NLX, KQV)
|
||||
SXK = (NTG, NDD)
|
||||
CXH = (MPG, TVP)
|
||||
PHM = (LJR, QXX)
|
||||
CND = (KCH, SDR)
|
||||
MSG = (CBH, NKS)
|
||||
RQR = (SXH, BVX)
|
||||
GHT = (QQL, BVH)
|
||||
GTK = (VFQ, RHK)
|
||||
NDQ = (NQF, GGG)
|
||||
CVC = (SGV, SGV)
|
||||
NGG = (GPN, DXD)
|
||||
PBB = (CLR, GTN)
|
||||
JLT = (QSR, KDJ)
|
||||
MBH = (JNV, QPG)
|
||||
JTD = (GHT, BQP)
|
||||
LBV = (FFL, KHB)
|
||||
XXS = (VXF, BGH)
|
||||
GMH = (GGS, KLG)
|
||||
80
2023/gareth/day09/day09.go
Normal file
80
2023/gareth/day09/day09.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
lines := strings.Split(input, "\r\n")
|
||||
total := 0
|
||||
for _, line := range lines {
|
||||
var intSeq []int
|
||||
seq := strings.Split(line, " ")
|
||||
for _, i := range seq {
|
||||
num, _ := strconv.Atoi(i)
|
||||
intSeq = append(intSeq, num)
|
||||
}
|
||||
total += extrapolate1(intSeq)
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
lines := strings.Split(input, "\r\n")
|
||||
total := 0
|
||||
for _, line := range lines {
|
||||
var intSeq []int
|
||||
seq := strings.Split(line, " ")
|
||||
for _, i := range seq {
|
||||
num, _ := strconv.Atoi(i)
|
||||
intSeq = append(intSeq, num)
|
||||
}
|
||||
total += extrapolate2(intSeq)
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func extrapolate1(array []int) int {
|
||||
allZeros := true
|
||||
for _, x := range array {
|
||||
if x != 0 {
|
||||
allZeros = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if allZeros {
|
||||
return 0
|
||||
}
|
||||
|
||||
deltas := make([]int, len(array)-1)
|
||||
for i := 0; i < len(array)-1; i++ {
|
||||
deltas[i] = array[i+1] - array[i]
|
||||
}
|
||||
|
||||
diff := extrapolate1(deltas)
|
||||
return array[len(array)-1] + diff
|
||||
}
|
||||
|
||||
func extrapolate2(array []int) int {
|
||||
allZeros := true
|
||||
for _, x := range array {
|
||||
if x != 0 {
|
||||
allZeros = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if allZeros {
|
||||
return 0
|
||||
}
|
||||
|
||||
deltas := make([]int, len(array)-1)
|
||||
for i := 0; i < len(array)-1; i++ {
|
||||
deltas[i] = array[i+1] - array[i]
|
||||
}
|
||||
|
||||
diff := extrapolate2(deltas)
|
||||
return array[0] - diff
|
||||
}
|
||||
18
2023/gareth/day09/day09_test.go
Normal file
18
2023/gareth/day09/day09_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`0 3 6 9 12 15
|
||||
1 3 6 10 15 21
|
||||
10 13 16 21 30 45`)
|
||||
assert.Equal(t, 114, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`10 13 16 21 30 45`)
|
||||
assert.Equal(t, 5, r)
|
||||
}
|
||||
200
2023/gareth/day09/input.txt
Normal file
200
2023/gareth/day09/input.txt
Normal file
@@ -0,0 +1,200 @@
|
||||
-7 4 41 121 272 539 997 1790 3238 6096 12113 25120 52964 110690 225447 443645 840883 1535008 2702137 4594155 7553340
|
||||
4 6 15 32 56 97 215 608 1782 4848 12001 27235 57322 113013 210281 371191 623616 998482 1522475 2203130 3001892
|
||||
1 14 30 60 127 259 482 812 1241 1708 2047 1924 854 -1364 -2779 6693 61773 262974 871468 2514024 6601925
|
||||
6 11 22 52 122 270 570 1162 2299 4438 8451 16122 31239 61800 124158 250420 501360 989250 1920158 3677323 6993968
|
||||
5 7 20 59 158 375 798 1567 2933 5377 9809 17858 32248 57231 99015 166082 269237 421163 635178 922797 1289594
|
||||
0 -3 -6 -7 1 43 201 703 2093 5515 13138 28727 58310 110773 197987 333665 529470 785825 1073258 1297757 1240279
|
||||
4 16 31 51 77 110 165 305 716 1872 4881 12159 28649 63886 135307 273317 528748 983488 1765211 3067307 5175293
|
||||
28 42 56 70 84 98 112 126 140 154 168 182 196 210 224 238 252 266 280 294 308
|
||||
14 30 55 105 221 486 1057 2232 4581 9179 17987 34432 64237 116546 205378 351432 584260 944840 1488635 2289343 3443761
|
||||
11 22 37 68 148 338 743 1559 3190 6514 13460 28214 59658 126174 264919 549437 1122545 2256574 4461315 8672808 16575204
|
||||
13 16 35 83 171 318 572 1047 1989 3900 7783 15648 31591 64129 131249 271201 565159 1183779 2480632 5175309 10704255
|
||||
-7 -11 -2 41 146 354 734 1409 2595 4667 8313 14965 27979 55581 117567 259445 580783 1290395 2812622 5992175 12490570
|
||||
8 7 5 17 83 276 712 1579 3222 6366 12646 25770 53931 114643 244277 516741 1079964 2226889 4532683 9117139 18139459
|
||||
25 41 76 150 290 533 930 1551 2491 3877 5876 8704 12636 18017 25274 34929 47613 64081 85228 112106 145942
|
||||
21 50 90 137 187 236 280 315 337 342 326 285 215 112 -28 -209 -435 -710 -1038 -1423 -1869
|
||||
14 22 37 55 73 93 126 196 344 632 1147 2005 3355 5383 8316 12426 18034 25514 35297 47875 63805
|
||||
9 11 21 58 153 364 817 1783 3810 7966 16336 33094 66812 135287 275234 560945 1138767 2288413 4528199 8789922 16701011
|
||||
8 14 35 91 217 469 946 1850 3620 7208 14641 30168 62576 129773 267707 547650 1110014 2231708 4462709 8905935 17791177
|
||||
8 19 38 65 93 119 179 422 1244 3509 8890 20369 42941 84573 157475 279746 477464 787295 1259702 1962841 2987237
|
||||
10 29 55 97 174 315 559 955 1562 2449 3695 5389 7630 10527 14199 18775 24394 31205 39367 49049 60430
|
||||
11 21 37 74 173 415 947 2045 4251 8633 17229 33748 64613 120443 218083 383303 654299 1086141 1756325 2771598 4276237
|
||||
3 13 33 63 103 153 213 283 363 453 553 663 783 913 1053 1203 1363 1533 1713 1903 2103
|
||||
7 9 17 31 51 77 109 147 191 241 297 359 427 501 581 667 759 857 961 1071 1187
|
||||
-8 -2 22 78 200 459 982 1972 3727 6652 11253 18096 27698 40263 55025 68607 71081 37078 -92913 -449054 -1297721
|
||||
8 0 -16 -37 -45 8 222 774 1952 4228 8438 16189 30679 58196 110656 209648 392576 721624 1296420 2271439 3879363
|
||||
15 32 68 131 226 355 517 708 921 1146 1370 1577 1748 1861 1891 1810 1587 1188 576 -289 -1450
|
||||
25 48 89 168 324 622 1160 2076 3555 5836 9219 14072 20838 30042 42298 58316 78909 105000 137629 177960 227288
|
||||
6 6 14 56 182 492 1191 2686 5741 11717 22951 43393 79771 143892 257421 462023 840872 1563564 2977624 5789534 11411748
|
||||
6 24 58 127 264 524 1003 1871 3422 6144 10812 18607 31264 51252 81989 128095 195686 292712 429342 618399 875848
|
||||
2 15 35 78 172 354 662 1121 1734 2511 3615 5798 11471 27026 67417 164495 381118 833495 1724359 3389070 6355154
|
||||
10 12 13 25 76 226 607 1493 3403 7237 14442 27202 48643 83041 136018 214708 327872 485938 700939 986319 1356574
|
||||
12 23 47 90 151 215 256 260 283 567 1743 5149 13278 30341 62878 120271 214902 361551 575439 868084 1239849
|
||||
10 15 30 57 98 155 230 325 442 583 750 945 1170 1427 1718 2045 2410 2815 3262 3753 4290
|
||||
11 26 41 56 71 86 101 116 131 146 161 176 191 206 221 236 251 266 281 296 311
|
||||
22 35 46 66 130 306 709 1536 3152 6272 12307 23995 46562 89916 172870 331321 634164 1214667 2333799 4511553 8805034
|
||||
25 46 79 133 222 366 592 935 1439 2158 3157 4513 6316 8670 11694 15523 20309 26222 33451 42205 52714
|
||||
17 20 21 20 17 12 5 -4 -15 -28 -43 -60 -79 -100 -123 -148 -175 -204 -235 -268 -303
|
||||
18 43 75 114 167 264 488 1019 2192 4569 9025 16848 29853 50510 82086 128801 195998 290327 419943 594718 826467
|
||||
3 12 29 49 67 78 77 59 19 -48 -147 -283 -461 -686 -963 -1297 -1693 -2156 -2691 -3303 -3997
|
||||
16 18 27 47 82 147 282 565 1119 2107 3705 6042 9124 12866 17606 25912 47070 106096 258775 611721 1339290
|
||||
0 3 17 65 177 391 757 1349 2311 4001 7367 14814 32041 71732 160796 354586 765302 1619811 3378481 6978415 14323381
|
||||
23 29 34 55 137 371 930 2143 4633 9552 18955 36367 67613 122002 213983 365425 608715 990919 1579312 2468655 3790681
|
||||
6 8 22 63 148 303 570 1007 1680 2669 4163 6831 12899 28894 72134 185261 467246 1136558 2654320 5954663 12859322
|
||||
15 23 43 94 209 457 978 2031 4055 7743 14129 24688 41449 67121 105232 160281 237903 345047 490167 683426 936913
|
||||
14 17 28 69 186 475 1114 2398 4773 8864 15506 25842 41681 66560 108425 185762 340856 667587 1368500 2869679 6046748
|
||||
9 13 32 92 233 526 1101 2190 4207 7929 14928 28560 56075 112810 230009 468630 942605 1856477 3564216 6658388 12101797
|
||||
9 20 37 61 93 143 246 494 1109 2617 6263 14965 35372 81983 184799 402632 845125 1708254 3331901 6296837 11597563
|
||||
26 35 45 75 156 332 675 1333 2643 5374 11232 23881 50947 107835 224792 459621 919968 1801397 3450831 6469735 11878094
|
||||
3 10 43 115 234 409 680 1189 2311 4863 10404 21640 42995 81600 149492 269125 487274 909039 1778256 3662348 7866979
|
||||
8 20 47 109 238 481 909 1642 2922 5313 10206 20999 45662 101954 227416 497518 1057100 2172642 4316065 8294857 15448502
|
||||
1 10 38 105 244 505 971 1807 3383 6558 13298 27941 59630 126725 264391 537055 1058045 2019482 3736406 6710193 11717576
|
||||
17 26 30 30 35 64 155 385 898 1933 3850 7189 12904 23157 43537 88430 192703 435132 982422 2167632 4623809
|
||||
12 18 34 66 122 222 413 804 1647 3502 7554 16231 34465 72352 150787 313173 648982 1339442 2742866 5548392 11043844
|
||||
8 8 5 12 63 230 654 1597 3536 7347 14661 28505 54356 101720 186285 332571 576796 969382 1576129 2476582 3757505
|
||||
-5 -3 13 58 155 341 677 1275 2366 4439 8494 16494 32207 62865 122579 239562 471597 939109 1894851 3867122 7944923
|
||||
0 8 27 71 168 365 731 1353 2328 3768 5854 9010 14356 24821 47806 101363 228022 524654 1205019 2727507 6050558
|
||||
5 1 7 46 164 442 1021 2158 4338 8483 16338 31194 59248 112115 211301 395803 734375 1344297 2418557 4262978 7343672
|
||||
6 18 51 113 214 364 571 846 1227 1840 3022 5539 10941 22106 44036 84980 157972 282886 489125 819077 1332488
|
||||
12 26 57 112 209 387 728 1412 2833 5815 11999 24548 49473 98181 192388 373478 719926 1378780 2620661 4932488 9168229
|
||||
-4 -8 -4 25 106 281 627 1306 2657 5334 10477 19879 36097 62487 103290 164264 255098 396164 634330 1075909 1949772
|
||||
11 29 51 76 110 173 301 545 985 1804 3505 7403 16584 37594 83203 176682 358135 693543 1287303 2299182 3966754
|
||||
-1 8 25 54 103 181 295 447 631 830 1013 1132 1119 883 307 -755 -2481 -5084 -8815 -13966 -20873
|
||||
-3 9 36 78 135 207 294 396 513 645 792 954 1131 1323 1530 1752 1989 2241 2508 2790 3087
|
||||
6 18 35 62 114 237 541 1254 2830 6190 13265 28193 59904 127628 272524 582022 1240250 2631130 5545775 11591944 23985770
|
||||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
||||
-2 -4 0 24 102 305 773 1775 3825 7912 15953 31656 62091 120417 230408 433667 800720 1447548 2559550 4425440 7484172
|
||||
8 19 44 98 215 467 1013 2188 4632 9456 18458 34449 61841 107806 184569 313801 534712 918433 1592800 2783964 4884691
|
||||
6 17 29 36 46 111 369 1090 2711 5832 11127 19108 29680 41463 50964 51899 35344 -8001 -81243 -166928 -199578
|
||||
7 15 48 123 261 492 860 1428 2298 3688 6163 11232 22755 50057 114512 262985 594501 1311829 2818870 5900153 12043773
|
||||
7 19 37 61 88 107 85 -64 -539 -1757 -4523 -10289 -21530 -42269 -78787 -140558 -241453 -401261 -647579 -1018127 -1563548
|
||||
3 11 19 27 35 43 51 59 67 75 83 91 99 107 115 123 131 139 147 155 163
|
||||
23 38 55 74 95 118 143 170 199 230 263 298 335 374 415 458 503 550 599 650 703
|
||||
0 4 15 38 81 153 262 413 606 834 1081 1320 1511 1599 1512 1159 428 -816 -2733 -5510 -9363
|
||||
5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15
|
||||
10 39 84 155 274 478 822 1382 2258 3577 5496 8205 11930 16936 23530 32064 42938 56603 73564 94383 119682
|
||||
14 20 28 36 55 125 339 893 2188 5020 10925 22836 46429 93014 185790 373104 755626 1539976 3140634 6366800 12753827
|
||||
7 11 23 61 149 317 601 1043 1691 2599 3827 5441 7513 10121 13349 17287 22031 27683 34351 42149 51197
|
||||
2 17 46 106 224 434 774 1278 1968 2879 4203 6734 12972 29564 72323 176014 412622 924173 1979684 4070866 8068272
|
||||
3 19 61 140 272 488 855 1511 2716 4924 8888 15821 27651 47427 79956 132778 217617 352481 564623 894618 1401858
|
||||
28 46 83 153 270 448 701 1043 1488 2050 2743 3581 4578 5748 7105 8663 10436 12438 14683 17185 19958
|
||||
2 -1 -4 -7 -10 -13 -16 -19 -22 -25 -28 -31 -34 -37 -40 -43 -46 -49 -52 -55 -58
|
||||
12 23 35 45 59 111 289 776 1940 4546 10215 22320 47587 98760 198793 387149 728916 1327593 2342555 4012375 6685363
|
||||
23 42 73 123 204 331 522 809 1270 2089 3642 6606 12140 22383 42006 82571 173309 385056 879027 1999545 4440608
|
||||
13 11 13 39 126 334 753 1514 2825 5096 9307 17950 37204 81576 183196 409485 895339 1899903 3904777 7783021 15092756
|
||||
-1 1 15 62 176 404 806 1455 2437 3851 5809 8436 11870 16262 21776 28589 36891 46885 58787 72826 89244
|
||||
16 27 40 63 118 253 558 1186 2373 4439 7735 12479 18397 24053 25715 15562 -21010 -109277 -290622 -629929 -1225416
|
||||
2 8 26 60 114 192 298 436 610 824 1082 1388 1746 2160 2634 3172 3778 4456 5210 6044 6962
|
||||
19 35 66 119 208 362 632 1115 2035 3961 8310 18388 41372 91838 197700 409748 816363 1565447 2896138 5183485 8999936
|
||||
20 44 88 168 310 553 949 1564 2501 4003 6763 12686 26541 59248 134022 297320 637610 1316534 2619234 5033652 9372744
|
||||
1 6 14 28 51 86 136 204 293 406 546 716 919 1158 1436 1756 2121 2534 2998 3516 4091
|
||||
1 12 27 53 120 288 653 1358 2617 4765 8374 14557 25775 47872 94901 199977 438633 977178 2169229 4741565 10139210
|
||||
24 32 47 84 172 371 797 1657 3309 6394 12158 23227 45369 91245 187908 390970 810062 1652628 3296417 6405494 12110442
|
||||
11 14 16 24 66 218 659 1783 4410 10145 21935 44885 87454 163330 294692 518407 898389 1550768 2695670 4764470 8622594
|
||||
9 22 64 155 318 581 991 1660 2882 5392 10886 22999 49091 103521 213787 432294 859071 1685202 3274052 6308883 12052900
|
||||
11 22 61 139 269 469 766 1217 1981 3506 6956 15133 34422 78851 178515 396967 866882 1862445 3944187 8243845 17014712
|
||||
5 14 21 30 66 185 494 1205 2759 6078 13050 27461 56833 116134 235288 474105 951045 1896610 3748735 7317076 14056480
|
||||
0 13 42 88 152 235 338 462 608 777 970 1188 1432 1703 2002 2330 2688 3077 3498 3952 4440
|
||||
4 5 17 61 185 476 1077 2214 4246 7775 13913 24927 45702 86816 170589 342437 691652 1389193 2756793 5394389 10415995
|
||||
17 28 46 87 182 384 785 1549 2967 5540 10096 17947 31092 52472 86283 138353 216589 331500 496802 730111 1053730
|
||||
30 46 68 112 202 378 724 1425 2862 5754 11356 21722 40042 71062 121596 201139 322590 503094 765012 1137028 1655402
|
||||
-2 -5 -1 29 122 346 831 1837 3895 8087 16574 33537 66765 130206 247892 459757 829988 1458683 2497737 4172037 6807220
|
||||
22 30 48 100 224 484 1003 2030 4054 7978 15366 28776 52192 91568 155497 256018 409574 638134 970492 1443756 2105040
|
||||
-3 1 8 15 32 105 360 1085 2877 6912 15476 33065 68676 140436 284532 571605 1135461 2221251 4263312 8006787 14692112
|
||||
16 35 69 120 206 377 733 1441 2752 5039 8932 15755 28740 56011 117280 257930 577399 1284978 2808078 6000729 12542125
|
||||
9 11 16 23 32 44 61 86 123 177 254 361 506 698 947 1264 1661 2151 2748 3467 4324
|
||||
10 20 45 95 185 345 634 1150 2034 3495 5961 10628 20989 46454 110042 263558 616093 1385974 2994218 6232675 12569356
|
||||
18 21 29 50 105 254 633 1501 3300 6733 12875 23374 40911 70322 121207 213541 388854 731069 1403201 2708962 5192037
|
||||
18 31 61 122 227 388 616 921 1312 1797 2383 3076 3881 4802 5842 7003 8286 9691 11217 12862 14623
|
||||
22 32 42 52 62 72 82 92 102 112 122 132 142 152 162 172 182 192 202 212 222
|
||||
10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110
|
||||
13 35 67 117 209 391 754 1466 2823 5317 9719 17173 29295 48269 76930 118822 178217 260079 369955 513773 697525
|
||||
27 46 79 149 296 592 1171 2285 4407 8413 15894 29699 54946 101071 186214 346693 656995 1270352 2497601 4954049 9822324
|
||||
-1 -2 2 24 92 255 600 1292 2661 5391 10921 22252 45487 92676 187042 372712 733159 1426452 2752264 5277040 10062018
|
||||
-2 -1 12 46 113 243 525 1193 2777 6335 13779 28333 55290 103646 190259 350659 665941 1325896 2769231 5980153 13089536
|
||||
-5 -1 19 69 165 325 569 919 1399 2035 2855 3889 5169 6729 8605 10835 13459 16519 20059 24125 28765
|
||||
1 8 23 58 129 260 491 886 1546 2663 4726 9145 19852 46961 114464 275419 640455 1429106 3059073 6296772 12504459
|
||||
17 43 85 154 278 518 996 1940 3751 7100 13085 23550 41841 74642 136289 258494 511481 1048509 2196953 4639266 9761996
|
||||
-5 4 34 97 205 370 604 919 1327 1840 2470 3229 4129 5182 6400 7795 9379 11164 13162 15385 17845
|
||||
0 9 43 131 316 657 1241 2215 3848 6632 11441 19819 34620 61568 112979 216077 430288 880923 1821151 3740587 7547740
|
||||
19 24 24 14 -16 -77 -168 -234 -49 1067 4867 15440 41669 101882 232566 504784 1055569 2148985 4296498 8496059 16707712
|
||||
-8 -6 -1 10 52 199 615 1618 3782 8105 16310 31454 59290 111441 212726 417455 843996 1744600 3640017 7568110 15525464
|
||||
19 44 93 182 342 632 1152 2056 3565 5980 9695 15210 23144 34248 49418 69708 96343 130732 174481 229406 297546
|
||||
19 38 77 161 332 651 1208 2154 3780 6702 12281 23525 46897 95699 196026 396694 785049 1511166 2823653 5121089 9024050
|
||||
12 21 42 99 242 568 1261 2675 5508 11149 22322 44199 86206 164800 307549 558899 988060 1699485 2846450 4648267 7411674
|
||||
9 6 -1 -12 -27 -46 -69 -96 -127 -162 -201 -244 -291 -342 -397 -456 -519 -586 -657 -732 -811
|
||||
4 17 46 97 187 346 618 1062 1756 2822 4539 7728 14826 32484 77244 187121 444340 1019516 2258574 4857886 10224905
|
||||
16 28 53 106 220 446 858 1582 2880 5334 10202 20079 40118 80285 159515 313419 608938 1173390 2254517 4347786 8466922
|
||||
13 39 72 115 176 270 435 781 1598 3551 7996 17490 36711 74412 148044 294951 598739 1248527 2665452 5759825 12430770
|
||||
17 40 82 157 280 477 813 1453 2779 5596 11487 23454 47176 93667 185129 367997 741815 1522010 3173022 6682697 14110922
|
||||
9 15 32 67 119 172 180 36 -472 -1693 -4079 -7987 -13117 -17108 -12104 23526 144519 481823 1333954 3351191 7890107
|
||||
17 20 38 90 210 468 1016 2185 4670 9865 20460 41494 82172 158891 300079 553708 999019 1765994 3071478 5293702 9134802
|
||||
5 -2 1 39 161 454 1057 2175 4093 7190 11953 18991 29049 43022 61969 87127 119925 161998 215201 281623 363601
|
||||
19 34 55 90 154 265 440 691 1021 1420 1861 2296 2652 2827 2686 2057 727 -1562 -5117 -10298 -17522
|
||||
20 32 47 78 159 354 776 1628 3289 6499 12757 25149 50002 100097 200860 402401 803348 1598842 3178136 6323201 12609933
|
||||
-5 -2 7 17 28 52 124 332 904 2438 6443 16482 40377 94154 208674 440213 886617 1711062 3175887 5689431 9869282
|
||||
13 35 75 150 302 610 1210 2331 4355 7909 13997 24180 40812 67340 108676 171649 265545 402743 599455 876578 1260666
|
||||
16 32 67 132 241 427 769 1429 2700 5078 9406 17211 31482 58341 110406 213347 418786 830753 1662681 3364365 6907349
|
||||
18 26 36 46 51 47 36 29 53 199 812 3032 10058 29736 79378 194113 440564 938248 1891820 3638138 6713125
|
||||
11 37 82 154 274 493 916 1747 3393 6701 13458 27389 56109 114947 234469 475196 955891 1906493 3764126 7341668 14114472
|
||||
16 40 80 148 273 523 1036 2055 3961 7311 12936 22266 38262 67694 126062 247275 501350 1024946 2071592 4091096 7850935
|
||||
25 38 48 56 71 123 283 692 1616 3565 7532 15408 30585 58638 107764 188412 311503 485392 714412 1008488 1427223
|
||||
14 19 39 103 268 642 1425 2988 6036 11947 23455 45965 89980 175446 339407 649438 1227274 2290475 4225743 7716883 13965076
|
||||
5 11 28 66 140 276 526 997 1899 3617 6812 12556 22506 39122 65934 107863 171601 266055 402860 596966 867304
|
||||
8 13 31 81 208 495 1080 2181 4132 7434 12821 21329 34356 53787 82604 127367 206280 371838 768806 1774285 4323634
|
||||
9 18 35 71 145 291 576 1137 2256 4519 9166 18861 39330 82676 173737 361669 740083 1480624 2886941 5478659 10118335
|
||||
21 31 45 64 100 195 458 1132 2718 6217 13614 28847 59736 121792 245640 491198 974063 1913167 3714191 7111094 13399192
|
||||
1 12 32 58 95 164 317 674 1509 3439 7816 17487 38177 80909 166261 332305 650790 1262667 2458657 4861265 9826204
|
||||
14 27 54 100 181 331 619 1195 2388 4893 10124 20898 42785 86778 174547 348728 692995 1370992 2701051 5297233 10329738
|
||||
-3 -8 -8 12 79 249 642 1504 3310 6928 13866 26611 49032 86770 147540 241478 382379 592396 916292 1457810 2461765
|
||||
15 31 60 102 157 225 306 400 507 627 760 906 1065 1237 1422 1620 1831 2055 2292 2542 2805
|
||||
10 23 51 110 230 460 877 1614 2941 5463 10551 21211 43741 90750 186443 375543 737860 1411367 2627747 4765780 8429696
|
||||
3 18 49 97 163 248 353 479 627 798 993 1213 1459 1732 2033 2363 2723 3114 3537 3993 4483
|
||||
6 15 28 43 60 83 127 248 635 1836 5238 13997 34750 80693 177053 370696 746640 1455529 2757432 5088111 9153132
|
||||
23 32 32 16 -28 -120 -291 -586 -1067 -1816 -2938 -4564 -6854 -10000 -14229 -19806 -27037 -36272 -47908 -62392 -80224
|
||||
14 39 73 108 148 223 407 847 1824 3904 8313 17801 38467 83342 179071 378052 780510 1575696 3122007 6109179 11895198
|
||||
22 47 93 176 322 583 1064 1956 3578 6459 11554 20802 38412 73511 145101 290630 579846 1135911 2165915 4002828 7160406
|
||||
7 16 39 76 127 192 271 364 471 592 727 876 1039 1216 1407 1612 1831 2064 2311 2572 2847
|
||||
2 12 42 105 217 391 629 912 1188 1358 1260 651 -813 -3599 -8321 -15766 -26922 -43008 -65506 -96195 -137187
|
||||
0 -3 -1 28 114 290 587 1029 1628 2379 3255 4202 5134 5928 6419 6395 5592 3689 303 -5016 -12790
|
||||
18 36 75 147 271 480 842 1511 2833 5551 11204 22950 47369 98511 206849 438313 932832 1978762 4151057 8560981 17302215
|
||||
10 3 -9 -17 8 121 408 1003 2153 4414 9142 19562 42850 93831 201048 416043 826640 1574737 2878477 5057525 8558344
|
||||
16 30 45 63 93 155 282 521 934 1598 2608 4126 6650 12007 26282 67260 181392 479382 1206027 2869985 6474071
|
||||
19 30 48 86 161 293 509 851 1382 2182 3348 5091 8201 15476 35234 88799 224921 545498 1248748 2698152 5528061
|
||||
20 39 73 127 212 360 646 1215 2312 4313 7755 13363 22072 35042 53664 79555 114540 160619 219917 294615 386860
|
||||
11 12 23 64 171 417 939 1972 3911 7453 13909 25812 47978 89232 165192 303042 550551 994426 1798527 3282128 6074521
|
||||
26 40 53 68 95 155 286 551 1048 1922 3379 5702 9269 14573 22244 33073 48038 68332 95393 130936 176987
|
||||
12 23 45 75 110 147 183 215 240 255 257 243 210 155 75 -33 -172 -345 -555 -805 -1098
|
||||
3 19 52 108 193 319 525 920 1764 3637 7828 17238 38379 85534 188923 409940 868373 1789219 3580508 6958696 13144865
|
||||
17 33 47 55 61 97 270 860 2510 6575 15736 35042 73634 147592 284807 533920 981975 1790865 3273077 6045893 11334635
|
||||
15 44 84 131 181 230 274 309 331 336 320 279 209 106 -34 -215 -441 -716 -1044 -1429 -1875
|
||||
6 27 67 134 236 381 577 832 1154 1551 2031 2602 3272 4049 4941 5956 7102 8387 9819 11406 13156
|
||||
29 47 79 131 212 342 560 932 1559 2585 4205 6673 10310 15512 22758 32618 45761 62963 85115 113231 148456
|
||||
-9 -7 10 57 168 408 882 1734 3136 5286 8465 13246 21003 34935 61899 115437 220485 420367 786804 1433807 2536474
|
||||
8 13 43 123 295 625 1210 2185 3730 6077 9517 14407 21177 30337 42484 58309 78604 104269 136319 175891 224251
|
||||
14 21 37 71 138 259 460 786 1367 2600 5550 12739 29624 67357 148080 315462 656254 1344845 2734927 5545487 11231700
|
||||
6 16 35 76 161 319 589 1030 1740 2886 4747 7772 12655 20429 32581 51190 79090 120060 179043 262396 378173
|
||||
25 36 45 64 130 321 779 1754 3702 7500 14889 29333 57614 112746 219398 424500 819260 1586873 3107330 6185019 12529795
|
||||
7 6 2 -5 -15 -28 -44 -63 -85 -110 -138 -169 -203 -240 -280 -323 -369 -418 -470 -525 -583
|
||||
14 23 35 62 125 254 488 875 1472 2345 3569 5228 7415 10232 13790 18209 23618 30155 37967 47210 58049
|
||||
11 23 29 28 38 109 347 976 2491 6006 14004 31900 71212 155816 333902 700066 1434747 2872297 5614783 10716676 19976490
|
||||
13 13 16 25 40 69 149 377 951 2221 4750 9385 17338 30277 50427 80681 124721 187149 273628 391033 547612
|
||||
24 37 60 109 210 404 760 1411 2641 5071 10033 20303 41509 84771 171547 342454 673451 1306066 2504783 4766554 9027925
|
||||
7 28 58 104 184 327 573 973 1589 2494 3772 5518 7838 10849 14679 19467 25363 32528 41134 51364 63412
|
||||
2 9 15 18 16 7 -11 -40 -82 -139 -213 -306 -420 -557 -719 -908 -1126 -1375 -1657 -1974 -2328
|
||||
-2 -8 -22 -36 -30 32 216 659 1677 4012 9338 21221 46842 99962 205876 409585 789396 1480256 2715538 4904886 8782742
|
||||
3 10 27 73 182 407 824 1536 2677 4416 6961 10563 15520 22181 30950 42290 56727 74854 97335 124909 158394
|
||||
10 19 44 102 227 482 972 1856 3356 5774 9577 15730 26695 48929 98377 211450 465398 1013941 2146626 4383766 8623131
|
||||
10 31 72 149 284 512 899 1586 2882 5437 10534 20547 39620 74630 136505 241976 415850 693899 1126468 1782913 2756988
|
||||
11 33 74 146 273 497 898 1641 3074 5923 11677 23368 47206 96055 196723 404751 833173 1706029 3453804 6877118 13417719
|
||||
8 21 58 132 265 504 939 1721 3091 5469 9726 17876 34585 70136 145929 304513 628138 1274073 2543782 5020872 9847569
|
||||
-4 -8 -14 -25 -37 -22 109 583 1910 5132 12220 26671 54365 104750 192431 339247 576928 950432 1522070 2376535 3626959
|
||||
18 38 82 173 347 653 1153 1922 3048 4632 6788 9643 13337 18023 23867 31048 39758 50202 62598 77177 94183
|
||||
15 28 47 91 191 388 741 1353 2420 4300 7589 13199 22512 37951 64995 118188 236764 521302 1213228 2857007 6615220
|
||||
14 21 37 81 183 388 760 1386 2380 3887 6087 9199 13485 19254 26866 36736 49338 65209 84953 109245 138835
|
||||
16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168 176
|
||||
3 8 23 61 141 288 533 913 1471 2256 3323 4733 6553 8856 11721 15233 19483 24568 30591 37661 45893
|
||||
14 30 57 99 167 295 569 1169 2424 4880 9381 17163 29961 50129 80773 125897 190562 281058 405089 571971 792843
|
||||
-6 -7 -10 -4 37 154 403 855 1596 2727 4364 6638 9695 13696 18817 25249 33198 42885 54546 68432 84809
|
||||
1 6 25 68 141 255 458 900 1941 4312 9339 19240 37505 69369 122388 207128 337977 534090 820477 1229244 1800997
|
||||
17 27 53 113 230 432 752 1228 1903 2825 4047 5627 7628 10118 13170 16862 21277 26503 32633 39765 48002
|
||||
18
2023/gareth/template/day09.go
Normal file
18
2023/gareth/template/day09.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
fmt.Println(line)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
return -2
|
||||
}
|
||||
25
2023/gareth/template/day09_test.go
Normal file
25
2023/gareth/template/day09_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`AAA = (BBB, BBB)
|
||||
BBB = (AAA, ZZZ)
|
||||
ZZZ = (ZZZ, ZZZ)`)
|
||||
assert.Equal(t, 6, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`11A = (11B, XXX)
|
||||
11B = (XXX, 11Z)
|
||||
11Z = (11B, XXX)
|
||||
22A = (22B, XXX)
|
||||
22B = (22C, 22C)
|
||||
22C = (22Z, 22Z)
|
||||
22Z = (22B, 22B)
|
||||
XXX = (XXX, XXX)`)
|
||||
assert.Equal(t, 6, r)
|
||||
}
|
||||
200
2023/gareth/template/input.txt
Normal file
200
2023/gareth/template/input.txt
Normal file
@@ -0,0 +1,200 @@
|
||||
-7 4 41 121 272 539 997 1790 3238 6096 12113 25120 52964 110690 225447 443645 840883 1535008 2702137 4594155 7553340
|
||||
4 6 15 32 56 97 215 608 1782 4848 12001 27235 57322 113013 210281 371191 623616 998482 1522475 2203130 3001892
|
||||
1 14 30 60 127 259 482 812 1241 1708 2047 1924 854 -1364 -2779 6693 61773 262974 871468 2514024 6601925
|
||||
6 11 22 52 122 270 570 1162 2299 4438 8451 16122 31239 61800 124158 250420 501360 989250 1920158 3677323 6993968
|
||||
5 7 20 59 158 375 798 1567 2933 5377 9809 17858 32248 57231 99015 166082 269237 421163 635178 922797 1289594
|
||||
0 -3 -6 -7 1 43 201 703 2093 5515 13138 28727 58310 110773 197987 333665 529470 785825 1073258 1297757 1240279
|
||||
4 16 31 51 77 110 165 305 716 1872 4881 12159 28649 63886 135307 273317 528748 983488 1765211 3067307 5175293
|
||||
28 42 56 70 84 98 112 126 140 154 168 182 196 210 224 238 252 266 280 294 308
|
||||
14 30 55 105 221 486 1057 2232 4581 9179 17987 34432 64237 116546 205378 351432 584260 944840 1488635 2289343 3443761
|
||||
11 22 37 68 148 338 743 1559 3190 6514 13460 28214 59658 126174 264919 549437 1122545 2256574 4461315 8672808 16575204
|
||||
13 16 35 83 171 318 572 1047 1989 3900 7783 15648 31591 64129 131249 271201 565159 1183779 2480632 5175309 10704255
|
||||
-7 -11 -2 41 146 354 734 1409 2595 4667 8313 14965 27979 55581 117567 259445 580783 1290395 2812622 5992175 12490570
|
||||
8 7 5 17 83 276 712 1579 3222 6366 12646 25770 53931 114643 244277 516741 1079964 2226889 4532683 9117139 18139459
|
||||
25 41 76 150 290 533 930 1551 2491 3877 5876 8704 12636 18017 25274 34929 47613 64081 85228 112106 145942
|
||||
21 50 90 137 187 236 280 315 337 342 326 285 215 112 -28 -209 -435 -710 -1038 -1423 -1869
|
||||
14 22 37 55 73 93 126 196 344 632 1147 2005 3355 5383 8316 12426 18034 25514 35297 47875 63805
|
||||
9 11 21 58 153 364 817 1783 3810 7966 16336 33094 66812 135287 275234 560945 1138767 2288413 4528199 8789922 16701011
|
||||
8 14 35 91 217 469 946 1850 3620 7208 14641 30168 62576 129773 267707 547650 1110014 2231708 4462709 8905935 17791177
|
||||
8 19 38 65 93 119 179 422 1244 3509 8890 20369 42941 84573 157475 279746 477464 787295 1259702 1962841 2987237
|
||||
10 29 55 97 174 315 559 955 1562 2449 3695 5389 7630 10527 14199 18775 24394 31205 39367 49049 60430
|
||||
11 21 37 74 173 415 947 2045 4251 8633 17229 33748 64613 120443 218083 383303 654299 1086141 1756325 2771598 4276237
|
||||
3 13 33 63 103 153 213 283 363 453 553 663 783 913 1053 1203 1363 1533 1713 1903 2103
|
||||
7 9 17 31 51 77 109 147 191 241 297 359 427 501 581 667 759 857 961 1071 1187
|
||||
-8 -2 22 78 200 459 982 1972 3727 6652 11253 18096 27698 40263 55025 68607 71081 37078 -92913 -449054 -1297721
|
||||
8 0 -16 -37 -45 8 222 774 1952 4228 8438 16189 30679 58196 110656 209648 392576 721624 1296420 2271439 3879363
|
||||
15 32 68 131 226 355 517 708 921 1146 1370 1577 1748 1861 1891 1810 1587 1188 576 -289 -1450
|
||||
25 48 89 168 324 622 1160 2076 3555 5836 9219 14072 20838 30042 42298 58316 78909 105000 137629 177960 227288
|
||||
6 6 14 56 182 492 1191 2686 5741 11717 22951 43393 79771 143892 257421 462023 840872 1563564 2977624 5789534 11411748
|
||||
6 24 58 127 264 524 1003 1871 3422 6144 10812 18607 31264 51252 81989 128095 195686 292712 429342 618399 875848
|
||||
2 15 35 78 172 354 662 1121 1734 2511 3615 5798 11471 27026 67417 164495 381118 833495 1724359 3389070 6355154
|
||||
10 12 13 25 76 226 607 1493 3403 7237 14442 27202 48643 83041 136018 214708 327872 485938 700939 986319 1356574
|
||||
12 23 47 90 151 215 256 260 283 567 1743 5149 13278 30341 62878 120271 214902 361551 575439 868084 1239849
|
||||
10 15 30 57 98 155 230 325 442 583 750 945 1170 1427 1718 2045 2410 2815 3262 3753 4290
|
||||
11 26 41 56 71 86 101 116 131 146 161 176 191 206 221 236 251 266 281 296 311
|
||||
22 35 46 66 130 306 709 1536 3152 6272 12307 23995 46562 89916 172870 331321 634164 1214667 2333799 4511553 8805034
|
||||
25 46 79 133 222 366 592 935 1439 2158 3157 4513 6316 8670 11694 15523 20309 26222 33451 42205 52714
|
||||
17 20 21 20 17 12 5 -4 -15 -28 -43 -60 -79 -100 -123 -148 -175 -204 -235 -268 -303
|
||||
18 43 75 114 167 264 488 1019 2192 4569 9025 16848 29853 50510 82086 128801 195998 290327 419943 594718 826467
|
||||
3 12 29 49 67 78 77 59 19 -48 -147 -283 -461 -686 -963 -1297 -1693 -2156 -2691 -3303 -3997
|
||||
16 18 27 47 82 147 282 565 1119 2107 3705 6042 9124 12866 17606 25912 47070 106096 258775 611721 1339290
|
||||
0 3 17 65 177 391 757 1349 2311 4001 7367 14814 32041 71732 160796 354586 765302 1619811 3378481 6978415 14323381
|
||||
23 29 34 55 137 371 930 2143 4633 9552 18955 36367 67613 122002 213983 365425 608715 990919 1579312 2468655 3790681
|
||||
6 8 22 63 148 303 570 1007 1680 2669 4163 6831 12899 28894 72134 185261 467246 1136558 2654320 5954663 12859322
|
||||
15 23 43 94 209 457 978 2031 4055 7743 14129 24688 41449 67121 105232 160281 237903 345047 490167 683426 936913
|
||||
14 17 28 69 186 475 1114 2398 4773 8864 15506 25842 41681 66560 108425 185762 340856 667587 1368500 2869679 6046748
|
||||
9 13 32 92 233 526 1101 2190 4207 7929 14928 28560 56075 112810 230009 468630 942605 1856477 3564216 6658388 12101797
|
||||
9 20 37 61 93 143 246 494 1109 2617 6263 14965 35372 81983 184799 402632 845125 1708254 3331901 6296837 11597563
|
||||
26 35 45 75 156 332 675 1333 2643 5374 11232 23881 50947 107835 224792 459621 919968 1801397 3450831 6469735 11878094
|
||||
3 10 43 115 234 409 680 1189 2311 4863 10404 21640 42995 81600 149492 269125 487274 909039 1778256 3662348 7866979
|
||||
8 20 47 109 238 481 909 1642 2922 5313 10206 20999 45662 101954 227416 497518 1057100 2172642 4316065 8294857 15448502
|
||||
1 10 38 105 244 505 971 1807 3383 6558 13298 27941 59630 126725 264391 537055 1058045 2019482 3736406 6710193 11717576
|
||||
17 26 30 30 35 64 155 385 898 1933 3850 7189 12904 23157 43537 88430 192703 435132 982422 2167632 4623809
|
||||
12 18 34 66 122 222 413 804 1647 3502 7554 16231 34465 72352 150787 313173 648982 1339442 2742866 5548392 11043844
|
||||
8 8 5 12 63 230 654 1597 3536 7347 14661 28505 54356 101720 186285 332571 576796 969382 1576129 2476582 3757505
|
||||
-5 -3 13 58 155 341 677 1275 2366 4439 8494 16494 32207 62865 122579 239562 471597 939109 1894851 3867122 7944923
|
||||
0 8 27 71 168 365 731 1353 2328 3768 5854 9010 14356 24821 47806 101363 228022 524654 1205019 2727507 6050558
|
||||
5 1 7 46 164 442 1021 2158 4338 8483 16338 31194 59248 112115 211301 395803 734375 1344297 2418557 4262978 7343672
|
||||
6 18 51 113 214 364 571 846 1227 1840 3022 5539 10941 22106 44036 84980 157972 282886 489125 819077 1332488
|
||||
12 26 57 112 209 387 728 1412 2833 5815 11999 24548 49473 98181 192388 373478 719926 1378780 2620661 4932488 9168229
|
||||
-4 -8 -4 25 106 281 627 1306 2657 5334 10477 19879 36097 62487 103290 164264 255098 396164 634330 1075909 1949772
|
||||
11 29 51 76 110 173 301 545 985 1804 3505 7403 16584 37594 83203 176682 358135 693543 1287303 2299182 3966754
|
||||
-1 8 25 54 103 181 295 447 631 830 1013 1132 1119 883 307 -755 -2481 -5084 -8815 -13966 -20873
|
||||
-3 9 36 78 135 207 294 396 513 645 792 954 1131 1323 1530 1752 1989 2241 2508 2790 3087
|
||||
6 18 35 62 114 237 541 1254 2830 6190 13265 28193 59904 127628 272524 582022 1240250 2631130 5545775 11591944 23985770
|
||||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
||||
-2 -4 0 24 102 305 773 1775 3825 7912 15953 31656 62091 120417 230408 433667 800720 1447548 2559550 4425440 7484172
|
||||
8 19 44 98 215 467 1013 2188 4632 9456 18458 34449 61841 107806 184569 313801 534712 918433 1592800 2783964 4884691
|
||||
6 17 29 36 46 111 369 1090 2711 5832 11127 19108 29680 41463 50964 51899 35344 -8001 -81243 -166928 -199578
|
||||
7 15 48 123 261 492 860 1428 2298 3688 6163 11232 22755 50057 114512 262985 594501 1311829 2818870 5900153 12043773
|
||||
7 19 37 61 88 107 85 -64 -539 -1757 -4523 -10289 -21530 -42269 -78787 -140558 -241453 -401261 -647579 -1018127 -1563548
|
||||
3 11 19 27 35 43 51 59 67 75 83 91 99 107 115 123 131 139 147 155 163
|
||||
23 38 55 74 95 118 143 170 199 230 263 298 335 374 415 458 503 550 599 650 703
|
||||
0 4 15 38 81 153 262 413 606 834 1081 1320 1511 1599 1512 1159 428 -816 -2733 -5510 -9363
|
||||
5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15
|
||||
10 39 84 155 274 478 822 1382 2258 3577 5496 8205 11930 16936 23530 32064 42938 56603 73564 94383 119682
|
||||
14 20 28 36 55 125 339 893 2188 5020 10925 22836 46429 93014 185790 373104 755626 1539976 3140634 6366800 12753827
|
||||
7 11 23 61 149 317 601 1043 1691 2599 3827 5441 7513 10121 13349 17287 22031 27683 34351 42149 51197
|
||||
2 17 46 106 224 434 774 1278 1968 2879 4203 6734 12972 29564 72323 176014 412622 924173 1979684 4070866 8068272
|
||||
3 19 61 140 272 488 855 1511 2716 4924 8888 15821 27651 47427 79956 132778 217617 352481 564623 894618 1401858
|
||||
28 46 83 153 270 448 701 1043 1488 2050 2743 3581 4578 5748 7105 8663 10436 12438 14683 17185 19958
|
||||
2 -1 -4 -7 -10 -13 -16 -19 -22 -25 -28 -31 -34 -37 -40 -43 -46 -49 -52 -55 -58
|
||||
12 23 35 45 59 111 289 776 1940 4546 10215 22320 47587 98760 198793 387149 728916 1327593 2342555 4012375 6685363
|
||||
23 42 73 123 204 331 522 809 1270 2089 3642 6606 12140 22383 42006 82571 173309 385056 879027 1999545 4440608
|
||||
13 11 13 39 126 334 753 1514 2825 5096 9307 17950 37204 81576 183196 409485 895339 1899903 3904777 7783021 15092756
|
||||
-1 1 15 62 176 404 806 1455 2437 3851 5809 8436 11870 16262 21776 28589 36891 46885 58787 72826 89244
|
||||
16 27 40 63 118 253 558 1186 2373 4439 7735 12479 18397 24053 25715 15562 -21010 -109277 -290622 -629929 -1225416
|
||||
2 8 26 60 114 192 298 436 610 824 1082 1388 1746 2160 2634 3172 3778 4456 5210 6044 6962
|
||||
19 35 66 119 208 362 632 1115 2035 3961 8310 18388 41372 91838 197700 409748 816363 1565447 2896138 5183485 8999936
|
||||
20 44 88 168 310 553 949 1564 2501 4003 6763 12686 26541 59248 134022 297320 637610 1316534 2619234 5033652 9372744
|
||||
1 6 14 28 51 86 136 204 293 406 546 716 919 1158 1436 1756 2121 2534 2998 3516 4091
|
||||
1 12 27 53 120 288 653 1358 2617 4765 8374 14557 25775 47872 94901 199977 438633 977178 2169229 4741565 10139210
|
||||
24 32 47 84 172 371 797 1657 3309 6394 12158 23227 45369 91245 187908 390970 810062 1652628 3296417 6405494 12110442
|
||||
11 14 16 24 66 218 659 1783 4410 10145 21935 44885 87454 163330 294692 518407 898389 1550768 2695670 4764470 8622594
|
||||
9 22 64 155 318 581 991 1660 2882 5392 10886 22999 49091 103521 213787 432294 859071 1685202 3274052 6308883 12052900
|
||||
11 22 61 139 269 469 766 1217 1981 3506 6956 15133 34422 78851 178515 396967 866882 1862445 3944187 8243845 17014712
|
||||
5 14 21 30 66 185 494 1205 2759 6078 13050 27461 56833 116134 235288 474105 951045 1896610 3748735 7317076 14056480
|
||||
0 13 42 88 152 235 338 462 608 777 970 1188 1432 1703 2002 2330 2688 3077 3498 3952 4440
|
||||
4 5 17 61 185 476 1077 2214 4246 7775 13913 24927 45702 86816 170589 342437 691652 1389193 2756793 5394389 10415995
|
||||
17 28 46 87 182 384 785 1549 2967 5540 10096 17947 31092 52472 86283 138353 216589 331500 496802 730111 1053730
|
||||
30 46 68 112 202 378 724 1425 2862 5754 11356 21722 40042 71062 121596 201139 322590 503094 765012 1137028 1655402
|
||||
-2 -5 -1 29 122 346 831 1837 3895 8087 16574 33537 66765 130206 247892 459757 829988 1458683 2497737 4172037 6807220
|
||||
22 30 48 100 224 484 1003 2030 4054 7978 15366 28776 52192 91568 155497 256018 409574 638134 970492 1443756 2105040
|
||||
-3 1 8 15 32 105 360 1085 2877 6912 15476 33065 68676 140436 284532 571605 1135461 2221251 4263312 8006787 14692112
|
||||
16 35 69 120 206 377 733 1441 2752 5039 8932 15755 28740 56011 117280 257930 577399 1284978 2808078 6000729 12542125
|
||||
9 11 16 23 32 44 61 86 123 177 254 361 506 698 947 1264 1661 2151 2748 3467 4324
|
||||
10 20 45 95 185 345 634 1150 2034 3495 5961 10628 20989 46454 110042 263558 616093 1385974 2994218 6232675 12569356
|
||||
18 21 29 50 105 254 633 1501 3300 6733 12875 23374 40911 70322 121207 213541 388854 731069 1403201 2708962 5192037
|
||||
18 31 61 122 227 388 616 921 1312 1797 2383 3076 3881 4802 5842 7003 8286 9691 11217 12862 14623
|
||||
22 32 42 52 62 72 82 92 102 112 122 132 142 152 162 172 182 192 202 212 222
|
||||
10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110
|
||||
13 35 67 117 209 391 754 1466 2823 5317 9719 17173 29295 48269 76930 118822 178217 260079 369955 513773 697525
|
||||
27 46 79 149 296 592 1171 2285 4407 8413 15894 29699 54946 101071 186214 346693 656995 1270352 2497601 4954049 9822324
|
||||
-1 -2 2 24 92 255 600 1292 2661 5391 10921 22252 45487 92676 187042 372712 733159 1426452 2752264 5277040 10062018
|
||||
-2 -1 12 46 113 243 525 1193 2777 6335 13779 28333 55290 103646 190259 350659 665941 1325896 2769231 5980153 13089536
|
||||
-5 -1 19 69 165 325 569 919 1399 2035 2855 3889 5169 6729 8605 10835 13459 16519 20059 24125 28765
|
||||
1 8 23 58 129 260 491 886 1546 2663 4726 9145 19852 46961 114464 275419 640455 1429106 3059073 6296772 12504459
|
||||
17 43 85 154 278 518 996 1940 3751 7100 13085 23550 41841 74642 136289 258494 511481 1048509 2196953 4639266 9761996
|
||||
-5 4 34 97 205 370 604 919 1327 1840 2470 3229 4129 5182 6400 7795 9379 11164 13162 15385 17845
|
||||
0 9 43 131 316 657 1241 2215 3848 6632 11441 19819 34620 61568 112979 216077 430288 880923 1821151 3740587 7547740
|
||||
19 24 24 14 -16 -77 -168 -234 -49 1067 4867 15440 41669 101882 232566 504784 1055569 2148985 4296498 8496059 16707712
|
||||
-8 -6 -1 10 52 199 615 1618 3782 8105 16310 31454 59290 111441 212726 417455 843996 1744600 3640017 7568110 15525464
|
||||
19 44 93 182 342 632 1152 2056 3565 5980 9695 15210 23144 34248 49418 69708 96343 130732 174481 229406 297546
|
||||
19 38 77 161 332 651 1208 2154 3780 6702 12281 23525 46897 95699 196026 396694 785049 1511166 2823653 5121089 9024050
|
||||
12 21 42 99 242 568 1261 2675 5508 11149 22322 44199 86206 164800 307549 558899 988060 1699485 2846450 4648267 7411674
|
||||
9 6 -1 -12 -27 -46 -69 -96 -127 -162 -201 -244 -291 -342 -397 -456 -519 -586 -657 -732 -811
|
||||
4 17 46 97 187 346 618 1062 1756 2822 4539 7728 14826 32484 77244 187121 444340 1019516 2258574 4857886 10224905
|
||||
16 28 53 106 220 446 858 1582 2880 5334 10202 20079 40118 80285 159515 313419 608938 1173390 2254517 4347786 8466922
|
||||
13 39 72 115 176 270 435 781 1598 3551 7996 17490 36711 74412 148044 294951 598739 1248527 2665452 5759825 12430770
|
||||
17 40 82 157 280 477 813 1453 2779 5596 11487 23454 47176 93667 185129 367997 741815 1522010 3173022 6682697 14110922
|
||||
9 15 32 67 119 172 180 36 -472 -1693 -4079 -7987 -13117 -17108 -12104 23526 144519 481823 1333954 3351191 7890107
|
||||
17 20 38 90 210 468 1016 2185 4670 9865 20460 41494 82172 158891 300079 553708 999019 1765994 3071478 5293702 9134802
|
||||
5 -2 1 39 161 454 1057 2175 4093 7190 11953 18991 29049 43022 61969 87127 119925 161998 215201 281623 363601
|
||||
19 34 55 90 154 265 440 691 1021 1420 1861 2296 2652 2827 2686 2057 727 -1562 -5117 -10298 -17522
|
||||
20 32 47 78 159 354 776 1628 3289 6499 12757 25149 50002 100097 200860 402401 803348 1598842 3178136 6323201 12609933
|
||||
-5 -2 7 17 28 52 124 332 904 2438 6443 16482 40377 94154 208674 440213 886617 1711062 3175887 5689431 9869282
|
||||
13 35 75 150 302 610 1210 2331 4355 7909 13997 24180 40812 67340 108676 171649 265545 402743 599455 876578 1260666
|
||||
16 32 67 132 241 427 769 1429 2700 5078 9406 17211 31482 58341 110406 213347 418786 830753 1662681 3364365 6907349
|
||||
18 26 36 46 51 47 36 29 53 199 812 3032 10058 29736 79378 194113 440564 938248 1891820 3638138 6713125
|
||||
11 37 82 154 274 493 916 1747 3393 6701 13458 27389 56109 114947 234469 475196 955891 1906493 3764126 7341668 14114472
|
||||
16 40 80 148 273 523 1036 2055 3961 7311 12936 22266 38262 67694 126062 247275 501350 1024946 2071592 4091096 7850935
|
||||
25 38 48 56 71 123 283 692 1616 3565 7532 15408 30585 58638 107764 188412 311503 485392 714412 1008488 1427223
|
||||
14 19 39 103 268 642 1425 2988 6036 11947 23455 45965 89980 175446 339407 649438 1227274 2290475 4225743 7716883 13965076
|
||||
5 11 28 66 140 276 526 997 1899 3617 6812 12556 22506 39122 65934 107863 171601 266055 402860 596966 867304
|
||||
8 13 31 81 208 495 1080 2181 4132 7434 12821 21329 34356 53787 82604 127367 206280 371838 768806 1774285 4323634
|
||||
9 18 35 71 145 291 576 1137 2256 4519 9166 18861 39330 82676 173737 361669 740083 1480624 2886941 5478659 10118335
|
||||
21 31 45 64 100 195 458 1132 2718 6217 13614 28847 59736 121792 245640 491198 974063 1913167 3714191 7111094 13399192
|
||||
1 12 32 58 95 164 317 674 1509 3439 7816 17487 38177 80909 166261 332305 650790 1262667 2458657 4861265 9826204
|
||||
14 27 54 100 181 331 619 1195 2388 4893 10124 20898 42785 86778 174547 348728 692995 1370992 2701051 5297233 10329738
|
||||
-3 -8 -8 12 79 249 642 1504 3310 6928 13866 26611 49032 86770 147540 241478 382379 592396 916292 1457810 2461765
|
||||
15 31 60 102 157 225 306 400 507 627 760 906 1065 1237 1422 1620 1831 2055 2292 2542 2805
|
||||
10 23 51 110 230 460 877 1614 2941 5463 10551 21211 43741 90750 186443 375543 737860 1411367 2627747 4765780 8429696
|
||||
3 18 49 97 163 248 353 479 627 798 993 1213 1459 1732 2033 2363 2723 3114 3537 3993 4483
|
||||
6 15 28 43 60 83 127 248 635 1836 5238 13997 34750 80693 177053 370696 746640 1455529 2757432 5088111 9153132
|
||||
23 32 32 16 -28 -120 -291 -586 -1067 -1816 -2938 -4564 -6854 -10000 -14229 -19806 -27037 -36272 -47908 -62392 -80224
|
||||
14 39 73 108 148 223 407 847 1824 3904 8313 17801 38467 83342 179071 378052 780510 1575696 3122007 6109179 11895198
|
||||
22 47 93 176 322 583 1064 1956 3578 6459 11554 20802 38412 73511 145101 290630 579846 1135911 2165915 4002828 7160406
|
||||
7 16 39 76 127 192 271 364 471 592 727 876 1039 1216 1407 1612 1831 2064 2311 2572 2847
|
||||
2 12 42 105 217 391 629 912 1188 1358 1260 651 -813 -3599 -8321 -15766 -26922 -43008 -65506 -96195 -137187
|
||||
0 -3 -1 28 114 290 587 1029 1628 2379 3255 4202 5134 5928 6419 6395 5592 3689 303 -5016 -12790
|
||||
18 36 75 147 271 480 842 1511 2833 5551 11204 22950 47369 98511 206849 438313 932832 1978762 4151057 8560981 17302215
|
||||
10 3 -9 -17 8 121 408 1003 2153 4414 9142 19562 42850 93831 201048 416043 826640 1574737 2878477 5057525 8558344
|
||||
16 30 45 63 93 155 282 521 934 1598 2608 4126 6650 12007 26282 67260 181392 479382 1206027 2869985 6474071
|
||||
19 30 48 86 161 293 509 851 1382 2182 3348 5091 8201 15476 35234 88799 224921 545498 1248748 2698152 5528061
|
||||
20 39 73 127 212 360 646 1215 2312 4313 7755 13363 22072 35042 53664 79555 114540 160619 219917 294615 386860
|
||||
11 12 23 64 171 417 939 1972 3911 7453 13909 25812 47978 89232 165192 303042 550551 994426 1798527 3282128 6074521
|
||||
26 40 53 68 95 155 286 551 1048 1922 3379 5702 9269 14573 22244 33073 48038 68332 95393 130936 176987
|
||||
12 23 45 75 110 147 183 215 240 255 257 243 210 155 75 -33 -172 -345 -555 -805 -1098
|
||||
3 19 52 108 193 319 525 920 1764 3637 7828 17238 38379 85534 188923 409940 868373 1789219 3580508 6958696 13144865
|
||||
17 33 47 55 61 97 270 860 2510 6575 15736 35042 73634 147592 284807 533920 981975 1790865 3273077 6045893 11334635
|
||||
15 44 84 131 181 230 274 309 331 336 320 279 209 106 -34 -215 -441 -716 -1044 -1429 -1875
|
||||
6 27 67 134 236 381 577 832 1154 1551 2031 2602 3272 4049 4941 5956 7102 8387 9819 11406 13156
|
||||
29 47 79 131 212 342 560 932 1559 2585 4205 6673 10310 15512 22758 32618 45761 62963 85115 113231 148456
|
||||
-9 -7 10 57 168 408 882 1734 3136 5286 8465 13246 21003 34935 61899 115437 220485 420367 786804 1433807 2536474
|
||||
8 13 43 123 295 625 1210 2185 3730 6077 9517 14407 21177 30337 42484 58309 78604 104269 136319 175891 224251
|
||||
14 21 37 71 138 259 460 786 1367 2600 5550 12739 29624 67357 148080 315462 656254 1344845 2734927 5545487 11231700
|
||||
6 16 35 76 161 319 589 1030 1740 2886 4747 7772 12655 20429 32581 51190 79090 120060 179043 262396 378173
|
||||
25 36 45 64 130 321 779 1754 3702 7500 14889 29333 57614 112746 219398 424500 819260 1586873 3107330 6185019 12529795
|
||||
7 6 2 -5 -15 -28 -44 -63 -85 -110 -138 -169 -203 -240 -280 -323 -369 -418 -470 -525 -583
|
||||
14 23 35 62 125 254 488 875 1472 2345 3569 5228 7415 10232 13790 18209 23618 30155 37967 47210 58049
|
||||
11 23 29 28 38 109 347 976 2491 6006 14004 31900 71212 155816 333902 700066 1434747 2872297 5614783 10716676 19976490
|
||||
13 13 16 25 40 69 149 377 951 2221 4750 9385 17338 30277 50427 80681 124721 187149 273628 391033 547612
|
||||
24 37 60 109 210 404 760 1411 2641 5071 10033 20303 41509 84771 171547 342454 673451 1306066 2504783 4766554 9027925
|
||||
7 28 58 104 184 327 573 973 1589 2494 3772 5518 7838 10849 14679 19467 25363 32528 41134 51364 63412
|
||||
2 9 15 18 16 7 -11 -40 -82 -139 -213 -306 -420 -557 -719 -908 -1126 -1375 -1657 -1974 -2328
|
||||
-2 -8 -22 -36 -30 32 216 659 1677 4012 9338 21221 46842 99962 205876 409585 789396 1480256 2715538 4904886 8782742
|
||||
3 10 27 73 182 407 824 1536 2677 4416 6961 10563 15520 22181 30950 42290 56727 74854 97335 124909 158394
|
||||
10 19 44 102 227 482 972 1856 3356 5774 9577 15730 26695 48929 98377 211450 465398 1013941 2146626 4383766 8623131
|
||||
10 31 72 149 284 512 899 1586 2882 5437 10534 20547 39620 74630 136505 241976 415850 693899 1126468 1782913 2756988
|
||||
11 33 74 146 273 497 898 1641 3074 5923 11677 23368 47206 96055 196723 404751 833173 1706029 3453804 6877118 13417719
|
||||
8 21 58 132 265 504 939 1721 3091 5469 9726 17876 34585 70136 145929 304513 628138 1274073 2543782 5020872 9847569
|
||||
-4 -8 -14 -25 -37 -22 109 583 1910 5132 12220 26671 54365 104750 192431 339247 576928 950432 1522070 2376535 3626959
|
||||
18 38 82 173 347 653 1153 1922 3048 4632 6788 9643 13337 18023 23867 31048 39758 50202 62598 77177 94183
|
||||
15 28 47 91 191 388 741 1353 2420 4300 7589 13199 22512 37951 64995 118188 236764 521302 1213228 2857007 6615220
|
||||
14 21 37 81 183 388 760 1386 2380 3887 6087 9199 13485 19254 26866 36736 49338 65209 84953 109245 138835
|
||||
16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168 176
|
||||
3 8 23 61 141 288 533 913 1471 2256 3323 4733 6553 8856 11721 15233 19483 24568 30591 37661 45893
|
||||
14 30 57 99 167 295 569 1169 2424 4880 9381 17163 29961 50129 80773 125897 190562 281058 405089 571971 792843
|
||||
-6 -7 -10 -4 37 154 403 855 1596 2727 4364 6638 9695 13696 18817 25249 33198 42885 54546 68432 84809
|
||||
1 6 25 68 141 255 458 900 1941 4312 9339 19240 37505 69369 122388 207128 337977 534090 820477 1229244 1800997
|
||||
17 27 53 113 230 432 752 1228 1903 2825 4047 5627 7628 10118 13170 16862 21277 26503 32633 39765 48002
|
||||
@@ -1,74 +1,74 @@
|
||||
package grid2d
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"adventofcode2022/utils"
|
||||
)
|
||||
|
||||
type Grid[T any] struct {
|
||||
sizeX, sizeY int
|
||||
matrix [][]T
|
||||
empty T
|
||||
}
|
||||
|
||||
func NewGrid[T any](sizeX, sizeY int, empty T) *Grid[T] {
|
||||
matrix := make([][]T, sizeY)
|
||||
rows := make([]T, sizeX*sizeY)
|
||||
for i := 0; i < sizeX*sizeY; i++ {
|
||||
rows[i] = empty
|
||||
}
|
||||
|
||||
j := 0
|
||||
for i := 0; i < sizeY; i++ {
|
||||
matrix[i] = rows[j : j+sizeX : j+sizeX]
|
||||
j += sizeX
|
||||
}
|
||||
return &Grid[T]{
|
||||
sizeX: sizeX,
|
||||
sizeY: sizeY,
|
||||
matrix: matrix,
|
||||
empty: empty,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Grid[T]) SizeX() int {
|
||||
return g.sizeX
|
||||
}
|
||||
|
||||
func (g *Grid[T]) SizeY() int {
|
||||
return g.sizeY
|
||||
}
|
||||
|
||||
func (g *Grid[T]) Get(x, y int) T {
|
||||
if x < 0 || x >= g.sizeX {
|
||||
return g.empty
|
||||
}
|
||||
if y < 0 || y >= g.sizeY {
|
||||
return g.empty
|
||||
}
|
||||
return g.matrix[y][x]
|
||||
}
|
||||
|
||||
func (g *Grid[T]) Set(x, y int, v T) {
|
||||
if x < 0 || x >= g.sizeX {
|
||||
panic("invalid x")
|
||||
}
|
||||
if y < 0 || y >= g.sizeY {
|
||||
panic("invalid y")
|
||||
}
|
||||
g.matrix[y][x] = v
|
||||
}
|
||||
|
||||
func (g *Grid[T]) StringWithFormatter(formatter func(T, int, int) string) string {
|
||||
var r strings.Builder
|
||||
for j := 0; j < g.sizeY; j++ {
|
||||
for i := 0; i < g.sizeX; i++ {
|
||||
_, err := r.WriteString(formatter(g.matrix[j][i], i, j))
|
||||
utils.PanicOnErr(err)
|
||||
}
|
||||
_, err := r.WriteRune('\n')
|
||||
utils.PanicOnErr(err)
|
||||
}
|
||||
return r.String()
|
||||
}
|
||||
package grid2d
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"awesomeProject/utils"
|
||||
)
|
||||
|
||||
type Grid[T any] struct {
|
||||
sizeX, sizeY int
|
||||
matrix [][]T
|
||||
empty T
|
||||
}
|
||||
|
||||
func NewGrid[T any](sizeX, sizeY int, empty T) *Grid[T] {
|
||||
matrix := make([][]T, sizeY)
|
||||
rows := make([]T, sizeX*sizeY)
|
||||
for i := 0; i < sizeX*sizeY; i++ {
|
||||
rows[i] = empty
|
||||
}
|
||||
|
||||
j := 0
|
||||
for i := 0; i < sizeY; i++ {
|
||||
matrix[i] = rows[j : j+sizeX : j+sizeX]
|
||||
j += sizeX
|
||||
}
|
||||
return &Grid[T]{
|
||||
sizeX: sizeX,
|
||||
sizeY: sizeY,
|
||||
matrix: matrix,
|
||||
empty: empty,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Grid[T]) SizeX() int {
|
||||
return g.sizeX
|
||||
}
|
||||
|
||||
func (g *Grid[T]) SizeY() int {
|
||||
return g.sizeY
|
||||
}
|
||||
|
||||
func (g *Grid[T]) Get(x, y int) T {
|
||||
if x < 0 || x >= g.sizeX {
|
||||
return g.empty
|
||||
}
|
||||
if y < 0 || y >= g.sizeY {
|
||||
return g.empty
|
||||
}
|
||||
return g.matrix[y][x]
|
||||
}
|
||||
|
||||
func (g *Grid[T]) Set(x, y int, v T) {
|
||||
if x < 0 || x >= g.sizeX {
|
||||
panic("invalid x")
|
||||
}
|
||||
if y < 0 || y >= g.sizeY {
|
||||
panic("invalid y")
|
||||
}
|
||||
g.matrix[y][x] = v
|
||||
}
|
||||
|
||||
func (g *Grid[T]) StringWithFormatter(formatter func(T, int, int) string) string {
|
||||
var r strings.Builder
|
||||
for j := 0; j < g.sizeY; j++ {
|
||||
for i := 0; i < g.sizeX; i++ {
|
||||
_, err := r.WriteString(formatter(g.matrix[j][i], i, j))
|
||||
utils.PanicOnErr(err)
|
||||
}
|
||||
_, err := r.WriteRune('\n')
|
||||
utils.PanicOnErr(err)
|
||||
}
|
||||
return r.String()
|
||||
}
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
package inputs
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"adventofcode2022/utils"
|
||||
"adventofcode2022/utils/grid2d"
|
||||
sparsegrid "adventofcode2022/utils/sparseGrid"
|
||||
)
|
||||
|
||||
func ToInts(input string, sep string) []int {
|
||||
var r []int
|
||||
for _, line := range strings.Split(input, sep) {
|
||||
if line != "" {
|
||||
r = append(r, utils.MustAtoi(line))
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func ToGrid2D[T any](input, rowSep, colSep string, empty T, conv func(string) T) *grid2d.Grid[T] {
|
||||
lines := strings.Split(input, rowSep)
|
||||
|
||||
grid := grid2d.NewGrid(len(lines[0]), len(lines), empty)
|
||||
for y, line := range lines {
|
||||
for x, v := range strings.Split(line, colSep) {
|
||||
grid.Set(x, y, conv(v))
|
||||
}
|
||||
}
|
||||
|
||||
return grid
|
||||
}
|
||||
|
||||
func ToSparseGrid[T comparable](input, rowSep, colSep string, empty T, conv func(string) T) *sparsegrid.SparseGrid[T] {
|
||||
lines := strings.Split(input, rowSep)
|
||||
|
||||
grid := sparsegrid.NewGrid(empty)
|
||||
for y, line := range lines {
|
||||
for x, v := range strings.Split(line, colSep) {
|
||||
grid.Set(x, y, conv(v))
|
||||
}
|
||||
}
|
||||
|
||||
return grid
|
||||
}
|
||||
package inputs
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"awesomeProject/utils"
|
||||
"awesomeProject/utils/grid2d"
|
||||
sparsegrid "awesomeProject/utils/sparseGrid"
|
||||
)
|
||||
|
||||
func ToInts(input string, sep string) []int {
|
||||
var r []int
|
||||
for _, line := range strings.Split(input, sep) {
|
||||
if line != "" {
|
||||
r = append(r, utils.MustAtoi(line))
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func ToGrid2D[T any](input, rowSep, colSep string, empty T, conv func(string) T) *grid2d.Grid[T] {
|
||||
lines := strings.Split(input, rowSep)
|
||||
|
||||
grid := grid2d.NewGrid(len(lines[0]), len(lines), empty)
|
||||
for y, line := range lines {
|
||||
for x, v := range strings.Split(line, colSep) {
|
||||
grid.Set(x, y, conv(v))
|
||||
}
|
||||
}
|
||||
|
||||
return grid
|
||||
}
|
||||
|
||||
func ToSparseGrid[T comparable](input, rowSep, colSep string, empty T, conv func(string) T) *sparsegrid.SparseGrid[T] {
|
||||
lines := strings.Split(input, rowSep)
|
||||
|
||||
grid := sparsegrid.NewGrid(empty)
|
||||
for y, line := range lines {
|
||||
for x, v := range strings.Split(line, colSep) {
|
||||
grid.Set(x, y, conv(v))
|
||||
}
|
||||
}
|
||||
|
||||
return grid
|
||||
}
|
||||
|
||||
16
2023/go/.vscode/launch.json
vendored
Normal file
16
2023/go/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"args": ["16"],
|
||||
"program": "${fileDirname}"
|
||||
}
|
||||
]
|
||||
}
|
||||
101
2023/go/day08/day08.go
Normal file
101
2023/go/day08/day08.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
_ "adventofcode2023/utils"
|
||||
"regexp"
|
||||
"strings"
|
||||
"math"
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
left string
|
||||
right string
|
||||
}
|
||||
|
||||
type Network map[string]Node
|
||||
|
||||
func Part1(input string) int {
|
||||
instructions, network := parseInput(input)
|
||||
return getSteps("AAA", instructions, network, true)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
instructions, nexts, network := parseInput2(input)
|
||||
fmt.Println(nexts)
|
||||
ans := 1
|
||||
for _, next := range nexts {
|
||||
ans = lcm(ans, getSteps(next, instructions, network, false))
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
// gcd calculates the greatest common divisor using Euclid's algorithm
|
||||
func gcd(a, b int) int {
|
||||
for b != 0 {
|
||||
a, b = b, a%b
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// lcm calculates the least common multiple using the formula: LCM(a, b) = |a * b| / GCD(a, b)
|
||||
func lcm(a, b int) int {
|
||||
if a == 0 || b == 0 {
|
||||
return 0
|
||||
}
|
||||
return int(math.Abs(float64(a*b)) / float64(gcd(a, b)))
|
||||
}
|
||||
|
||||
func parseInput(input string) ([]rune, Network) {
|
||||
network := make(Network)
|
||||
lines := strings.Split(input, "\n")
|
||||
instructions := []rune(lines[0])
|
||||
re := regexp.MustCompile(`(\w+) = \((\w+), (\w+)\)`)
|
||||
|
||||
for _, line := range lines[2:] {
|
||||
matches := re.FindAllStringSubmatch(line, -1)
|
||||
network[matches[0][1]] = Node{matches[0][2], matches[0][3]}
|
||||
}
|
||||
return instructions, network
|
||||
}
|
||||
|
||||
func parseInput2(input string) ([]rune, []string, Network) {
|
||||
network := make(Network)
|
||||
lines := strings.Split(input, "\n")
|
||||
start := []string{}
|
||||
instructions := []rune(lines[0])
|
||||
re := regexp.MustCompile(`(\w+) = \((\w+), (\w+)\)`)
|
||||
|
||||
for _, line := range lines[2:] {
|
||||
matches := re.FindAllStringSubmatch(line, -1)
|
||||
network[matches[0][1]] = Node{matches[0][2], matches[0][3]}
|
||||
if matches[0][1][2] == 'A' {
|
||||
start = append(start, matches[0][1])
|
||||
}
|
||||
}
|
||||
return instructions, start, network
|
||||
}
|
||||
|
||||
func getSteps(next string, instructions []rune, network Network, partOne bool) int{
|
||||
steps := 0
|
||||
for {
|
||||
for _, ins := range instructions {
|
||||
steps++
|
||||
if ins == 'L' {
|
||||
next = network[next].left
|
||||
} else {
|
||||
next = network[next].right
|
||||
}
|
||||
if partOne {
|
||||
if next == "ZZZ" {
|
||||
return steps
|
||||
}
|
||||
} else {
|
||||
if next[2] == 'Z' {
|
||||
fmt.Println(next)
|
||||
return steps
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
2023/go/day08/day08_test.go
Normal file
32
2023/go/day08/day08_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`LLR
|
||||
|
||||
AAA = (BBB, BBB)
|
||||
BBB = (AAA, ZZZ)
|
||||
ZZZ = (ZZZ, ZZZ)`)
|
||||
require.Equal(t, 6, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`LR
|
||||
|
||||
11A = (11B, XXX)
|
||||
11B = (XXX, 11Z)
|
||||
11Z = (11B, XXX)
|
||||
22A = (22B, XXX)
|
||||
22B = (22C, 22C)
|
||||
22C = (22Z, 22Z)
|
||||
22Z = (22B, 22B)
|
||||
XXX = (XXX, XXX)`)
|
||||
require.Equal(t, 6, r)
|
||||
}
|
||||
704
2023/go/day08/input.txt
Normal file
704
2023/go/day08/input.txt
Normal file
@@ -0,0 +1,704 @@
|
||||
LRRRLRRRLRRLRRLRLRRLRRLRRRLRRLRRRLRRRLLRRRLRRRLRRRLRLRRLRRRLRLRRRLRRRLLRLRLRRLRRLLLRRLRRLRRRLLRRRLLRRRLRLRRRLRRRLLRRLRLLRLRRRLRRLRRLRLRLRLRLRLRRRLRLRRRLLRLRRLRRRLRRRLRLRRLRLLLRLRLRLRLRLRRRLLRRLRLRLLRRRLRRLRRRLRRLRRLRRRLLRRLRLRRLRRRLRRLRLRRLRLLRRLLRLRRRLRRLRLLRRRR
|
||||
|
||||
RHQ = (QNL, HDC)
|
||||
FVH = (LMX, SDD)
|
||||
MCR = (THP, XKJ)
|
||||
RFJ = (TVQ, HGJ)
|
||||
MLK = (KKF, MMK)
|
||||
JDL = (XXQ, BFT)
|
||||
KXN = (HFS, XFM)
|
||||
NJP = (MSB, PBD)
|
||||
KDR = (VFC, SBM)
|
||||
RKR = (MBK, RFS)
|
||||
RJB = (PQK, FHB)
|
||||
XTL = (LMG, LMF)
|
||||
QDD = (KFF, JSD)
|
||||
CFP = (VBK, XNS)
|
||||
BQX = (FFP, SKX)
|
||||
NSJ = (HNC, MLQ)
|
||||
KQQ = (LTG, TNH)
|
||||
KVN = (SSJ, LNK)
|
||||
QCT = (FQQ, LLX)
|
||||
LBB = (VMQ, THT)
|
||||
DPQ = (PGL, GTC)
|
||||
RTH = (QNQ, CMS)
|
||||
QLS = (NFV, FKX)
|
||||
FST = (DNQ, QJQ)
|
||||
MHX = (LFT, JDL)
|
||||
JLF = (CCF, JNJ)
|
||||
TQJ = (VVT, TBV)
|
||||
HSC = (LKR, GTS)
|
||||
GHV = (NFS, RNT)
|
||||
VBK = (CPT, MBX)
|
||||
HVV = (CFH, QGR)
|
||||
JMG = (LXR, NHP)
|
||||
DDJ = (LNK, SSJ)
|
||||
NKV = (HLG, TCT)
|
||||
QBG = (FHB, PQK)
|
||||
FKH = (DDS, JLK)
|
||||
TLF = (VKH, QLQ)
|
||||
NTR = (MLL, GKH)
|
||||
KFF = (MDN, HCD)
|
||||
NPF = (FCP, VLM)
|
||||
PKP = (HXS, KGH)
|
||||
DVV = (TDH, XKB)
|
||||
SNM = (BJN, SGS)
|
||||
JVC = (PKX, CGR)
|
||||
VLB = (RDM, VBP)
|
||||
RQQ = (KQQ, HHB)
|
||||
SHH = (RRP, CSQ)
|
||||
DPN = (HLR, LCK)
|
||||
MCT = (BQG, SMV)
|
||||
FNJ = (QML, TVP)
|
||||
RGK = (CTF, KTS)
|
||||
HNC = (VPX, PPR)
|
||||
JLG = (THT, VMQ)
|
||||
RJJ = (PLT, TFH)
|
||||
VRK = (CMS, QNQ)
|
||||
JGJ = (JLF, RFM)
|
||||
RMD = (BVV, XTG)
|
||||
MBB = (QTQ, MCH)
|
||||
KDN = (LMF, LMG)
|
||||
SPR = (KHB, BPG)
|
||||
TFN = (CTT, JGH)
|
||||
LXR = (VTV, GRD)
|
||||
MPX = (LSD, RDD)
|
||||
SDN = (FLL, XSG)
|
||||
RMR = (TMB, NKV)
|
||||
FJM = (STG, DLM)
|
||||
HKK = (VPV, HFQ)
|
||||
GQG = (JDL, LFT)
|
||||
SQM = (CJM, HSN)
|
||||
BFM = (LKX, LKX)
|
||||
KMH = (NDL, GNG)
|
||||
THT = (DXV, PHQ)
|
||||
XHT = (FXG, PVN)
|
||||
JCJ = (BVJ, FKM)
|
||||
MBX = (CKQ, CST)
|
||||
XPJ = (QHB, RKH)
|
||||
NLL = (KXP, RXV)
|
||||
VJD = (MBK, RFS)
|
||||
SGS = (QQB, DMG)
|
||||
FBS = (PQH, MCR)
|
||||
XFT = (FHC, PKJ)
|
||||
LXS = (GCR, FVL)
|
||||
CPC = (KFS, RTM)
|
||||
PKX = (CND, KFP)
|
||||
TKK = (XBR, NTR)
|
||||
NTJ = (QCQ, MJQ)
|
||||
DVC = (TPP, FBS)
|
||||
NVC = (DPN, CNF)
|
||||
CFG = (TRX, VFS)
|
||||
SDQ = (KMH, GFG)
|
||||
GNG = (RLH, FKJ)
|
||||
TXL = (XNP, XHF)
|
||||
FKM = (STF, BDQ)
|
||||
DDN = (NKG, CFP)
|
||||
KMB = (NKG, CFP)
|
||||
VQD = (TQJ, VGS)
|
||||
DBX = (BGX, SSX)
|
||||
QTX = (QCX, MSS)
|
||||
VMN = (SDQ, DFD)
|
||||
MJQ = (GGM, XSR)
|
||||
VGS = (TBV, VVT)
|
||||
HDC = (NNN, BNV)
|
||||
FVB = (TQS, XBQ)
|
||||
QML = (LDS, PVQ)
|
||||
GTS = (PJK, XQP)
|
||||
LLX = (QNG, RHD)
|
||||
NRG = (VFK, QHK)
|
||||
KVD = (MBB, TJD)
|
||||
FMV = (CSX, BKH)
|
||||
RDK = (NKP, JGJ)
|
||||
HFR = (DFD, SDQ)
|
||||
QLQ = (VMN, HFR)
|
||||
MVB = (JNM, DKL)
|
||||
RXQ = (MMT, DFP)
|
||||
QQP = (VFS, TRX)
|
||||
SCN = (XRD, XRD)
|
||||
SDR = (JKQ, XHC)
|
||||
VCB = (JGD, VQD)
|
||||
PPR = (KGD, DJJ)
|
||||
QVZ = (JLB, DXR)
|
||||
CMT = (JDG, CNN)
|
||||
FGX = (HRX, VLQ)
|
||||
KTS = (CPB, DMP)
|
||||
CJM = (VTX, NTJ)
|
||||
SPQ = (RGS, KKV)
|
||||
DDS = (MCT, FMS)
|
||||
LMT = (RJJ, MTR)
|
||||
NNN = (RTH, VRK)
|
||||
NHP = (GRD, VTV)
|
||||
CGX = (MMM, MJT)
|
||||
FDQ = (NHM, QTX)
|
||||
XHF = (JGM, PBC)
|
||||
QJQ = (TFJ, HKR)
|
||||
STF = (RFR, DHN)
|
||||
CVV = (LSD, RDD)
|
||||
MPR = (JVC, XMS)
|
||||
VFG = (MFV, RPC)
|
||||
DVH = (SHS, FML)
|
||||
CNF = (LCK, HLR)
|
||||
VFK = (GSH, FVB)
|
||||
HXB = (KPC, PMF)
|
||||
TRX = (VMG, LXF)
|
||||
DBP = (KQQ, HHB)
|
||||
TKQ = (RCD, RLC)
|
||||
MFT = (BNR, TFN)
|
||||
XMM = (GCR, FVL)
|
||||
DSJ = (QLS, CFJ)
|
||||
XNM = (RKJ, MGB)
|
||||
CPB = (CDM, XSL)
|
||||
BVV = (DQK, FDC)
|
||||
XVN = (VVM, NTB)
|
||||
LTB = (MBB, TJD)
|
||||
LTG = (FCK, JMG)
|
||||
JTG = (CGX, PBQ)
|
||||
MSB = (PXM, SHH)
|
||||
GHS = (XDT, RKG)
|
||||
HPN = (PMF, KPC)
|
||||
VHN = (MHX, GQG)
|
||||
PGB = (XBR, NTR)
|
||||
RHD = (NFR, XRV)
|
||||
DKL = (CDJ, MPR)
|
||||
PVN = (LSN, RRQ)
|
||||
VFC = (QXB, RTX)
|
||||
HFQ = (MCC, QVB)
|
||||
MGB = (RGN, TGP)
|
||||
JDD = (KVB, GGL)
|
||||
GRB = (FCC, GHR)
|
||||
NLC = (NJC, JJL)
|
||||
FQM = (MSB, PBD)
|
||||
VSN = (BPD, FKN)
|
||||
RFS = (GKT, TQQ)
|
||||
XSG = (RKS, RRV)
|
||||
CXS = (SHB, XDD)
|
||||
MKN = (JNQ, SDN)
|
||||
PXM = (RRP, CSQ)
|
||||
JNQ = (XSG, FLL)
|
||||
NCP = (HPV, KKX)
|
||||
NKS = (PJH, XPT)
|
||||
PGL = (VGD, VGD)
|
||||
SDD = (LRG, FRT)
|
||||
JKV = (XVS, KKR)
|
||||
LXF = (BFM, PSF)
|
||||
XBR = (GKH, MLL)
|
||||
DQK = (RSF, STP)
|
||||
QLR = (DXR, JLB)
|
||||
DQD = (LCC, XFT)
|
||||
CST = (VFG, NRV)
|
||||
SNR = (BPG, KHB)
|
||||
GKH = (BNJ, NRL)
|
||||
XTG = (FDC, DQK)
|
||||
PBC = (JFV, VHN)
|
||||
FRT = (SXR, CTX)
|
||||
TTQ = (MGB, RKJ)
|
||||
TKJ = (HHM, RTD)
|
||||
LLQ = (RNT, NFS)
|
||||
QGZ = (NQV, CCP)
|
||||
GCN = (CSX, BKH)
|
||||
SSM = (RCF, VNG)
|
||||
XRT = (DLB, BJB)
|
||||
BVJ = (STF, BDQ)
|
||||
QXM = (CSK, SDR)
|
||||
QJM = (DBP, RQQ)
|
||||
VVM = (KDD, HDN)
|
||||
CTX = (JVG, XCN)
|
||||
XCM = (KXN, KCQ)
|
||||
FDC = (RSF, STP)
|
||||
KFS = (KMF, XSS)
|
||||
RVN = (GDL, GHS)
|
||||
JXZ = (RMD, SMQ)
|
||||
SXF = (VBP, RDM)
|
||||
JCS = (RQF, QFL)
|
||||
CSX = (RXD, LSC)
|
||||
TXS = (GBQ, JHK)
|
||||
RQF = (MBC, SQM)
|
||||
QXB = (NXK, DFN)
|
||||
PKJ = (BSB, NDP)
|
||||
VMQ = (DXV, PHQ)
|
||||
HLG = (NCP, KBQ)
|
||||
CSQ = (LJP, BGN)
|
||||
MMT = (MVB, GHX)
|
||||
KXG = (XCF, HKK)
|
||||
FBH = (XFT, LCC)
|
||||
SQG = (LTB, KVD)
|
||||
VMG = (BFM, PSF)
|
||||
FFP = (SSF, QJM)
|
||||
KVF = (JCS, GMR)
|
||||
HXS = (RLR, NPQ)
|
||||
PVM = (BMM, PTQ)
|
||||
JFD = (DLB, BJB)
|
||||
FTD = (BMP, XXL)
|
||||
JLK = (FMS, MCT)
|
||||
BGN = (JTG, NCV)
|
||||
KGH = (NPQ, RLR)
|
||||
QFL = (MBC, SQM)
|
||||
XNP = (JGM, PBC)
|
||||
DHN = (SPR, SNR)
|
||||
LJP = (JTG, NCV)
|
||||
KKX = (PKP, GTB)
|
||||
KKR = (KKC, SNM)
|
||||
DBG = (LKR, GTS)
|
||||
RCN = (FQQ, LLX)
|
||||
BKH = (RXD, LSC)
|
||||
HCD = (KDR, LGD)
|
||||
KVB = (JLS, TMH)
|
||||
SPC = (SXF, VLB)
|
||||
NKG = (XNS, VBK)
|
||||
FNN = (RMB, NPF)
|
||||
QNT = (SJD, KTM)
|
||||
RXK = (NKV, TMB)
|
||||
RDF = (FCJ, FST)
|
||||
XSS = (GKK, SQG)
|
||||
LRG = (SXR, CTX)
|
||||
FMS = (SMV, BQG)
|
||||
DVA = (DXR, JLB)
|
||||
JKQ = (KTP, RDF)
|
||||
LCC = (FHC, PKJ)
|
||||
LSD = (NKS, DPC)
|
||||
HHM = (BTG, NXB)
|
||||
XBQ = (QPF, TLF)
|
||||
JNM = (MPR, CDJ)
|
||||
TCB = (KXG, PJD)
|
||||
TBV = (RXK, RMR)
|
||||
KTP = (FCJ, FST)
|
||||
HSN = (VTX, NTJ)
|
||||
GDL = (XDT, RKG)
|
||||
FCJ = (DNQ, QJQ)
|
||||
DXR = (FFT, HNQ)
|
||||
RTB = (SVP, BQX)
|
||||
HLR = (DSC, SSR)
|
||||
LVL = (QML, TVP)
|
||||
KXQ = (RJP, DVV)
|
||||
BKN = (LXS, XMM)
|
||||
JHK = (FFR, QXX)
|
||||
DLS = (MKN, PTL)
|
||||
BTD = (CCP, NQV)
|
||||
JVG = (LMT, SKC)
|
||||
FFT = (LTR, PMD)
|
||||
XDD = (KRC, JBN)
|
||||
QNL = (BNV, NNN)
|
||||
LNK = (KDN, XTL)
|
||||
CMS = (DLS, VQG)
|
||||
TJD = (MCH, QTQ)
|
||||
LHR = (HNC, MLQ)
|
||||
FKS = (MPX, CVV)
|
||||
CCP = (XFP, XHT)
|
||||
QCX = (KQL, SPQ)
|
||||
KXP = (QXM, QXM)
|
||||
HHG = (FML, SHS)
|
||||
HDS = (KTS, CTF)
|
||||
BPG = (GMQ, NDD)
|
||||
QPR = (TFG, CDF)
|
||||
QCQ = (GGM, XSR)
|
||||
DFN = (KXQ, XCV)
|
||||
KRC = (FGX, XTP)
|
||||
RLR = (DDJ, KVN)
|
||||
PVX = (TGJ, XPJ)
|
||||
SVX = (MQN, QNJ)
|
||||
VQG = (PTL, MKN)
|
||||
GTM = (CFH, QGR)
|
||||
KVJ = (JLK, DDS)
|
||||
HHB = (TNH, LTG)
|
||||
BCB = (RVN, NHB)
|
||||
XTP = (HRX, VLQ)
|
||||
DJJ = (PGT, VCM)
|
||||
JQA = (CSK, SDR)
|
||||
PSR = (GLC, DQV)
|
||||
HDN = (CPC, GCF)
|
||||
VPX = (DJJ, KGD)
|
||||
BNR = (CTT, JGH)
|
||||
QRC = (XDD, SHB)
|
||||
VRX = (XNP, XHF)
|
||||
BTG = (QNS, QDL)
|
||||
RRP = (LJP, BGN)
|
||||
PFS = (RJB, QBG)
|
||||
BSB = (LKN, SBH)
|
||||
RXD = (SHQ, RHR)
|
||||
JJL = (VCK, RTB)
|
||||
RJP = (XKB, TDH)
|
||||
RCD = (DPT, FXX)
|
||||
PHQ = (PDH, KVF)
|
||||
DDL = (JSD, KFF)
|
||||
VBP = (DDN, KMB)
|
||||
GRD = (KVJ, FKH)
|
||||
CKQ = (NRV, VFG)
|
||||
KNM = (PTQ, BMM)
|
||||
XCD = (NXG, FSP)
|
||||
LGD = (VFC, SBM)
|
||||
RTD = (NXB, BTG)
|
||||
VCK = (SVP, BQX)
|
||||
GBC = (NHB, RVN)
|
||||
STP = (MQQ, KGJ)
|
||||
NKP = (RFM, JLF)
|
||||
JBN = (XTP, FGX)
|
||||
SBS = (RGK, HDS)
|
||||
RRQ = (FDM, CSB)
|
||||
FDM = (KSX, TFM)
|
||||
NXB = (QDL, QNS)
|
||||
NHB = (GHS, GDL)
|
||||
DQV = (FNJ, LVL)
|
||||
MBC = (HSN, CJM)
|
||||
QHK = (FVB, GSH)
|
||||
MDN = (KDR, LGD)
|
||||
FCP = (PBH, RHQ)
|
||||
NRL = (DXL, KXK)
|
||||
MSS = (SPQ, KQL)
|
||||
PBD = (SHH, PXM)
|
||||
JBB = (XKD, PSR)
|
||||
TVP = (PVQ, LDS)
|
||||
DKB = (TTQ, XNM)
|
||||
LSN = (FDM, CSB)
|
||||
XRD = (CQQ, CQQ)
|
||||
TGP = (MMV, BKN)
|
||||
NDD = (VCB, NSB)
|
||||
FSP = (KNM, PVM)
|
||||
CDM = (VSC, VSC)
|
||||
NXG = (PVM, KNM)
|
||||
SSF = (DBP, RQQ)
|
||||
RKJ = (TGP, RGN)
|
||||
SRF = (FJM, CPG)
|
||||
MSP = (RLC, RCD)
|
||||
BDQ = (RFR, DHN)
|
||||
DTR = (LBN, GRB)
|
||||
SHS = (SRF, QBT)
|
||||
LGT = (JHK, GBQ)
|
||||
BQG = (SBS, LHK)
|
||||
XVS = (SNM, KKC)
|
||||
TFG = (VSN, VSN)
|
||||
NTB = (HDN, KDD)
|
||||
HNQ = (PMD, LTR)
|
||||
PMF = (XCM, RPX)
|
||||
FLV = (NJP, FQM)
|
||||
PTQ = (PFS, XPF)
|
||||
XXQ = (PGB, TKK)
|
||||
PJL = (DQD, FBH)
|
||||
GHX = (JNM, DKL)
|
||||
GMR = (QFL, RQF)
|
||||
TFH = (DTR, HNK)
|
||||
KVM = (PGL, GTC)
|
||||
DPC = (XPT, PJH)
|
||||
KDD = (GCF, CPC)
|
||||
JMM = (FBH, DQD)
|
||||
XCF = (VPV, VPV)
|
||||
JLS = (HSC, DBG)
|
||||
GKT = (BKM, KSH)
|
||||
DNQ = (TFJ, HKR)
|
||||
PTA = (SMQ, RMD)
|
||||
XFV = (RKR, VJD)
|
||||
RKG = (LHR, NSJ)
|
||||
RPC = (JDD, HPK)
|
||||
HNK = (GRB, LBN)
|
||||
NSB = (VQD, JGD)
|
||||
HKR = (MQT, XHH)
|
||||
FKX = (BXX, RTN)
|
||||
BPD = (NRG, LPP)
|
||||
NJC = (RTB, VCK)
|
||||
QXX = (CKT, MRX)
|
||||
SFG = (DDL, QDD)
|
||||
FGV = (PSR, XKD)
|
||||
PJH = (NRJ, NVC)
|
||||
CPG = (STG, DLM)
|
||||
NPQ = (DDJ, KVN)
|
||||
SSR = (PCJ, HVX)
|
||||
XCV = (RJP, DVV)
|
||||
SMV = (LHK, SBS)
|
||||
PCJ = (FTK, HHN)
|
||||
RHX = (FDK, DBX)
|
||||
DXL = (XFV, PKV)
|
||||
RDM = (KMB, DDN)
|
||||
NFR = (QQP, CFG)
|
||||
VNG = (MSP, TKQ)
|
||||
QDL = (DSQ, QNT)
|
||||
HPV = (GTB, PKP)
|
||||
SBM = (QXB, RTX)
|
||||
RGQ = (SXF, VLB)
|
||||
NRV = (MFV, RPC)
|
||||
DFD = (GFG, KMH)
|
||||
RRV = (RDK, HSB)
|
||||
PBH = (QNL, HDC)
|
||||
MMV = (LXS, XMM)
|
||||
VVT = (RMR, RXK)
|
||||
RPX = (KXN, KCQ)
|
||||
LPP = (VFK, QHK)
|
||||
RLH = (NHF, JKV)
|
||||
TPP = (MCR, PQH)
|
||||
XPB = (TGJ, XPJ)
|
||||
FVL = (RNM, JCJ)
|
||||
KGJ = (HPN, HXB)
|
||||
GKK = (LTB, KVD)
|
||||
BGX = (TTS, PHD)
|
||||
BNJ = (KXK, DXL)
|
||||
KBQ = (HPV, KKX)
|
||||
NFS = (JMM, PJL)
|
||||
BXX = (JLG, LBB)
|
||||
TNH = (FCK, JMG)
|
||||
BJB = (DVC, HSL)
|
||||
KHB = (NDD, GMQ)
|
||||
SKX = (SSF, QJM)
|
||||
LTR = (PVX, XPB)
|
||||
FDK = (SSX, BGX)
|
||||
LBN = (FCC, GHR)
|
||||
STG = (DJM, RHX)
|
||||
KGD = (VCM, PGT)
|
||||
PDH = (JCS, GMR)
|
||||
MCC = (QLR, QLR)
|
||||
GKN = (TTQ, XNM)
|
||||
KKC = (SGS, BJN)
|
||||
JDG = (NPX, PKR)
|
||||
DXV = (KVF, PDH)
|
||||
PGT = (QQH, GPS)
|
||||
GGL = (JLS, TMH)
|
||||
LRH = (QGG, LQN)
|
||||
XDT = (LHR, NSJ)
|
||||
TFJ = (XHH, MQT)
|
||||
CKT = (FTD, VPL)
|
||||
QNM = (GPD, HFT)
|
||||
QQB = (HHG, DVH)
|
||||
LKX = (MQN, MQN)
|
||||
HFT = (CMT, ZZZ)
|
||||
GTC = (VGD, NLL)
|
||||
DFP = (MVB, GHX)
|
||||
NDP = (LKN, SBH)
|
||||
PJK = (VRX, TXL)
|
||||
GBQ = (QXX, FFR)
|
||||
BJN = (QQB, DMG)
|
||||
RCF = (TKQ, MSP)
|
||||
FCK = (NHP, LXR)
|
||||
HHN = (RFJ, KHX)
|
||||
XNS = (MBX, CPT)
|
||||
XFM = (SPC, RGQ)
|
||||
VTV = (FKH, KVJ)
|
||||
PXP = (NHM, QTX)
|
||||
FKN = (LPP, NRG)
|
||||
DLM = (DJM, RHX)
|
||||
BCQ = (TFG, TFG)
|
||||
RFR = (SPR, SNR)
|
||||
GPS = (NBG, MKL)
|
||||
FML = (SRF, QBT)
|
||||
JLB = (HNQ, FFT)
|
||||
DLB = (DVC, HSL)
|
||||
DMP = (CDM, XSL)
|
||||
VCM = (QQH, GPS)
|
||||
SKC = (MTR, RJJ)
|
||||
TQZ = (SDR, CSK)
|
||||
XHH = (CXS, QRC)
|
||||
KKF = (RCN, QCT)
|
||||
TDH = (BGT, TCB)
|
||||
DSC = (HVX, PCJ)
|
||||
CND = (XVN, PCV)
|
||||
QBT = (FJM, CPG)
|
||||
KCQ = (HFS, XFM)
|
||||
KFP = (PCV, XVN)
|
||||
MCH = (NLC, NNC)
|
||||
TGJ = (RKH, QHB)
|
||||
RTN = (LBB, JLG)
|
||||
XSL = (VSC, QNM)
|
||||
SMQ = (BVV, XTG)
|
||||
PQH = (XKJ, THP)
|
||||
XQP = (TXL, VRX)
|
||||
PQK = (DRQ, MLK)
|
||||
QNQ = (VQG, DLS)
|
||||
SJD = (JBB, FGV)
|
||||
XSR = (LLQ, GHV)
|
||||
CFJ = (NFV, FKX)
|
||||
RNM = (BVJ, FKM)
|
||||
FSS = (PLL, DSG)
|
||||
SSJ = (XTL, KDN)
|
||||
JGM = (VHN, JFV)
|
||||
RTM = (XSS, KMF)
|
||||
MLQ = (VPX, PPR)
|
||||
SBH = (GXD, LRH)
|
||||
ZZZ = (CNN, JDG)
|
||||
VTX = (QCQ, MJQ)
|
||||
KHX = (TVQ, HGJ)
|
||||
NPX = (FND, FLV)
|
||||
PKR = (FLV, FND)
|
||||
JGD = (VGS, TQJ)
|
||||
JGH = (DPQ, KVM)
|
||||
PFB = (DFP, MMT)
|
||||
LHK = (RGK, HDS)
|
||||
GMQ = (NSB, VCB)
|
||||
DJM = (FDK, DBX)
|
||||
JKH = (XRD, RBT)
|
||||
CGR = (KFP, CND)
|
||||
RSF = (KGJ, MQQ)
|
||||
GQT = (DDL, QDD)
|
||||
RNT = (PJL, JMM)
|
||||
PTL = (SDN, JNQ)
|
||||
NCV = (PBQ, CGX)
|
||||
KTM = (FGV, JBB)
|
||||
FBR = (CFJ, QLS)
|
||||
BFT = (PGB, TKK)
|
||||
TTS = (FDQ, PXP)
|
||||
GTB = (KGH, HXS)
|
||||
XFP = (FXG, PVN)
|
||||
SHQ = (BCQ, BCQ)
|
||||
VGD = (KXP, KXP)
|
||||
CSK = (XHC, JKQ)
|
||||
MLL = (NRL, BNJ)
|
||||
CFH = (SFG, GQT)
|
||||
BMM = (PFS, XPF)
|
||||
LKN = (LRH, GXD)
|
||||
HSL = (FBS, TPP)
|
||||
TMB = (TCT, HLG)
|
||||
CDJ = (XMS, JVC)
|
||||
FQQ = (RHD, QNG)
|
||||
TQQ = (BKM, KSH)
|
||||
PVQ = (GKN, DKB)
|
||||
QTZ = (FKN, BPD)
|
||||
DSQ = (KTM, SJD)
|
||||
TMH = (HSC, DBG)
|
||||
QHB = (FSS, HCN)
|
||||
CQQ = (SMQ, RMD)
|
||||
MBK = (GKT, TQQ)
|
||||
MMM = (RXQ, PFB)
|
||||
LSC = (SHQ, RHR)
|
||||
MQT = (CXS, QRC)
|
||||
PMD = (XPB, PVX)
|
||||
MMK = (QCT, RCN)
|
||||
TVJ = (RCF, VNG)
|
||||
FHB = (MLK, DRQ)
|
||||
QNJ = (BTD, QGZ)
|
||||
TVQ = (NXS, XCD)
|
||||
GLC = (FNJ, LVL)
|
||||
HFS = (RGQ, SPC)
|
||||
BJV = (FKS, KFM)
|
||||
SSX = (TTS, PHD)
|
||||
FXG = (LSN, RRQ)
|
||||
TQS = (TLF, QPF)
|
||||
QVB = (QLR, QVZ)
|
||||
BNV = (RTH, VRK)
|
||||
NXS = (NXG, FSP)
|
||||
KSH = (TDL, FSC)
|
||||
HPK = (KVB, GGL)
|
||||
KKV = (FNN, BRK)
|
||||
XHC = (RDF, KTP)
|
||||
LQN = (BJV, GJC)
|
||||
GPD = (CMT, CMT)
|
||||
HRX = (LGQ, TKJ)
|
||||
CSB = (KSX, TFM)
|
||||
XPT = (NRJ, NVC)
|
||||
QTQ = (NNC, NLC)
|
||||
VPV = (MCC, MCC)
|
||||
TDL = (SCN, SCN)
|
||||
CTT = (DPQ, KVM)
|
||||
JFV = (GQG, MHX)
|
||||
GFG = (GNG, NDL)
|
||||
MKL = (TVJ, SSM)
|
||||
XKB = (TCB, BGT)
|
||||
XRV = (CFG, QQP)
|
||||
CRA = (BPD, FKN)
|
||||
VSC = (GPD, GPD)
|
||||
RGS = (FNN, BRK)
|
||||
MFV = (JDD, HPK)
|
||||
GGM = (GHV, LLQ)
|
||||
FKJ = (JKV, NHF)
|
||||
GCF = (KFS, RTM)
|
||||
JSD = (MDN, HCD)
|
||||
SXR = (XCN, JVG)
|
||||
LMF = (MXP, FVH)
|
||||
AAA = (JDG, CNN)
|
||||
MJT = (RXQ, PFB)
|
||||
PJD = (XCF, HKK)
|
||||
RDD = (NKS, DPC)
|
||||
DPT = (HVV, GTM)
|
||||
NHM = (QCX, MSS)
|
||||
MQQ = (HXB, HPN)
|
||||
FLL = (RKS, RRV)
|
||||
BRK = (RMB, NPF)
|
||||
FHC = (BSB, NDP)
|
||||
RHR = (BCQ, QPR)
|
||||
NNC = (JJL, NJC)
|
||||
LKR = (XQP, PJK)
|
||||
CDF = (VSN, QTZ)
|
||||
MRX = (FTD, VPL)
|
||||
PLT = (DTR, HNK)
|
||||
VLQ = (TKJ, LGQ)
|
||||
GJC = (KFM, FKS)
|
||||
MQN = (BTD, BTD)
|
||||
GHR = (MFT, NRB)
|
||||
XXL = (FBR, DSJ)
|
||||
NHF = (XVS, KKR)
|
||||
LDS = (DKB, GKN)
|
||||
PKV = (RKR, VJD)
|
||||
KPC = (RPX, XCM)
|
||||
NRJ = (DPN, CNF)
|
||||
BGA = (CCP, NQV)
|
||||
LCK = (DSC, SSR)
|
||||
KFM = (MPX, CVV)
|
||||
RMB = (FCP, VLM)
|
||||
XKJ = (FMV, GCN)
|
||||
NBG = (SSM, TVJ)
|
||||
QPF = (VKH, QLQ)
|
||||
RKH = (HCN, FSS)
|
||||
HGJ = (XCD, NXS)
|
||||
RGN = (MMV, BKN)
|
||||
HCN = (DSG, PLL)
|
||||
RFM = (CCF, JNJ)
|
||||
DRQ = (KKF, MMK)
|
||||
XKD = (DQV, GLC)
|
||||
NXK = (KXQ, XCV)
|
||||
FTK = (RFJ, KHX)
|
||||
QQH = (MKL, NBG)
|
||||
HSB = (NKP, JGJ)
|
||||
GSH = (TQS, XBQ)
|
||||
CTF = (CPB, DMP)
|
||||
GCR = (RNM, JCJ)
|
||||
CCF = (XRT, JFD)
|
||||
DSG = (BCB, GBC)
|
||||
XCN = (SKC, LMT)
|
||||
PLL = (GBC, BCB)
|
||||
VKH = (HFR, VMN)
|
||||
PBQ = (MJT, MMM)
|
||||
PSF = (LKX, SVX)
|
||||
LMG = (MXP, FVH)
|
||||
BMP = (FBR, DSJ)
|
||||
GXD = (LQN, QGG)
|
||||
XMS = (PKX, CGR)
|
||||
RLC = (DPT, FXX)
|
||||
NRB = (BNR, TFN)
|
||||
VPL = (XXL, BMP)
|
||||
PCV = (VVM, NTB)
|
||||
QGR = (SFG, GQT)
|
||||
PHD = (PXP, FDQ)
|
||||
NQV = (XFP, XHT)
|
||||
LGQ = (RTD, HHM)
|
||||
CNN = (NPX, PKR)
|
||||
CPT = (CST, CKQ)
|
||||
BGT = (KXG, PJD)
|
||||
THP = (GCN, FMV)
|
||||
QGG = (BJV, GJC)
|
||||
KSX = (LGT, TXS)
|
||||
BKM = (TDL, FSC)
|
||||
FXX = (HVV, GTM)
|
||||
KMF = (SQG, GKK)
|
||||
FCC = (MFT, NRB)
|
||||
NDL = (FKJ, RLH)
|
||||
TFM = (TXS, LGT)
|
||||
LMX = (FRT, LRG)
|
||||
FFR = (MRX, CKT)
|
||||
KXK = (PKV, XFV)
|
||||
JNJ = (XRT, JFD)
|
||||
DMG = (HHG, DVH)
|
||||
TCT = (NCP, KBQ)
|
||||
MXP = (SDD, LMX)
|
||||
FSC = (SCN, JKH)
|
||||
VFS = (VMG, LXF)
|
||||
RBT = (CQQ, JXZ)
|
||||
RXV = (QXM, TQZ)
|
||||
RKS = (HSB, RDK)
|
||||
FND = (FQM, NJP)
|
||||
XPF = (QBG, RJB)
|
||||
LFT = (XXQ, BFT)
|
||||
HVX = (HHN, FTK)
|
||||
RTX = (NXK, DFN)
|
||||
QNG = (XRV, NFR)
|
||||
NFV = (RTN, BXX)
|
||||
KQL = (RGS, KKV)
|
||||
MTR = (TFH, PLT)
|
||||
QNS = (QNT, DSQ)
|
||||
SHB = (KRC, JBN)
|
||||
SVP = (FFP, SKX)
|
||||
VLM = (PBH, RHQ)
|
||||
71
2023/go/day09/day09.go
Normal file
71
2023/go/day09/day09.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
_ "fmt"
|
||||
"strings"
|
||||
|
||||
"adventofcode2023/utils/inputs"
|
||||
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
ins := parseInput(input)
|
||||
ans := 0
|
||||
for _, in := range ins {
|
||||
ans += f1(in)
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
ins := parseInput(input)
|
||||
ans := 0
|
||||
for _, in := range ins {
|
||||
reverse(in)
|
||||
ans += f1(in)
|
||||
}
|
||||
return ans}
|
||||
|
||||
func f1(in []int) int {
|
||||
out := []int{}
|
||||
for i:=0;i<len(in)-1;i++{
|
||||
out = append(out, in[i+1] - in[i])
|
||||
}
|
||||
if allZero(out) {
|
||||
return in[len(in) -1]
|
||||
} else {
|
||||
return in[len(in) -1] + f1(out)
|
||||
}
|
||||
}
|
||||
|
||||
func reverse(nums []int) {
|
||||
for i, j := 0, len(nums)-1; i < j; i, j = i+1, j-1 {
|
||||
nums[i], nums[j] = nums[j], nums[i]
|
||||
}
|
||||
}
|
||||
|
||||
func allZero(in []int) bool {
|
||||
for _, v := range in {
|
||||
if v != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func diff(in []int) []int {
|
||||
out := []int{}
|
||||
for i:=0;i<len(in)-1;i++{
|
||||
out = append(out, in[i+1] - in[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseInput(input string) ([][]int) {
|
||||
lines := strings.Split(input, "\n")
|
||||
out := [][]int{}
|
||||
for _, line := range lines {
|
||||
out = append(out, inputs.ToInts(line, " "))
|
||||
}
|
||||
return out
|
||||
}
|
||||
23
2023/go/day09/day09_test.go
Normal file
23
2023/go/day09/day09_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`0 3 6 9 12 15
|
||||
1 3 6 10 15 21
|
||||
10 13 16 21 30 45`)
|
||||
require.Equal(t, 114, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`0 3 6 9 12 15
|
||||
1 3 6 10 15 21
|
||||
10 13 16 21 30 45`)
|
||||
require.Equal(t, 2, r)
|
||||
}
|
||||
200
2023/go/day09/input.txt
Normal file
200
2023/go/day09/input.txt
Normal file
@@ -0,0 +1,200 @@
|
||||
12 20 25 35 64 137 305 670 1420 2874 5537 10165 17840 30055 48809 76712 117100 174160 253065 360119 502912
|
||||
4 13 35 72 138 283 626 1388 2906 5608 9961 16503 26276 42338 73621 143357 305888 678423 1499107 3231106 6746590
|
||||
-6 -9 -13 -18 -24 -31 -39 -48 -58 -69 -81 -94 -108 -123 -139 -156 -174 -193 -213 -234 -256
|
||||
18 36 73 131 225 404 773 1526 3020 5945 11675 22920 44839 86819 165175 307081 556102 979762 1679653 2804665 4567997
|
||||
17 31 46 67 109 199 385 775 1650 3729 8722 20406 46627 102917 218904 449526 894459 1731467 3273058 6061549 11026301
|
||||
2 6 26 71 146 246 345 385 290 59 36 1541 8237 29022 84081 217384 522055 1190948 2615907 5580283 11629317
|
||||
12 21 26 32 65 187 511 1216 2562 4905 8712 14576 23231 35567 52645 75712 106216 145821 196422 260160 339437
|
||||
19 40 72 106 141 209 426 1095 2907 7321 17258 38315 80781 162797 315036 587344 1058110 1848293 3145159 5247819 8660620
|
||||
13 13 23 70 203 501 1092 2208 4327 8488 16904 34050 68520 136271 266715 515104 988950 1904948 3709702 7328655 14662978
|
||||
24 39 54 69 84 99 114 129 144 159 174 189 204 219 234 249 264 279 294 309 324
|
||||
7 23 56 125 258 487 856 1466 2597 4971 10261 22027 47409 100206 206569 415728 820556 1597628 3086552 5949705 11498367
|
||||
3 4 13 37 81 153 291 637 1607 4241 10866 26285 59856 129126 266300 530120 1028523 1963486 3722239 7065077 13510923
|
||||
14 24 57 142 319 639 1167 1988 3216 5006 7569 11190 16249 23245 32823 45804 63218 86340 116729 156270 207219
|
||||
0 3 18 73 223 574 1330 2878 5932 11776 22703 42884 80178 149892 282329 537277 1030620 1981333 3791768 7181107 13402261
|
||||
1 2 7 22 71 206 514 1121 2193 3934 6581 10396 15655 22634 31592 42751 56273 72234 90595 111170 133591
|
||||
10 23 53 118 259 555 1140 2226 4144 7426 12968 22337 38311 65782 113288 195931 341930 608937 1125228 2190007 4505341
|
||||
8 24 59 130 257 463 774 1219 1830 2642 3693 5024 6679 8705 11152 14073 17524 21564 26255 31662 37853
|
||||
-5 -1 24 79 168 290 439 604 769 913 1010 1029 934 684 233 -470 -1481 -2861 -4676 -6997 -9900
|
||||
15 30 63 114 187 312 590 1276 2932 6720 14984 32418 68369 141221 286394 570321 1113889 2130302 3984201 7281214 12999963
|
||||
14 33 65 120 219 398 725 1342 2547 4946 9746 19341 38473 76428 150937 294658 565256 1060083 1936163 3435442 5913859
|
||||
13 23 49 105 201 338 503 664 765 721 413 -317 -1671 -3900 -7309 -12262 -19187 -28581 -41015 -57139 -77687
|
||||
17 32 46 59 69 68 32 -100 -463 -1324 -3166 -6803 -13531 -25320 -45052 -76810 -126223 -200872 -310762 -468865 -691739
|
||||
14 17 25 48 110 259 586 1269 2665 5480 11054 21805 41883 78092 141145 247324 420624 695467 1120079 1760630 2706244
|
||||
14 8 9 30 85 189 358 609 960 1430 2039 2808 3759 4915 6300 7939 9858 12084 14645 17570 20889
|
||||
16 43 85 156 281 496 848 1395 2206 3361 4951 7078 9855 13406 17866 23381 30108 38215 47881 59296 72661
|
||||
19 44 91 172 296 466 677 924 1251 1918 3844 9613 25529 65528 158335 360406 779575 1619184 3262021 6431310 12498130
|
||||
0 4 12 44 135 335 709 1337 2314 3750 5770 8514 12137 16809 22715 30055 39044 49912 62904 78280 96315
|
||||
16 24 46 91 161 248 338 441 691 1595 4568 13006 34383 84308 194283 426251 899158 1835982 3644382 7050745 13316497
|
||||
7 29 70 137 240 394 619 949 1478 2503 4891 10937 26256 63759 151635 348678 772493 1649381 3399400 6776661 13093860
|
||||
4 4 5 13 34 74 139 235 368 544 769 1049 1390 1798 2279 2839 3484 4220 5053 5989 7034
|
||||
4 -4 -7 8 59 169 365 671 1095 1624 2264 3194 5144 10157 22954 53189 118958 252012 505219 962924 1754969
|
||||
26 42 74 139 263 487 877 1543 2672 4587 7863 13560 23658 41777 74239 131622 231718 407726 733983 1402568 2931267
|
||||
11 33 70 131 245 486 1027 2238 4843 10151 20376 39061 71621 126020 213597 350056 556635 861469 1301162 1922583 2784901
|
||||
23 36 60 110 212 411 788 1488 2763 5049 9135 16554 30434 57184 109535 211570 406399 766978 1410118 2512830 4328616
|
||||
9 21 53 112 202 321 466 654 967 1629 3123 6356 12880 25177 47016 83890 143541 236581 377217 584088 881222
|
||||
1 12 44 109 239 501 1018 1996 3753 6743 11566 18954 29723 44682 64492 89471 119345 152950 187896 220211 243991
|
||||
5 8 15 37 102 271 668 1537 3347 6972 13982 27113 51102 94431 173443 322385 617316 1230502 2548499 5417988 11639807
|
||||
22 32 42 52 62 72 82 92 102 112 122 132 142 152 162 172 182 192 202 212 222
|
||||
26 52 91 142 204 276 357 446 542 644 751 862 976 1092 1209 1326 1442 1556 1667 1774 1876
|
||||
24 49 87 138 202 279 369 472 588 717 859 1014 1182 1363 1557 1764 1984 2217 2463 2722 2994
|
||||
9 19 42 78 127 189 264 352 453 567 694 834 987 1153 1332 1524 1729 1947 2178 2422 2679
|
||||
-3 -2 3 24 99 302 758 1676 3415 6612 12449 23248 43805 84286 166263 334878 682850 1397511 2853324 5795757 11710724
|
||||
4 16 41 95 214 468 975 1915 3544 6208 10357 16559 25514 38068 55227 78171 108268 147088 196417 258271 334910
|
||||
11 15 29 64 141 299 617 1259 2547 5059 9732 17919 31299 51465 78912 111010 138371 138799 67743 -156150 -672167
|
||||
5 1 3 18 62 174 431 964 1975 3755 6703 11346 18360 28592 43083 63092 90121 125941 172619 232546 308466
|
||||
26 51 99 184 339 632 1182 2174 3872 6638 10991 17798 28811 48009 84666 159878 319614 659405 1368755 2807428 5631043
|
||||
15 31 66 141 300 634 1325 2728 5517 10935 21220 40345 75348 138842 254046 465448 862165 1629328 3158970 6281548 12730658
|
||||
15 25 35 45 55 65 75 85 95 105 115 125 135 145 155 165 175 185 195 205 215
|
||||
13 28 56 103 181 308 508 811 1253 1876 2728 3863 5341 7228 9596 12523 16093 20396 25528 31591 38693
|
||||
6 14 37 87 177 324 552 895 1400 2130 3167 4615 6603 9288 12858 17535 23578 31286 41001 53111 68053
|
||||
7 8 24 73 191 441 920 1764 3151 5302 8480 12987 19159 27359 37968 51374 67959 88084 112072 140189 172623
|
||||
-2 -2 12 49 123 269 565 1156 2284 4356 8142 15299 29577 59291 121951 252342 515850 1029450 1993520 3738533 6791719
|
||||
4 18 57 143 320 671 1342 2569 4699 8191 13578 21366 31841 44750 58817 71050 75790 63448 18871 -80727 -268338
|
||||
20 38 71 128 214 335 513 809 1360 2467 4852 10383 23936 57774 141126 339947 795762 1798994 3922635 8258484 16823056
|
||||
8 23 43 72 128 263 609 1478 3558 8273 18421 39274 80432 158922 304459 568717 1042388 1887535 3399479 6123936 11073736
|
||||
-2 11 49 137 313 643 1251 2364 4372 7903 13913 23791 39479 63607 99643 152058 226506 330019 471217 660533 910453
|
||||
20 31 52 97 178 300 456 622 752 773 580 31 -1058 -2918 -5832 -10140 -16244 -24613 -35788 -50387 -69110
|
||||
-5 3 17 38 76 154 313 628 1253 2518 5099 10262 20122 37721 66459 107930 156415 187029 132637 -158066 -992728
|
||||
8 8 4 -5 -7 36 201 617 1478 3056 5714 9919 16255 25436 38319 55917 79412 110168 149744 199907 262645
|
||||
10 31 59 95 157 308 702 1659 3795 8256 17136 34198 66064 124095 227245 406244 709544 1211549 2023745 3309449 5303007
|
||||
25 52 96 157 230 305 367 396 367 250 10 -393 -1004 -1873 -3055 -4610 -6603 -9104 -12188 -15935 -20430
|
||||
18 37 77 154 307 616 1230 2412 4621 8671 16030 29344 53288 95854 170181 297010 507804 848505 1383803 2201662 3417681
|
||||
9 20 38 68 119 223 484 1169 2848 6589 14224 28739 54945 100848 180737 322294 582607 1082858 2080310 4111590 8267015
|
||||
16 18 33 83 206 461 946 1857 3630 7218 14557 29273 57696 110321 204066 366139 641204 1105050 1890401 3234215 5561242
|
||||
14 39 80 138 211 310 503 1012 2395 5849 13675 29974 61745 120819 227613 418689 761752 1384239 2525270 4625678 8477307
|
||||
19 45 82 127 174 220 274 368 586 1153 2671 6688 17013 42674 104354 247812 570611 1273115 2752498 5772143 11763838
|
||||
28 38 42 49 77 148 287 540 1031 2078 4381 9279 19046 37156 68392 118602 193814 298310 431124 580269 713811
|
||||
11 21 27 29 29 29 33 66 233 867 2865 8396 22316 54917 127224 281225 599691 1244513 2530267 5063511 10002115
|
||||
12 24 40 58 72 67 23 -54 -55 377 2098 6907 18400 43773 97860 212323 456296 981519 2117896 4569227 9801250
|
||||
24 32 39 42 29 -11 -65 -47 306 1640 5357 14241 33467 72245 146671 285119 539198 1006862 1881469 3554582 6826371
|
||||
0 10 24 38 55 91 181 385 794 1536 2782 4752 7721 12025 18067 26323 37348 51782 70356 93898 123339
|
||||
10 8 6 4 2 0 -2 -4 -6 -8 -10 -12 -14 -16 -18 -20 -22 -24 -26 -28 -30
|
||||
23 36 57 99 187 369 743 1519 3140 6491 13242 26420 51424 97971 184086 344653 650095 1247110 2446146 4905196 10007393
|
||||
6 3 1 0 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136
|
||||
3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63
|
||||
27 44 63 84 107 132 159 188 219 252 287 324 363 404 447 492 539 588 639 692 747
|
||||
-1 -7 1 47 173 448 984 1975 3790 7182 13743 26886 53965 110835 231521 488214 1031309 2166751 4500097 9195505 18426041
|
||||
5 17 35 67 143 330 753 1622 3265 6167 11015 18749 30619 48248 73701 109560 159005 225901 314891 431495 582215
|
||||
-6 -2 7 21 40 64 93 127 166 210 259 313 372 436 505 579 658 742 831 925 1024
|
||||
5 0 -4 -3 7 30 70 131 217 332 480 665 891 1162 1482 1855 2285 2776 3332 3957 4655
|
||||
-2 9 35 94 215 440 844 1582 2973 5640 10750 20449 38679 72726 136138 254178 473924 882791 1642073 3046724 5629899
|
||||
10 14 30 70 158 349 763 1655 3561 7584 15905 32613 64946 125058 232597 419003 736198 1276697 2222168 3959477 7350468
|
||||
26 35 42 44 33 -4 -85 -233 -476 -847 -1384 -2130 -3133 -4446 -6127 -8239 -10850 -14033 -17866 -22432 -27819
|
||||
8 4 13 52 139 289 508 786 1087 1337 1434 1368 1675 4707 17679 59383 174380 462612 1141265 2674334 6042821
|
||||
10 23 36 49 62 75 88 101 114 127 140 153 166 179 192 205 218 231 244 257 270
|
||||
5 7 9 13 27 82 254 695 1695 3828 8282 17539 36659 75535 152627 300855 576537 1072501 1936783 3398649 5804051
|
||||
4 12 35 82 161 278 436 634 866 1120 1377 1610 1783 1850 1754 1426 784 -268 -1841 -4062 -7075
|
||||
-6 -8 -10 -12 -14 -16 -18 -20 -22 -24 -26 -28 -30 -32 -34 -36 -38 -40 -42 -44 -46
|
||||
13 22 42 92 218 505 1089 2169 4019 7000 11572 18306 27896 41171 59107 82839 113673 153098 202798 264664 340806
|
||||
16 13 21 55 130 261 463 751 1140 1645 2281 3063 4006 5125 6435 7951 9688 11661 13885 16375 19146
|
||||
18 27 47 88 160 273 437 662 958 1335 1803 2372 3052 3853 4785 5858 7082 8467 10023 11760 13688
|
||||
7 6 17 58 155 342 661 1162 1903 2950 4377 6266 8707 11798 15645 20362 26071 32902 40993 50490 61547
|
||||
11 13 24 50 109 246 543 1125 2175 3985 7097 12658 23281 45058 92042 195689 423683 915597 1947414 4043610 8164997
|
||||
6 0 5 31 87 200 455 1071 2540 5886 13167 28475 59942 123730 251825 506902 1009910 1989788 3870441 7418499 13987325
|
||||
-2 8 27 55 92 138 193 257 330 412 503 603 712 830 957 1093 1238 1392 1555 1727 1908
|
||||
13 22 31 40 49 58 67 76 85 94 103 112 121 130 139 148 157 166 175 184 193
|
||||
14 35 68 128 246 470 871 1568 2805 5143 9869 19770 40471 82590 165018 319686 598232 1081027 1889058 3199196 5263396
|
||||
15 24 35 58 111 227 481 1046 2297 5016 10835 23231 49728 106580 228292 486215 1023782 2122091 4321254 8645623 17024708
|
||||
12 19 40 83 160 292 519 913 1602 2837 5172 9879 19786 40806 84519 172277 341424 654359 1211320 2167931 3758732
|
||||
18 36 68 124 214 348 536 788 1114 1524 2028 2636 3358 4204 5184 6308 7586 9028 10644 12444 14438
|
||||
12 20 33 45 47 24 -54 -236 -556 -887 -527 2807 15236 51518 144801 365619 857408 1900374 4022237 8183901 16081297
|
||||
11 22 33 49 89 203 511 1293 3174 7478 16893 36733 77363 158858 319822 633666 1237753 2383938 4523501 8445701 15497657
|
||||
11 27 54 110 220 428 835 1670 3410 6992 14206 28422 55898 108100 205914 387755 726239 1363956 2591066 5011451 9889470
|
||||
25 33 54 116 273 627 1364 2810 5519 10416 19034 33905 59191 101672 172244 288121 475981 776347 1249550 1983682 3105013
|
||||
4 5 10 23 64 183 481 1157 2623 5768 12514 26902 57092 118886 241719 478527 921458 1725895 3145362 5578917 9629452
|
||||
13 18 25 38 72 159 357 772 1610 3302 6805 14297 30695 66820 145791 315686 674243 1416334 2923593 5930084 11821362
|
||||
9 22 35 48 61 74 87 100 113 126 139 152 165 178 191 204 217 230 243 256 269
|
||||
9 32 76 153 275 454 702 1031 1453 1980 2624 3397 4311 5378 6610 8019 9617 11416 13428 15665 18139
|
||||
20 31 45 59 80 140 311 720 1564 3125 5785 10041 16520 25994 39395 57830 82596 115195 157349 211015 278400
|
||||
13 34 81 180 383 779 1505 2757 4801 7984 12745 19626 29283 42497 60185 83411 113397 151534 199393 258736 331527
|
||||
11 5 -4 -6 24 128 377 921 2123 4846 10990 24409 52376 107807 212503 401722 730451 1281811 2178096 3595020 5779824
|
||||
18 33 65 129 254 496 951 1774 3217 5699 9911 16936 28325 46012 71871 106613 147588 184893 194989 130795 -93048
|
||||
8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65 68
|
||||
22 27 35 57 123 295 675 1408 2681 4714 7734 11938 17521 25028 36693 60269 118556 271189 661633 1614015 3824955
|
||||
-5 -5 -2 13 74 258 712 1704 3727 7703 15360 29910 57292 108555 204579 385428 728331 1380599 2616414 4928519 9165614
|
||||
6 18 41 74 113 150 183 257 568 1674 4869 12788 30323 65942 133515 254763 462458 804514 1349121 2191086 3459557
|
||||
12 32 70 144 289 562 1047 1860 3154 5124 8012 12112 17775 25414 35509 48612 65352 86440 112674 144944 184237
|
||||
4 7 26 89 233 513 1028 1982 3817 7474 14867 29724 59116 116351 226576 437541 839650 1601693 3031396 5672739 10454035
|
||||
7 11 21 37 59 87 121 161 207 259 317 381 451 527 609 697 791 891 997 1109 1227
|
||||
-7 2 36 105 233 474 929 1764 3229 5678 9590 15591 24477 37238 55083 79466 112113 155050 210632 281573 370977
|
||||
19 22 21 20 27 60 160 405 916 1850 3392 5794 9570 16048 28609 55115 112249 232766 476991 950304 1828829
|
||||
6 5 0 -6 0 51 230 744 2075 5250 12281 26835 55203 107646 200205 357071 613620 1020227 1646982 2589440 3975546
|
||||
12 37 74 122 181 253 357 565 1076 2385 5694 13877 33581 79455 182089 402060 853572 1742597 3426234 6502268 11940701
|
||||
4 10 11 11 21 59 153 358 813 1892 4560 11162 27101 64273 147816 328805 707113 1470932 2962722 5786321 10978172
|
||||
2 -4 -14 -18 12 132 452 1185 2736 5872 12053 24061 47144 91002 173091 323920 595278 1072668 1893660 3274424 5547388
|
||||
23 41 67 100 149 247 471 965 1969 3883 7451 14250 27840 56227 116812 245915 516543 1070717 2176959 4330256 8422019
|
||||
-8 -1 26 83 188 387 799 1712 3775 8367 18292 39066 81247 164533 324739 625287 1175530 2159111 3876662 6808509 11704702
|
||||
16 38 75 146 286 563 1110 2172 4168 7768 13985 24282 40694 65965 103700 158532 236304 344266 491287 688082 947454
|
||||
3 13 24 47 116 313 808 1918 4203 8640 16944 32132 59444 107734 191412 332941 565755 937247 1511160 2368277 3603724
|
||||
2 16 51 124 266 545 1099 2180 4216 7907 14378 25406 43703 73161 118865 186656 282365 412201 589508 861747 1389619
|
||||
5 18 39 68 105 150 203 264 333 410 495 588 689 798 915 1040 1173 1314 1463 1620 1785
|
||||
1 12 50 141 322 641 1157 1940 3071 4642 6756 9527 13080 17551 23087 29846 37997 47720 59206 72657 88286
|
||||
4 16 50 124 269 540 1042 1983 3766 7129 13340 24457 43668 75726 127504 208826 334362 529529 849438 1435283 2668205
|
||||
15 35 66 111 173 255 360 491 651 843 1070 1335 1641 1991 2388 2835 3335 3891 4506 5183 5925
|
||||
13 21 53 130 286 580 1111 2043 3651 6395 11024 18730 31461 52741 89851 159160 297973 588757 1205355 2496214 5127228
|
||||
8 8 25 87 239 540 1055 1842 2934 4316 5897 7477 8709 9056 7743 3704 -4476 -18624 -41047 -74605 -122789
|
||||
-7 -9 -1 35 138 374 851 1761 3471 6696 12810 24386 46095 86118 158201 284361 497961 846321 1391101 2203233 3347012
|
||||
6 25 62 140 292 567 1043 1842 3136 5122 7923 11332 14243 13482 1523 -37788 -136855 -357062 -808189 -1674217 -3239703
|
||||
19 45 92 165 260 365 468 573 730 1101 2119 4861 11861 28749 67333 151061 324229 666861 1317902 2510261 4622346
|
||||
-5 -2 2 2 -11 -53 -145 -295 -444 -333 813 5032 17356 49671 128921 313695 726202 1611289 3441257 7095887 14162940
|
||||
9 10 21 64 187 481 1104 2321 4569 8551 15353 26563 44351 71444 110900 165550 236937 323536 417989 503034 545747
|
||||
13 11 9 7 5 3 1 -1 -3 -5 -7 -9 -11 -13 -15 -17 -19 -21 -23 -25 -27
|
||||
20 27 27 32 64 150 317 587 972 1469 2055 2682 3272 3712 3849 3485 2372 207 -3373 -8796 -16560
|
||||
8 12 17 29 59 128 272 546 1040 1949 3795 8014 18355 43992 106087 251024 576095 1277813 2740616 5697006 11513670
|
||||
13 23 39 67 110 168 238 314 387 445 473 453 364 182 -120 -572 -1207 -2061 -3173 -4585 -6342
|
||||
15 30 54 93 161 295 578 1180 2445 5079 10538 21785 44698 90622 181037 356507 695002 1351447 2644938 5249563 10601080
|
||||
15 30 49 72 99 130 165 204 247 294 345 400 459 522 589 660 735 814 897 984 1075
|
||||
0 2 10 36 96 215 444 911 1953 4421 10323 24086 54908 121006 257211 528674 1056138 2063596 3969400 7560556 14322468
|
||||
19 48 92 151 225 314 418 537 671 820 984 1163 1357 1566 1790 2029 2283 2552 2836 3135 3449
|
||||
19 29 38 54 96 194 391 747 1345 2299 3764 5948 9126 13656 19997 28729 40575 56425 77362 104690 139964
|
||||
-10 -15 -20 -25 -30 -35 -40 -45 -50 -55 -60 -65 -70 -75 -80 -85 -90 -95 -100 -105 -110
|
||||
20 35 62 113 200 345 611 1160 2344 4842 9886 19707 38540 74949 146995 293023 592748 1206017 2440198 4861569 9471136
|
||||
15 18 23 39 98 273 696 1582 3277 6368 11928 22026 40718 75857 142225 266705 496483 911606 1643629 2902569 5014954
|
||||
0 -1 8 38 103 226 448 850 1612 3147 6362 13112 26927 54106 105286 197608 357616 625039 1057620 1737170 2777039
|
||||
9 16 34 87 224 535 1183 2463 4899 9399 17522 31996 57798 104412 190375 351970 659005 1242114 2338026 4361877 8019004
|
||||
4 0 6 35 101 219 405 676 1050 1546 2184 2985 3971 5165 6591 8274 10240 12516 15130 18111 21489
|
||||
10 27 60 117 212 385 745 1542 3286 6958 14400 29028 57084 109730 206389 379855 683826 1203661 2071324 3485655 5739300
|
||||
5 7 22 60 131 245 412 642 945 1331 1810 2392 3087 3905 4856 5950 7197 8607 10190 11956 13915
|
||||
18 30 43 52 47 21 -14 9 296 1369 4407 11874 28661 64160 136010 276761 545454 1047184 1965179 3611880 6508043
|
||||
22 46 92 168 282 442 656 932 1278 1702 2212 2816 3522 4338 5272 6332 7526 8862 10348 11992 13802
|
||||
8 13 20 44 110 253 518 960 1644 2645 4048 5948 8450 11669 15730 20768 26928 34365 43244 53740 66038
|
||||
-3 1 10 24 43 67 96 130 169 213 262 316 375 439 508 582 661 745 834 928 1027
|
||||
13 39 85 169 321 590 1056 1847 3161 5293 8667 13873 21709 33228 49790 73119 105365 149171 207745 284937 385321
|
||||
5 14 36 83 195 464 1065 2288 4561 8450 14618 23721 36215 52044 70175 87942 100157 97942 67232 -13105 -173589
|
||||
15 19 30 62 145 335 724 1453 2731 4863 8290 13644 21821 34075 52136 78355 115879 168859 242694 344314 482505
|
||||
2 11 44 125 296 629 1253 2418 4645 9063 18123 37017 76329 156717 316782 625734 1203028 2247827 4081966 7211053 12409462
|
||||
11 35 81 170 335 621 1094 1881 3275 5959 11445 22918 46892 96576 198907 409378 843048 1738176 3583686 7367983 15052310
|
||||
22 31 41 57 91 170 363 840 1989 4657 10673 23996 53165 116277 250554 529758 1094371 2201726 4306420 8185830 15132182
|
||||
-1 7 15 33 92 259 668 1582 3518 7495 15514 31474 62920 124397 243884 474989 919525 1767999 3369645 6349039 11792984
|
||||
9 6 4 22 93 267 617 1248 2307 3990 6549 10333 15971 24949 41114 74263 148526 322161 734795 1719395 4061142
|
||||
17 28 42 71 134 259 488 894 1635 3095 6196 13008 27836 59024 121786 242453 464613 857718 1528838 2638357 4420530
|
||||
20 33 55 105 212 427 857 1727 3474 6875 13209 24451 43494 74393 122623 195341 301640 452781 662387 946581 1324048
|
||||
-2 -6 -6 16 84 227 476 858 1392 2102 3076 4617 7550 13765 27086 54555 108202 207330 381270 672446 1139424
|
||||
11 28 58 105 175 280 442 697 1099 1724 2674 4081 6111 8968 12898 18193 25195 34300 45962 60697 79087
|
||||
6 6 4 10 50 174 461 1020 1989 3537 5877 9301 14251 21443 32064 48065 72576 110472 169122 259356 396688
|
||||
9 33 72 143 291 617 1321 2757 5491 10347 18432 31172 50503 79595 124911 201104 341341 617245 1174920 2296653 4502083
|
||||
1 -3 -6 6 57 181 422 834 1481 2437 3786 5622 8049 11181 15142 20066 26097 33389 42106 52422 64521
|
||||
20 45 92 183 353 648 1120 1828 2877 4577 7895 15519 34068 78280 178405 392536 826242 1662637 3206942 5950687 10661971
|
||||
9 20 49 105 197 326 471 562 423 -334 -2454 -7125 -15718 -28520 -41047 -34951 42817 325984 1127851 3148993 7902215
|
||||
4 13 22 31 40 49 58 67 76 85 94 103 112 121 130 139 148 157 166 175 184
|
||||
3 18 39 62 84 110 166 321 721 1638 3537 7164 13658 24690 42632 70759 113487 176650 267819 396666 575376
|
||||
23 33 49 79 132 217 335 464 539 441 41 -595 -643 2719 16711 57254 156427 375417 827593 1720891 3437190
|
||||
7 24 50 85 142 258 514 1069 2207 4385 8261 14704 24907 41055 68751 123960 250328 558763 1312713 3104284 7206249
|
||||
-7 -1 21 79 208 466 962 1919 3787 7421 14339 27075 49642 88120 151384 251987 407213 640315 981953 1471847 2160660
|
||||
-7 -4 0 6 17 40 94 224 527 1208 2702 5922 12723 26708 54544 108004 207005 383972 689924 1202750 2038221
|
||||
18 29 55 112 225 446 901 1884 4033 8657 18343 38083 77387 154338 303618 592833 1156238 2264577 4468621 8890194 17802535
|
||||
13 27 43 70 138 306 667 1350 2519 4369 7119 11002 16252 23088 31695 42202 54657 68999 85027 102366 120430
|
||||
1 14 48 125 277 551 1022 1814 3129 5284 8756 14235 22685 35413 54146 81116 119153 171786 243352 339113 465381
|
||||
-1 8 23 44 71 104 143 188 239 296 359 428 503 584 671 764 863 968 1079 1196 1319
|
||||
19 43 77 127 215 395 790 1669 3597 7724 16343 33959 69302 139053 274682 535059 1030155 1966898 3740787 7123974 13657889
|
||||
18 45 91 164 275 438 677 1048 1684 2871 5163 9544 17645 32024 56517 96668 160246 257857 403659 616188 919303
|
||||
6 22 59 136 291 594 1160 2162 3844 6534 10657 16748 25465 37602 54102 76070 104786 141718 188535 247120 319583
|
||||
23 37 65 118 212 377 687 1329 2735 5816 12367 25768 52224 103069 199356 381630 731614 1420871 2818778 5726452 11868843
|
||||
13 24 32 38 55 126 345 876 1970 3996 7534 13631 24400 44252 82197 155837 297907 566504 1060484 1941908 3467885
|
||||
9 11 8 7 38 173 559 1479 3462 7483 15333 30296 58341 110127 204263 372559 668647 1182699 2067602 3586753 6201896
|
||||
18 44 92 182 354 678 1272 2352 4352 8165 15568 29905 57112 107177 196136 348713 601718 1008322 1643332 2609592 4045638
|
||||
-6 -2 12 37 85 189 422 952 2183 5066 11718 26576 58470 124296 255549 510096 993680 1899506 3581116 6685619 12394363
|
||||
10 18 40 85 167 323 635 1262 2502 4919 9598 18672 36477 72155 145400 298517 620281 1290667 2661351 5397302 10725062
|
||||
8 7 10 36 112 276 581 1096 1900 3059 4565 6212 7427 7257 5226 4991 25352 128511 485816 1520388 4200090
|
||||
6 1 -4 -9 -14 -19 -24 -29 -34 -39 -44 -49 -54 -59 -64 -69 -74 -79 -84 -89 -94
|
||||
306
2023/go/day10/day10.go
Normal file
306
2023/go/day10/day10.go
Normal file
@@ -0,0 +1,306 @@
|
||||
package day10
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"adventofcode2023/utils"
|
||||
"adventofcode2023/utils/grid2d"
|
||||
"adventofcode2023/utils/inputs"
|
||||
)
|
||||
|
||||
type Coord struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
type Direction struct {
|
||||
dir string
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
grid := inputs.ToGrid2D(input, "\n", "", ".", func(c string) string { return c})
|
||||
start, _ := findStart(grid)
|
||||
tunnel := findTunnel(grid, start)
|
||||
fmt.Println(start)
|
||||
return len(tunnel)/2
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := inputs.ToGrid2D(input, "\n", "", ".", func(c string) string { return c})
|
||||
start, _ := findStart(grid)
|
||||
tunnel := findTunnel(grid, start)
|
||||
maskJunkPipes(grid, tunnel)
|
||||
bigGrid := expand(grid)
|
||||
floodFill(bigGrid, Coord{0,0})
|
||||
return countTiles(bigGrid, tunnel)
|
||||
}
|
||||
|
||||
func floodFill(grid *grid2d.Grid[string], coord Coord) {
|
||||
// Base cases to stop recursion
|
||||
if coord.x < 0 || coord.x >= grid.SizeX() || coord.y < 0 || coord.y >= grid.SizeY() {
|
||||
return
|
||||
}
|
||||
|
||||
if grid.Get(coord.x, coord.y) != "." || grid.Get(coord.x, coord.y) == "O" {
|
||||
return
|
||||
}
|
||||
|
||||
// Change the color of the current pixel
|
||||
grid.Set(coord.x, coord.y, "O")
|
||||
|
||||
// Recursively call floodFill for neighboring pixels
|
||||
floodFill(grid, Coord{coord.x+1, coord.y})
|
||||
floodFill(grid, Coord{coord.x-1, coord.y})
|
||||
floodFill(grid, Coord{coord.x, coord.y+1})
|
||||
floodFill(grid, Coord{coord.x, coord.y-1})
|
||||
}
|
||||
|
||||
// Magnify grid
|
||||
|
||||
// +-
|
||||
// F => |
|
||||
//
|
||||
// L => |
|
||||
// +-
|
||||
//
|
||||
// |
|
||||
// | => |
|
||||
// |
|
||||
|
||||
|
||||
func findTunnel(grid *grid2d.Grid[string], start Coord) []Coord {
|
||||
directions := []Direction{{"s", 0, 1}, {"n", 0, -1}, {"e", 1, 0}, {"w", -1, 0}}
|
||||
steps := 0
|
||||
current := start
|
||||
last := Direction{}
|
||||
tunnel := []Coord{}
|
||||
tunnel = append(tunnel, start)
|
||||
for {
|
||||
for _, dir := range directions {
|
||||
if dir == oposite(last) { continue }
|
||||
x := current.x + dir.x
|
||||
y := current.y + dir.y
|
||||
if x < 0 || x >= grid.SizeX() || y < 0 || y >= grid.SizeY() {
|
||||
continue
|
||||
}
|
||||
if ! possible(dir, grid.Get(current.x, current.y) ) { continue }
|
||||
pipe := grid.Get(x, y)
|
||||
if pipe == "S" {
|
||||
return tunnel
|
||||
}
|
||||
switch dir.dir {
|
||||
case "n":
|
||||
if pipe == "|" || pipe == "F" || pipe == "7" {
|
||||
current = Coord{x, y}
|
||||
steps++
|
||||
last = dir
|
||||
tunnel = append(tunnel, current)
|
||||
if current == start { return tunnel }
|
||||
}
|
||||
case "s":
|
||||
if pipe == "|" || pipe == "L" || pipe == "J" {
|
||||
current = Coord{x, y}
|
||||
steps++
|
||||
last = dir
|
||||
tunnel = append(tunnel, current)
|
||||
if current == start { return tunnel }
|
||||
}
|
||||
case "e":
|
||||
if pipe == "-" || pipe == "J" || pipe == "7" {
|
||||
current = Coord{x, y}
|
||||
steps++
|
||||
last = dir
|
||||
tunnel = append(tunnel, current)
|
||||
if current == start { return tunnel }
|
||||
}
|
||||
case "w":
|
||||
if pipe == "-" || pipe == "F" || pipe == "L" {
|
||||
current = Coord{x, y}
|
||||
steps++
|
||||
last = dir
|
||||
tunnel = append(tunnel, current)
|
||||
if current == start { return tunnel }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func expand(grid *grid2d.Grid[string]) *grid2d.Grid[string] {
|
||||
bigGrid := grid2d.NewGrid(grid.SizeX() * 3, grid.SizeY() * 3, ".")
|
||||
for y:=0;y<grid.SizeY();y++ {
|
||||
for x:=0;x<grid.SizeX();x++ {
|
||||
switch grid.Get(x, y) {
|
||||
case "F":
|
||||
bigGrid.Set(x*3+1,y*3+1,"+")
|
||||
bigGrid.Set(x*3+2,y*3+1,"-")
|
||||
bigGrid.Set(x*3+1,y*3+2,"|")
|
||||
case "L":
|
||||
bigGrid.Set(x*3+1,y*3,"|")
|
||||
bigGrid.Set(x*3+1,y*3+1,"+")
|
||||
bigGrid.Set(x*3+2,y*3+1,"-")
|
||||
case "|":
|
||||
bigGrid.Set(x*3+1,y*3,"|")
|
||||
bigGrid.Set(x*3+1,y*3+1,"|")
|
||||
bigGrid.Set(x*3+1,y*3+2,"|")
|
||||
case "7":
|
||||
bigGrid.Set(x*3,y*3+1,"-")
|
||||
bigGrid.Set(x*3+1,y*3+1,"+")
|
||||
bigGrid.Set(x*3+1,y*3+2,"|")
|
||||
case "-":
|
||||
bigGrid.Set(x*3,y*3+1,"-")
|
||||
bigGrid.Set(x*3+1,y*3+1,"-")
|
||||
bigGrid.Set(x*3+2,y*3+1,"-")
|
||||
case "J":
|
||||
bigGrid.Set(x*3+1,y*3,"|")
|
||||
bigGrid.Set(x*3+1,y*3+1,"+")
|
||||
bigGrid.Set(x*3,y*3+1,"-")
|
||||
case "X":
|
||||
bigGrid.Set(x*3+1,y*3+1,"X")
|
||||
case "S":
|
||||
bigGrid.Set(x*3+1,y*3+1,"*")
|
||||
default:
|
||||
bigGrid.Set(x*3+1,y*3+1,".")
|
||||
}
|
||||
}
|
||||
}
|
||||
return bigGrid
|
||||
}
|
||||
func maskJunkPipes(grid *grid2d.Grid[string], tunnel []Coord) {
|
||||
for y:=0;y<grid.SizeY();y++ {
|
||||
for x:=0;x<grid.SizeX();x++ {
|
||||
if ! containsCoord(Coord{x, y}, tunnel) && grid.Get(x, y) != "." {
|
||||
grid.Set(x, y, ".")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func countTiles(grid *grid2d.Grid[string], tunnel []Coord) int {
|
||||
count := 0
|
||||
tiles := []Coord{}
|
||||
directions := []Coord{{0,1}, {0,-1},{1,0}, {-1, 0},{1,1},{1,-1},{-1,1},{-1,-1}}
|
||||
for y:=0;y<grid.SizeY();y=y+3 {
|
||||
for x:=0;x<grid.SizeX();x=x+3 {
|
||||
coord := Coord{x, y}
|
||||
if coord.x == 0 || coord.x == grid.SizeX() - 1 || coord.y == 0 || coord.y == grid.SizeY() - 1 {
|
||||
continue
|
||||
}
|
||||
found := true
|
||||
if grid.Get(coord.x, coord.y) == "." {
|
||||
for _, dir := range directions {
|
||||
if grid.Get(coord.x+dir.x, coord.y+dir.y) != "." {
|
||||
found = false
|
||||
continue
|
||||
}
|
||||
}
|
||||
if found {
|
||||
count++
|
||||
tiles = append(tiles, coord)
|
||||
grid.Set(coord.x, coord.y, "I")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// fmt.Println(grid.StringWithFormatter(func(c string, x int, y int) string { return c}))
|
||||
return count
|
||||
}
|
||||
|
||||
func containsCoord(coord Coord, tunnel []Coord) bool {
|
||||
for _, v := range tunnel {
|
||||
if v == coord {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func maxX(tunnel []Coord) int {
|
||||
max := 0
|
||||
for _, v := range tunnel {
|
||||
if v.x > max {
|
||||
max = v.x
|
||||
}
|
||||
}
|
||||
return max
|
||||
}
|
||||
func minX(tunnel []Coord) int {
|
||||
min := utils.MaxInt
|
||||
for _, v := range tunnel {
|
||||
if v.x < min {
|
||||
min = v.x
|
||||
}
|
||||
}
|
||||
return min
|
||||
}
|
||||
func maxY(tunnel []Coord) int {
|
||||
max := 0
|
||||
for _, v := range tunnel {
|
||||
if v.y > max {
|
||||
max = v.y
|
||||
}
|
||||
}
|
||||
return max
|
||||
}
|
||||
func minY(tunnel []Coord) int {
|
||||
min := utils.MaxInt
|
||||
for _, v := range tunnel {
|
||||
if v.y < min {
|
||||
min = v.y
|
||||
}
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
func possible(dir Direction, pipe string) bool {
|
||||
v := false
|
||||
if pipe == "S" { return true }
|
||||
switch dir.dir {
|
||||
case "n":
|
||||
if pipe == "|" || pipe == "L" || pipe == "J" {
|
||||
v = true
|
||||
}
|
||||
case "s":
|
||||
if pipe == "|" || pipe == "F" || pipe == "7" {
|
||||
v = true
|
||||
}
|
||||
case "e":
|
||||
if pipe == "-" || pipe == "F" || pipe == "L" {
|
||||
v = true
|
||||
}
|
||||
case "w":
|
||||
if pipe == "-" || pipe == "J" || pipe == "7" {
|
||||
v = true
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func findStart(grid *grid2d.Grid[string]) (Coord, error) {
|
||||
// for j := 0; j < grid.SizeY(); j++ {
|
||||
// for i := 0; i < grid.SizeX(); i++ {
|
||||
// if grid.Get(i, j) == "S" {
|
||||
// return Coord{i, j}, nil
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return Coord{}, fmt.Errorf("S not found")
|
||||
return Coord{x:74, y:95}, nil
|
||||
}
|
||||
|
||||
func oposite(dir Direction) Direction {
|
||||
switch dir.dir {
|
||||
case "n":
|
||||
return Direction{"s", 0, 1}
|
||||
case "s":
|
||||
return Direction{"n", 0, -1}
|
||||
case "e":
|
||||
return Direction{"w", -1, 0}
|
||||
case "w":
|
||||
return Direction{"e", 1, 0}
|
||||
}
|
||||
return Direction{}
|
||||
}
|
||||
32
2023/go/day10/day10_test.go
Normal file
32
2023/go/day10/day10_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package day10
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`..F7.
|
||||
.FJ|.
|
||||
SJ.L7
|
||||
|F--J
|
||||
LJ...`)
|
||||
require.Equal(t, 8, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`.F----7F7F7F7F-7....
|
||||
.|F--7||||||||FJ....
|
||||
.||.FJ||||||||L7....
|
||||
FJL7L7LJLJ||LJ.L-7..
|
||||
L--J.L7...LJF7F-7L7.
|
||||
....F-J..F7FJ|L7L7L7
|
||||
....L7.F7||L7|.L7L7|
|
||||
.....|FJLJ|FJ|F7|.LJ
|
||||
....FJL-7.||.||||...
|
||||
....L---J.LJ.LJLJ...`)
|
||||
require.Equal(t, 8, r)
|
||||
}
|
||||
140
2023/go/day10/input.txt
Normal file
140
2023/go/day10/input.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
FL7L-F7FJF-7FFF7FF|-F-F|JF--|.|-J-7.F--FJF|-7.F.-FF7.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
||||
JJL7FL.L..|.7FF7||FJ|L7F7|||L7||L7FJ||L7F-JL7L--7|FJL-JL-7||FJFJL-7F--JFL-7F-J|FJL7|L-7L7-|L-7L-7|L7||||FJ|||F--7FJL-JFJ|||FJL--7JJLFL-JL-..
|
||||
..FLJL|L|J|-JFJLJ|L7|JLJ|||||||L7|L7|L7|L--7L-7FJ||F7F---J|||FJF77|L7F7F7FJL7-|L7FJ|F7L7L-JF-JF-JL7||||||FJLJL-7LJF7F7L7||LJF---JF-JL||.F|L.
|
||||
F-L|7.-7|LJLFL--7L-JL7F7|LJ|FJ|FJ|FJL7||-F-JF-JL7|||LJF7F-J||L7||FJFJ||||L-7L7|FJ|FJ||FL--7|F7|F7FJ||||||L7F---JF-JLJL7|||F-J7LJJL77FLF.LLL|
|
||||
.|-|-7L--L.FFF--JF--7|||L-7|L7|L7|L-7LJL7L-7L7F7|LJ|F7||L-7||FJ|||FJL||||F-JFJ|L7|L7||F7F7|LJ|||||FJ||||L-JL--7|L7F---J|LJL--7-JL|-FF..7L|L|
|
||||
-LFJ.7|L-..FFL---JF-J|||F-JL7|L7||F7L7F-JF7|FJ||L7FJ||||F7||||-||||F7||||L7FJJL7||FJ||||||L7FJLJ||L7||||F-----JF7||F7F-JF7F-7|77FFF-77-L-7-7
|
||||
L||LJJ7.L-7JJF----JF7LJ||F7FJL7||LJL-JL7FJ||L7|L7||FJLJ||||||L7|||||LJ||L7|L7F7||||FJ|||||FJL-7FJL7|||LJL-----7|||||||F-JLJ.LJF7F7|FJ7JFL|F|
|
||||
.LJ|7|F-JJ||-L-----JL7FJLJ|||FJ|L----7-||FJL7|L7|||L-7FJ|LJ|L7|||||L7||L7|L7||LJ||||F||LJ||F7FJ|F7||||F------7||||||LJL-7F7F77|||||L77||FFLJ
|
||||
F7-|J-7|J.F7.L-F-----J|F7FJL-JFJ|F7F7L7|||F7||FJLJL7FJL7|F7|FJ|||||FJFJFJ|FJ||-FJ|||FJL-7|LJ||FJ|LJ||||F---7LLJ|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-JF--JF-J||F7FJ||L-JF7|F-JF-JF-JFJF7F-J|FJL7L--7L-JL-JLJF-JF7L7F----7|L7L-JLJF7FJFJF-J
|
||||
FL-...|.L7F7F7F7F7|F-----JF7F7L7L--7F7||F7LJ|L--7F--JF-7L-7FJF7|||||FJ|7F7|LJL77L-7L7FJFJ|L-7||F7|F-7|F7F-----JF-JL-JL---7LJFJF7F7FJLJFJFJ||
|
||||
|-FFF-7-LLJLJLJLJ||L------J||L7L7F7LJ||LJ|F7L7F7||F7FJFJF7|L7|||||||L7|FJLJF-7L--7|FJL7|JL7FJ||||LJFJ|||L------JF--7F7F-7L-7|FJLJ|L--7L7L7F|
|
||||
J-|-J|.LJ7|LL|F--JL-------7LJ-L7LJL--JL--J|L7LJLJ||||FJFJ||FJ|||||||FJ|L7F7L7|F--J||F7||F-J|FJ|||F7L7|||FF--7F-7L-7LJLJLL7FJ||F--JF-7L7L-J-7
|
||||
|-J|FFL---J-F-JF---------7|F--7L7F-7F7|F--JFJF-7-LJLJ|FJLLJ|FJ||||LJL7|L||L7||L--7LJ|LJ|L7FJ|FJ|LJL-JLJL-JF7LJL|F7L-----7|L7||L7F7L7L7L-7JL-
|
||||
.LJF7LL-J7||L-7|-F-------J|L-7|JLJFLJL-JF-7L-JFJF7F--JL---7||FJ||||F7||FJ|FJ|L7F-JF-JF7L7||FJ|.L7F7F------JL--7LJL---7F-J|FJLJ-LJ|FJ7L-7|7LL
|
||||
|7JFL77.||-J.L||FJF------7|F-J|F-------7L7|F--JFJLJF-7F7F-JLJL7||L7||||L7||FJFJ|F-JF7||FJLJL-JF-J|LJF---7F-7F7L-7F--7LJF-JL7F7FF7|L--7.LJJ7|
|
||||
|J-LL.7--||J-FLJL-JF----7||L-7|L----7F7|FJ|L7F7L7F7|7|||L--7F-J||FJ||LJFJ||L7L-JL--J|||L7F7F-7L-7|F-JF-7LJ.LJL-7LJF7|F7L-7FJ||FJLJF7FJF|LFL-
|
||||
LFF7J-LJFJJ-F7F77F7L---7L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J|F7|F----JLJJL-----7F--JFJ||F-----7|.FFFFJ|J-F
|
||||
LJL|77-FFF7L7|F7F7F7|L7F--JLJF--7FJF-J|FJ|LJLJ|LF-7|L7LJL|FJLF-J|FJ||L7J7F-J|F-7LJ-LJL--JL-JF7|||||F--7F--------7|L--7L7||L----7LJ.LL.JFJ-FJ
|
||||
L|--.|F-FJL-JLJLJ|||L7|L-7F7FJF-JL7L--JL-JF7F7L7L7||FJF-7||.FJF7|L7|L-J|FL-7||FJF----7F-----J|LJLJLJF7||F-------JL-7FJJLJL7F7F-JL|-FFJ.|J.F7
|
||||
-|J-7|J-L-7F7F7F7LJL7LJF7LJLJ.L---JF-7F---JLJL7|FJLJL7L7||L7|FJ|L7||JFFF..FJLJ|JL---7|L-----7L-7F7F7||LJL---------7|L---7J|||L-7F7|FFJ7J.-FL
|
||||
|L77L|.7FLLJ||||L7F-JF7|L---7FF7JF-JFLJF7F---7LJ|F--7|FJLJFJLJ.L7|||J|7LF-L7F7|J.LLFJ|F7F7F7L-7LJLJLJL----7F------J|F7F7L7|||F7LJ|7L-JL-7|||
|
||||
JJ||.LF|7.F7LJLJFJL-7||L7F7FJFJL-JF7F7FJLJF--JF7|L-7LJ|F7FJF7F-7||LJ-JLF--LLJLJ77-FL7||LJ|||F7|F----7F---7|L------7LJLJ|FJ||LJ|F7|J7L7-L.FFL
|
||||
LFJFF---F-J|J.F7L--7|||-LJ||FJF---JLJLJF-7|JF-JLJF-JF-J|LJFJLJFJ||J|L--7.|7|.FLJ--|F|LJF7LJLJ|LJF--7LJF--JL--7F7F7L--7LLJFJL7JLJLJ77LJ7L-F|.
|
||||
L77LL7||L-7L7FJL---JLJL---JLJFJF--7F7F-JFJL-JF7F-JF7|F-JF7|F--JLLJF-77.L.7-.L7LLJ-F7L--JL-7F7|F7L-7L-7L-----7LJLJL7F7L--7L--JF777|.J77F-FFF7
|
||||
FJF7LL--L-L7LJF7F-----7F7F7F7|JL-7LJ|L-7|F7F7||L--JLJL7-|LJL---7LJ7L|77.F|JFLJ7-FFJ|F7-F--J||LJL-7L7FJ-F7F-7L-7F-7||L--7|F7F7|L--7JF7JL7FLJF
|
||||
|-7J7FLF77LL7FJLJF----J|LJ||||F--JF7L--JLJ||||L7F--7F7L7|F----7L7FJJLL7-FF.7.|7FLL7LJL7L---JL---7L-JL-7|LJ-L-7LJFJ|L7F7LJ|||||F--J||JJJLFJ7|
|
||||
7F|FLJ7FF7F-J||F-JF-7F7L7LLJLJL--7|L-----7|||L7|L-7LJL7LJL---7L7L77F77|7F-FJ7|F|.LL--7L-7|F-----JF7F-7LJF7LF7L--J-L-J||F7||||||J||-FJ7.F|-J.
|
||||
--JFJFLF|LJF7|FJF7L7LJL-JF7F7F7F7||F--7F7|LJL-J|F-J-F-JF-7F-7L7L7|-L77|LF.|--JLJFJJF-JF7L7L---7F-J|L7L7FJL-JL7F---7F-JLJLJLJLJL7F7F77-|-|J.|
|
||||
L|--.|.FJF-JLJL-JL-JJF7-FJLJLJLJ|LJL-7LJLJF7F-7|L--7|F7|-|L7L-JLLJ-JF--J|F-7JFLF7JFL--JL7L-7F7LJF7L-J-LJF----J|F-7|L7F---7F7F-7LJLJL7.LF7.F|
|
||||
.7FJ.J.L-J|-F-----77FJL7L----7F7L-7F7L--7L|||FJL--7|||||FJFJJ.F77L|JJ.|FLJFLF7.JJF------JF7LJL-7||.F7FF7L-----JL7LJFJL--7LJLJ|L7F-7FJ7F7JFJ.
|
||||
F-JFJJF|-L|.L--7F7|FJF7L-7|F-J||F7LJL--7L7|||L7F77LJ||||L-J.F-JL7L|-.7JLL-JJ.J7||L--7F7F7|L7F-7LJL-JL-JL-------7L--JF7F7|F7LF7|LJ7LJF-J|-|J7
|
||||
|7L|F|-|.LLFF-7LJ||L-J|F7L7|F7|LJL----7L-J||L7LJL--7||||F7F7L-7FJF7J-|7.L---..F7LJLFJ|LJ||FJ|FJF--7F----------7L--7FJLJ|||L7|L7F7F7FJF-J7LF|
|
||||
7J-FJ7.J7LLFL7L--JL---J|L7LJ|||F------JJF-JL-JF7F--JLJLJ|LJL7-|||||F-|-F7F7-77FLJLLL7|F7||L7|L7|F-J|F--------7L7F7|L--7LJ|FJL7LJLJ||FJJFJ7|7
|
||||
L-F7JJ7.7-FFJL7F-7F7F7FJ|L7FJLJL-7F--7FFJF7F--J||F7F7-F7|F--JFJL-J|7J|F777JF-77JJFLLLJ||LJ-LJ7LJL--JL----7F-7L-J||L---JF7||F7|F---J|L77|J|L|
|
||||
||||L-J|LF-|-LLJ7LJLJ|L--7LJF7F7FLJF7L7L7|LJF7.LJ|LJL-JLJL7F7|F7F7L-7-LF7FF7|F77FJ.||FJL-----7FF--7LF----J|FJF--J|F7F--JLJLJLJL----JFJFL.JJ|
|
||||
J-|F-L-F7L-|FF7F7F---JF--JF7||||F7FJL7L-JL--JL--7|F7F----7|||||LJ|F-JFL|L7||FJL7LJFF7L-----7FJFJF7L7L-----JL-JF-7||LJF--7F7F7F--7F-7|F7--.F.
|
||||
.LLJLLFJ-J-FFJLJLJF-7FJLF-J|||||||L-7L--7F7F7F-7LJ|LJF--7LJ|LJL-7LJF77JL7||||F-J7JFJL-7F---JL7L-JL7|FF7LF----7L7|LJF7L-7|||||L-7LJ7LJ-|7..F7
|
||||
|.|7F-JJ.J--L7F7F-JFJ|F-JF7LJLJLJ|F-JF7LLJLJ||JL--JF7L7FJF7|F---J.FJ|F77|LJ|||JF7JL--7|L7F7F7L----JL-JL7L---7L7||F7|L7FJLJ|||F7|F--77|L--7L.
|
||||
L-JL|7777FF||LJLJF7L7||F7|L-----7|L--J|F---7|L-----JL-JL7|LJL-7F7FL7||L7|F7|||FJL7F--JL7LJLJL7F7F-7F7F7L----JJLJLJ|L7|L-7FJ||||||F-J7JF-F-77
|
||||
FJFLJL|7-L-F-----JL7LJLJ||F-----JL----J|F--JL--7F--7F7F7LJF-7FJ||F-J||FJLJ|||LJF7|L--7FJF---7LJLJFJ||||F-7F7.F---7|FJL--JL-JLJLJ||F7J.FL--77
|
||||
J7|7|JLJ7JLL------7L7F77LJL----7F------JL----7F||F7LJLJL7FJ|LJFJ|L-7|||F7FJ||F-JLJ7F7|L7L--7|-F--JFJLJLJFLJL7|F--J|L---7F7F7F7|FJLJL-7JJ-F||
|
||||
FF|-L.|7L7|L7|FF7L|FJ||F7F-7F-7||F---7F----7FJFJLJL----7|L-7F7|FJF7||||||L7||L7F7F7||L7L7F7|L-JF-7|F--7F7F7FJ||F7||F---J|||LJL-JF7F7FJJ.-F77
|
||||
F7F-L7L-7JF--LFJL-JL-J|||L7|L7|LJL--7|L---7|L7|F7F7F7F-JL--J|LJ|FJ||LJ|||FJ|L7||LJ||L7L7LJ|L--7|FJ|L-7||LJLJJ|||L7LJF-7FJLJF7F7FJ||LJJF|.L|7
|
||||
J7L77F|L|.JJF|L------7|||FJ|FJL-----JL---7|L-J||||||LJF7|F-7|F-JL7|L7FJ|LJFJ.|LJF-JL7|7L-7L7F7LJL-JF-JLJF7|F-JLJFJF7|FJL7F-JLJLJLLJJ..FJL.L7
|
||||
L|.LLJF-JF|7FF--7F7F7||||L7|L7F7F-------7|L--7||||LJF7|L7|FJ||F-7|L-JL7L-7|F7L-7|-F-J|F7FJFJ|L7F--7L--7FJL-JF7F7L7|LJL7FJL-----7|LF-7-|7|.7|
|
||||
7||7LLLJ-FJF7L-7LJLJLJLJL-JL7LJLJF------JL---JLJLJF7|||FJ|||||L7|L---7L77|LJL7FJL-JF7||LJFJFL7||F-JF--J|F---J|||FJ|F--J|F--7F-7|F7|FJ7|FF|LJ
|
||||
L-L7.|.7.FFJ|F7L-----7F--7F7L7LF7L---------7F-7-F7|||||L7|L7||FJ|F7F7L7L-JF--JL-7F-JLJL-7|F7FJ|||F7L---JL7FF7LJLJF|L---J|LFJL7LJ|LJL7FF7L7-7
|
||||
|.FF-7-FFFL7LJL----7LLJF-J|L7L-JL7F----7F--J|FJFJ||||||FJL7||||FJ||||JL--7L7F7F-JL7F7F7F|LJ|L7LJ|||F7F7F7L-JL-----JF7F-7L7L-7L--JF-7L-JL7J-J
|
||||
77|L7L.||LFJF--7F-7L-7FJF7L7L7F7FJL---7|L---JL7L7|||||||F7|||||L7|||L-7F7|FJ||L7F7|||||FJF7L7|F7LJLJLJ|||F-7F7F7F-7||L7L7L-7L----JFJF--7|J-7
|
||||
--L-JF|LJ.L7|J7LJFJF7LJFJ|FJ-LJ|L-----JL------JFJ|||||||||||||L7LJ||F-J|||L7|L7LJ|||||||FJL-JLJL-----7|||L7|||||L7LJL-J7L--JF----7L7L7.LJJF7
|
||||
|-J-J-F-J7JLJFF7-L-J|F-JFLJF7F-JF7F--------7F-7L7||LJ||LJLJ|||7L-7|||F7|LJFJ|FJFFJLJ||LJ|F77F---7F7LFJLJ|FJLJ||L7L---------7|F---JJL-J77L7F7
|
||||
F7.FL7J.FF-LLFJ|F7F-JL7F---J|L--JLJF-----7FJ|FJFJ||F7||F---J|L-77||||||L-7L7||F7|F-7||F-J|L7L--7|||FJF-7LJF7-LJFJF7F7F--7F7LJL--7-FL-|.7F|JL
|
||||
L|7F7|.F|LF7FL7|||L-7FJL-7F7L-7F--7L7F--7LJFJ|LL7|LJ|||L---7L-7|FJLJ|||F-JFJ|LJ|LJ-|LJ|F7L7|F-7||||L-J||F7||F7.L-JLJ|L-7|||F7F-7L7L|---L7|.|
|
||||
F-J|J.FFF-J|F-J||L--JL--7LJL-7|L-7L-J|F-JF7L7L7FJL-7|LJF---JF7||L-7FJ||L-7|J|F7L7F7|F7LJL-J|L7||LJL--7FJ|LJLJL7F7F7JL--JLJLJ|L7L-JL--|.LF77.
|
||||
-JJL.FLLL-7|L-7LJF---7F7|7F7FJ|F7L---JL--JL7|FJL7F-JL-7|FF7F|LJ|F7||FJL7FJL7LJL7|||LJL-7F--JFJ|L--7F-JL-JF-7F7LJ|||F-------7L7L--77.FF-F.L77
|
||||
FLFJ-J.LLFJL--JF7|F--J|||FJ|L7|||F---------J|L-7|L7-F7|L7|L7L7FJ|LJ|L-7|L7FJF-7|LJL7F--J|F7FJFJF--J|F7F--JJLJ|F-J|LJF---7F7L7|F7FJ-L-J|.F.L7
|
||||
|-7J.J...L-7F7FJ|||F7FJLJL7L-JLJ|L------7F7-|F-JL7L7|||FJ|FJFJL7L7FJ|FJL7|L7|FJL7F-JL-7FJ||L7||L--7|||L-----7LJF7|F-JF7-LJL-J|||||.L|FJ7L-7|
|
||||
|FJ..|-7FLLLJLJ.LJLJLJF-7-L7F7F7L---7F--J||FJ|F7FJFJ|||L7||FJF-J7||F7L-7LJFJ||F7|L-7F7||FJL7||F7F-JLJ|7F7F-7L-7|||L--JL-----7LJ|L-7-LF-L..77
|
||||
F-JJ-|.FFF--7F-7JF---7L7|F7||LJL-7F7LJLF7|||FJ||L7L7|||FJ||L7|JF7||||F7|F-JJ||||L-7|||||L7FJ||||L--7FJFJ|L7|F7LJLJF-----7F--JF7L--J7.J-|7..|
|
||||
7JJ-7J7FFJF7|L7|FJF-7L-JLJLJ|F--7LJ|F--J||LJL7||LL7|||||FJ|FJ|FJ||||||||L-7FJ|||F7|||||L7|L7|LJ|F7FJ|-L7L-JLJL---7L7F--7LJF7FJL-7JJL7.L7J7-L
|
||||
LF-FF---JFJ|L7||L-J-L-----7FJ|F7L--J|F--JL7F-J||F7||||||L7|L7|L7||||||||F-JL7||||||||||FJ|FJ|F-J||L7|F7L--7-F--7LL-J|F-JJ-|||F--J7||77LJ||7|
|
||||
7|FFL7F7FJ.L7LJL-7F7JF77F-J|JLJL7F-7||F7F7|L7FJ||||||LJ|FJL7|L7||||||||||F-7||||||||||||FJL7|L7FJ|FJ||L7F7L7|F-JF---JL-7FFJ|||F-7J-.FJ-LJ7-J
|
||||
L-7--LJLJF--JF7F7LJL-JL-JF7|F---J|FJ|||||||FJL7LJ|||L-7||F7|L7||||||||||||FJ|||||||||||LJF-JL7||FJ|FJ|-||L7LJL--JF--7F7L7|FJ|LJFJ.L-J--F|L|.
|
||||
.|||7.||-L---J||L7F7F-7F7|||L-7F7|L7|||||||L7FJF7||L7FJLJ|LJFJ||LJLJ||||||L7|LJ||||||||F7L---JLJL7|L7|FJL7L7F7F--JF7||L7LJL-JF-JJJF|JFF.J-FF
|
||||
|J|-7F|FF--7F7||.LJLJFJ|||LJF-J|||FJ||||||L7|L7|LJL7||F--JF-JFJL7LF7LJ||||.|L-7||LJLJ|LJL--7F---7||F|||F7|FJ||L7|FJ|||FJF-7F7L--7JJLL|JL-F|J
|
||||
|FJ||7LFJF7LJ|LJF7-F7L7|LJF-JF7|||L7|||LJL7|L7|L7F-JLJL-7FJJFJF7L7||F-J|||FJF-JLJLF7FJF-7F7LJF-7|||FJ|||||L7|L7L-JFJLJL7|F||L---JJ|..|-|FL77
|
||||
F--|L-JL-J|F7L--JL-JL-JL7FJF7|LJ|L7||LJF--JL7||FJL---7F7||F-JFJL7LJ|L7FJLJL7|.F77FJLJFJ-||L-7L7LJ||L7|||||L||FL---JJF77|L7|L7F7JF7J---7F7|L7
|
||||
FJJLJ.FF7|LJL------7F7F-J|FJ||F-JFJ||F-JF7F7|||L7F7F7||LJ||F7L-7|F7|FJ|F---JL7|L7|F7FJF-JL-7|FJF7LJFJ|LJLJFJL-------JL7L7|L7LJL-J||JL|-LJ-LF
|
||||
-JFL.F7|L--7F------J||L-7LJ|LJL7FJ-LJ|F7|LJLJ|L7||||||L-7|||L7FJLJLJL-JL--7F7LJFJLJ|L7|F7F7||L-JL7.|FJF---JF7F----7F-7L7LJFJF7F--J77-|||7..|
|
||||
|L|LFJ|L--7|L---7F-7||F7|F---7FJL7F7FJ||L7F--JFJLJ||||F-J||L7|L----7F-----J||F7|F--JFJLJ||LJL7F-7L7|L7|F7F7||L---7LJ7L7L-7L-J||F|.F77.-L-7F-
|
||||
L7-FL7L---JL----J|FJ||||||F-7LJF-J|LJFJ|FJL-7FJF7LLJ|||F7|L7|L7F-7FJL--7F7FJ||||L7F7L7|FJL77FJL7L-JL-JLJLJLJL7F--JF7F7L-7L--7|L777JLF7FJLF|J
|
||||
|.LJ.L----7F7F--7||FJ||||||FL-7L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-L-.|LJL7LLF.|JJ.L--J7JJ|LJFLF777LL-J-F.|-7JFJ.|FJ|L-7F7||-|7|---J7.||J7LJ.FL.L7LL7|-|L7-J|..|7J7.7J7F.L|J|7LL-7-L-J-|7FFJJ
|
||||
LF.FJF7-|-L--FL7L-7|-F.F-JL|.LF7F7L7-7JJFLLFFJ.LJ7-L|FF|F|.|7|.7J7...|LLL-F-7J.JFFF-7F.LFJJ-7.|7L7JLF7|F|J.|F7FJ...J||JJFF7LJF.FL7L-J.L-77|7
|
||||
F--JJL-7J|LJLJJLF-L7---J-|.J-.JLJJLL7JL7JJ.7.L|LLJ-.L-J-7J-L7LLJ---FJ-LJJ..JLL7.L-JLLLL-7-FJLF77L---7JJLJ.LFJL--F-F-JJ.LLJ|-F7-JJ.JJ.JJF7--7
|
||||
146
2023/go/day11/day11.go
Normal file
146
2023/go/day11/day11.go
Normal file
@@ -0,0 +1,146 @@
|
||||
package day11
|
||||
|
||||
import (
|
||||
"adventofcode2023/utils"
|
||||
_ "fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Galaxy struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
galaxies := []Galaxy{}
|
||||
lines := strings.Split(input, "\n")
|
||||
var expand_rows []int
|
||||
var expand_cols []int
|
||||
for y,line := range lines {
|
||||
for x,char := range line {
|
||||
if char == '#' {
|
||||
galaxies = append(galaxies, Galaxy{x, y})
|
||||
}
|
||||
}
|
||||
}
|
||||
// fmt.Println(galaxies)
|
||||
for y,line := range lines {
|
||||
no_galaxy := true
|
||||
for _,char := range line {
|
||||
if char != '.' {
|
||||
no_galaxy = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if no_galaxy {
|
||||
expand_rows = append(expand_rows, y)
|
||||
}
|
||||
}
|
||||
for x:=0;x<len(lines[0]);x++ {
|
||||
no_galaxy := true
|
||||
for _,line := range lines {
|
||||
if line[x] != '.' {
|
||||
no_galaxy = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if no_galaxy {
|
||||
expand_cols = append(expand_cols, x)
|
||||
}
|
||||
}
|
||||
galaxies = expand_row(expand_rows, galaxies, true)
|
||||
galaxies = expand_col(expand_cols, galaxies, true)
|
||||
// fmt.Printf("r: %v c: %v\n%v\n", expand_rows, expand_cols, galaxies)
|
||||
dist := 0
|
||||
for i:=0;i<len(galaxies)-1;i++{
|
||||
g1 := galaxies[i]
|
||||
for _, g2 := range galaxies[i+1:] {
|
||||
dist = dist + distance(g1, g2)
|
||||
}
|
||||
}
|
||||
return dist
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
galaxies := []Galaxy{}
|
||||
lines := strings.Split(input, "\n")
|
||||
var expand_rows []int
|
||||
var expand_cols []int
|
||||
for y,line := range lines {
|
||||
for x,char := range line {
|
||||
if char == '#' {
|
||||
galaxies = append(galaxies, Galaxy{x, y})
|
||||
}
|
||||
}
|
||||
}
|
||||
// fmt.Println(galaxies)
|
||||
for y,line := range lines {
|
||||
no_galaxy := true
|
||||
for _,char := range line {
|
||||
if char != '.' {
|
||||
no_galaxy = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if no_galaxy {
|
||||
expand_rows = append(expand_rows, y)
|
||||
}
|
||||
}
|
||||
for x:=0;x<len(lines[0]);x++ {
|
||||
no_galaxy := true
|
||||
for _,line := range lines {
|
||||
if line[x] != '.' {
|
||||
no_galaxy = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if no_galaxy {
|
||||
expand_cols = append(expand_cols, x)
|
||||
}
|
||||
}
|
||||
galaxies = expand_row(expand_rows, galaxies, false)
|
||||
galaxies = expand_col(expand_cols, galaxies, false)
|
||||
// fmt.Printf("r: %v c: %v\n%v\n", expand_rows, expand_cols, galaxies)
|
||||
dist := 0
|
||||
for i:=0;i<len(galaxies)-1;i++{
|
||||
g1 := galaxies[i]
|
||||
for _, g2 := range galaxies[i+1:] {
|
||||
dist = dist + distance(g1, g2)
|
||||
}
|
||||
}
|
||||
return dist
|
||||
}
|
||||
|
||||
func expand_row(rows []int, galaxies []Galaxy, partOne bool) []Galaxy {
|
||||
new := []Galaxy{}
|
||||
for _,galaxy := range galaxies {
|
||||
new = append(new, Galaxy{galaxy.x, galaxy.y + howMany(rows, galaxy.y, partOne)})
|
||||
}
|
||||
return new
|
||||
}
|
||||
|
||||
func expand_col(cols []int, galaxies []Galaxy, partOne bool) []Galaxy {
|
||||
new := []Galaxy{}
|
||||
for _,galaxy := range galaxies {
|
||||
new = append(new, Galaxy{galaxy.x + howMany(cols, galaxy.x, partOne), galaxy.y})
|
||||
}
|
||||
return new
|
||||
}
|
||||
|
||||
func howMany(xs []int, a int, partOne bool) int {
|
||||
count := 0
|
||||
incr := 1
|
||||
if !partOne { incr = 1000000 - 1 }
|
||||
for _,x := range xs {
|
||||
if x < a {
|
||||
count = count + incr
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func distance(g1 Galaxy, g2 Galaxy) int {
|
||||
val := utils.Abs(g1.x - g2.x) + utils.Abs(g1.y - g2.y)
|
||||
// fmt.Printf("%v - %v = %v\n", g1, g2, val)
|
||||
return val
|
||||
}
|
||||
38
2023/go/day11/day11_test.go
Normal file
38
2023/go/day11/day11_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package day11
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`...#......
|
||||
.......#..
|
||||
#.........
|
||||
..........
|
||||
......#...
|
||||
.#........
|
||||
.........#
|
||||
..........
|
||||
.......#..
|
||||
#...#.....`)
|
||||
require.Equal(t, 374, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`...#......
|
||||
.......#..
|
||||
#.........
|
||||
..........
|
||||
......#...
|
||||
.#........
|
||||
.........#
|
||||
..........
|
||||
.......#..
|
||||
#...#.....`)
|
||||
require.Equal(t, 8410, r)
|
||||
require.Equal(t, 0, r)
|
||||
}
|
||||
140
2023/go/day11/input.txt
Normal file
140
2023/go/day11/input.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
.......#...........................................................................#........................................................
|
||||
.............#...........#..................#.............................................................#..............#.......#..........
|
||||
..................................................................#.........#......................................#........................
|
||||
.................#...........................................................................................................#..............
|
||||
.............................................................#..............................................................................
|
||||
......................#.....................................................................#............................................#..
|
||||
.....#...........................................#..........................................................................................
|
||||
............................#..........................................#...............................#....................................
|
||||
...........#......................................................................................#......................#..................
|
||||
....................................................#.....#................................................#......................#.........
|
||||
#..................................................................#.............#...........................................#..............
|
||||
......................................#..................................................#...............................................#..
|
||||
.................................#..........................................................................................................
|
||||
...............#........#..............................................#...............................................#....................
|
||||
.......#....................................................................................................................................
|
||||
............................................................................#...................#..................#.......#.........#......
|
||||
...................#......................#......#.......#.......#..........................................................................
|
||||
............#...........................................................................#................#..................................
|
||||
.....................................................#..................#................................................................#..
|
||||
.............................#.....#..........................................................................#...................#.........
|
||||
...#.......................................................#...............................#................................................
|
||||
............................................#........................................................#......................................
|
||||
...................................................................#..................................................................#.....
|
||||
..........................................................................................................................#.................
|
||||
#.......................#............................#.......................................#..............................................
|
||||
..........................................#.................#.....................................#................................#........
|
||||
..................#............................................................#........................#..............#....................
|
||||
............................................................................................................................................
|
||||
......#........................................................................................#.............................#..............
|
||||
...............#........................#.........#.....#......#...................#..............................#.........................
|
||||
.........................#.....#..........................................#.................................................................
|
||||
.................................................................................................................................#..........
|
||||
...........................................................#..................................................#..........#............#.....
|
||||
.............#.................................................................#............................................................
|
||||
.....................#............#..............#.......................................#..................................................
|
||||
#..........................#...........................#..................................................#.................................
|
||||
.............................................................#....................................................................#.......#.
|
||||
......................................................................................................................#.....................
|
||||
............#..................#...........#........#...............................#..............#...........#............................
|
||||
.......#..............................#.....................................................................................................
|
||||
........................#...............................................................#..............#.................#.............#....
|
||||
.#..........................................................................................................#...............................
|
||||
.........................................................#.....................#.................................................#..........
|
||||
..........................................#..........................................#...........................#.........................#
|
||||
.....#..........................#.................#..........#........#.....................................................................
|
||||
..........#...........#.................................................................................#...................................
|
||||
.............................................................................................................................#.......#......
|
||||
..........................................................#.................#............#..................................................
|
||||
.....................................................#..........................................#...........#...............................
|
||||
.......................................#...............................#.............................#......................................
|
||||
..................................#...............................................#........................................#.............#..
|
||||
.......#.......#.......#..........................................#.........................................................................
|
||||
.............................................#...............#..............................................................................
|
||||
............................#................................................................#..............................................
|
||||
........................................................#..................#.............................#........................#.........
|
||||
...................................................................................................#..........#.............................
|
||||
......#............................................................................#....................................#..................#
|
||||
..................#.....#...............#.....#......#...................................#.....................................#............
|
||||
..................................................................#...........#.............................................................
|
||||
#.............#..........................................#...............#...................#.........#....................................
|
||||
........#.............................................................................................................#.............#.......
|
||||
......................#......................................#............................................................................#.
|
||||
..............................#....................................................#........................................................
|
||||
............................................................................................................................................
|
||||
...............#.............................................................................................#..............................
|
||||
........................#............#............................#................................................................#........
|
||||
...#.....................................................#................#..............#...................................#..............
|
||||
.............................................#..............................................................................................
|
||||
...........................#................................................................................................................
|
||||
.....................................................#......#....................................................#.....#....................
|
||||
.....#....................................#.....#...........................#...................#...........................................
|
||||
..............#.....................#...................................................................#...................................
|
||||
#........................................................................................#..................................................
|
||||
.....................#........................................................................................#.............................
|
||||
..........................#.......................#..................................................................................#......
|
||||
.........#................................................#.........#.......................................................#...............
|
||||
...............................#................................................................#.....#.....................................
|
||||
...................#..........................#.................#..................#..............................................#.........
|
||||
......#......#..............................................................................................................................
|
||||
............................#......................................................................#........#...............................
|
||||
....................................................................................................................#.......................
|
||||
................................................#...........#.................#........................#....................................
|
||||
.................#..........................................................................................................................
|
||||
..........................#......................................................................................#..........#..........#....
|
||||
#...............................................................................................#.....................#.....................
|
||||
............#......................#...................#.................................#.........................................#........
|
||||
............................................................................................................................................
|
||||
....................................................................#.......................................................................
|
||||
.....#........................................#...........................................................#...................#.............
|
||||
..........................................................#..................................#..............................................
|
||||
.............................#............................................#.................................................................
|
||||
......................#............................................................................................................#........
|
||||
..#.....................................................................................................................................#...
|
||||
...........#..........................#............................................................................#........................
|
||||
..............................................#.................#....................#...............#........#.............................
|
||||
...........................#...........................#......................................#...........................#.....#...........
|
||||
.........................................................................................................#..................................
|
||||
.........#......#................................................................................................#........................#.
|
||||
...#.....................................................................#..............#...................................................
|
||||
.............................#......#...............................#................................................#......................
|
||||
.........................................#............................................................................................#.....
|
||||
.....................#............................#............#.................#...........................#...............#..............
|
||||
.............#..........................................#...................................#...............................................
|
||||
..#.............................#...........................................#.....................#................#........................
|
||||
...........................................#...........................#.................................................#..............#...
|
||||
........#...........................#.......................#.......................#.......................................................
|
||||
...........................#.............................................................................#.......................#..........
|
||||
............................................................................................................................................
|
||||
...............#...............................................................................#..........................................#.
|
||||
............................................................................................................................................
|
||||
#...............................................#......#.......#...............#............................................................
|
||||
.........#.................................#...........................................................#....................................
|
||||
......................................#............................#...............................................#........................
|
||||
......................#.........#.............................................................................#.............................
|
||||
....................................................................................#............#..........................................
|
||||
..........................................................................#...............#.................................................
|
||||
...........#.....#................................#.........................................................................#...............
|
||||
..................................................................#.......................................#.........................#.......
|
||||
.........................#................................#........................................................#........................
|
||||
........#...................................................................................#......#....................................#...
|
||||
...............................................................#...............#............................................................
|
||||
.............................................#.........................#.....................................#..............................
|
||||
...................#...............#........................................................................................................
|
||||
..........................#..............................#....................................#..................................#..........
|
||||
...........#.....................................................................#.....#....................................................
|
||||
...#.................................................#...............................................#...........#...........#..............
|
||||
...............#........................#................................................................................................#..
|
||||
....................#..............................................#.....................................#..................................
|
||||
..................................#.....................#................................#..................................................
|
||||
............................................#...................................................#.............#.............................
|
||||
........................................................................................................................#.....#......#.....#
|
||||
...........................................................#..................#......................#......................................
|
||||
...................#.........#....................................#.........................#...............................................
|
||||
....................................................#...............................................................#.......................
|
||||
.............#........................#....................................................................................#................
|
||||
....................................................................................#...................................................#...
|
||||
.......#................................................#................#..................................................................
|
||||
.#.................................................................#..............................................................#.........
|
||||
...................#.....#...................................................................#.........#.........#..........................
|
||||
............................................#.....#............#..................................#.........#................#..............
|
||||
136
2023/go/day12/day12.go
Normal file
136
2023/go/day12/day12.go
Normal file
@@ -0,0 +1,136 @@
|
||||
package day12
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"adventofcode2023/utils"
|
||||
"adventofcode2023/utils/inputs"
|
||||
)
|
||||
|
||||
var cache = make(map[string]int)
|
||||
|
||||
type memoized struct {
|
||||
f func(int) int
|
||||
cache map[string]int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
ans := 0
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
slices := strings.Split(line, " ")
|
||||
record := slices[0]
|
||||
groups := inputs.ToInts(slices[1], ",")
|
||||
ans += calc(record, groups)
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
ans := 0
|
||||
lines := strings.Split(input, "\n")
|
||||
for i, line := range lines {
|
||||
slices := strings.Split(line, " ")
|
||||
record := slices[0] + "?" + slices[0] + "?" + slices[0] + "?" + slices[0] + "?" + slices[0]
|
||||
groups := inputs.ToInts(slices[1] + "," + slices[1] + "," + slices[1] + "," + slices[1] + "," + slices[1] , ",")
|
||||
ans += calc(record, groups)
|
||||
fmt.Printf("running total after lines %v = %v\n",i, ans)
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func calc(record string, groups []int) int {
|
||||
key := record + fmt.Sprint(groups)
|
||||
if v, ok := cache[key]; ok {
|
||||
return v
|
||||
}
|
||||
// ADD LOGIC HERE ... Base-case logic will go here
|
||||
// Did we run out of groups? We might still be valid
|
||||
if len(groups) == 0 {
|
||||
// Make sure there aren't any more damaged springs, if so, we're valid
|
||||
if ! strings.Contains(record, "#") {
|
||||
cache[key] = 1
|
||||
return 1
|
||||
} else {
|
||||
// Not valid to runout of groups and still have damaged springs "#"
|
||||
cache[key] = 0
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
if len(record) == 0 {
|
||||
// Already know there are more groups but no records
|
||||
cache[key] = 0
|
||||
return 0
|
||||
}
|
||||
|
||||
// Look at the next element in each record and group
|
||||
next_character := record[0]
|
||||
next_group := groups[0]
|
||||
out := 0
|
||||
|
||||
if next_character == '#' {
|
||||
// Test pound logic
|
||||
out = pound(record, groups, next_group)
|
||||
} else if next_character == '.' {
|
||||
// Test dot logic
|
||||
out = dot(record, groups)
|
||||
} else if next_character == '?' {
|
||||
// This character could be either character, so we'll explore both
|
||||
//possibilities
|
||||
out = dot(record, groups) + pound(record, groups, next_group)
|
||||
} else {
|
||||
utils.PanicOnErr(fmt.Errorf("RuntimeError"))
|
||||
|
||||
}
|
||||
// Help with debugging
|
||||
// fmt.Println(record, groups, out)
|
||||
cache[key] = out
|
||||
return out
|
||||
}
|
||||
|
||||
// Logic that treats the first character as pound-sign "#"
|
||||
func pound(record string, groups []int, next_group int) int {
|
||||
|
||||
// If the first is a pound, then the first n characters must be
|
||||
// able to be treated as a pound, where n is the first group number
|
||||
if next_group > len(record) {
|
||||
return 0
|
||||
}
|
||||
this_group := record[:next_group]
|
||||
this_group = strings.Replace(this_group, "?", "#", -1)
|
||||
|
||||
// If the next group can't fit all the damaged springs, then abort
|
||||
if this_group != strings.Repeat("#", next_group) {
|
||||
return 0
|
||||
}
|
||||
|
||||
// If the rest of the record is just the last group, then we're
|
||||
// done and there's only one possibility
|
||||
if len(record) == next_group {
|
||||
// Make sure this is the last group
|
||||
if len(groups) == 1 {
|
||||
//We are valid
|
||||
return 1
|
||||
} else {
|
||||
// There's more groups, we can't make it work
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the character that follows this group can be a seperator
|
||||
if record[next_group] == '?' || record[next_group] == '.' {
|
||||
// It can be seperator, so skip it and reduce to the next group
|
||||
return calc(record[next_group+1:], groups[1:])
|
||||
}
|
||||
// Can't be handled, there are no possibilites
|
||||
return 0
|
||||
}
|
||||
|
||||
// Logic that treats the first character as dot "."
|
||||
func dot(record string, groups []int) int {
|
||||
// ADD LOGIC HERE ... need to process this character and call
|
||||
// We just skip over the dot looking for the next pound
|
||||
return calc(record[1:], groups)
|
||||
}
|
||||
29
2023/go/day12/day12_test.go
Normal file
29
2023/go/day12/day12_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package day12
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`???.### 1,1,3
|
||||
.??..??...?##. 1,1,3
|
||||
?#?#?#?#?#?#?#? 1,3,1,6
|
||||
????.#...#... 4,1,1
|
||||
????.######..#####. 1,6,5
|
||||
?###???????? 3,2,1`)
|
||||
require.Equal(t, 21, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`???.### 1,1,3
|
||||
.??..??...?##. 1,1,3
|
||||
?#?#?#?#?#?#?#? 1,3,1,6
|
||||
????.#...#... 4,1,1
|
||||
????.######..#####. 1,6,5
|
||||
?###???????? 3,2,1`)
|
||||
require.Equal(t, 525152, r)
|
||||
}
|
||||
1000
2023/go/day12/input.txt
Normal file
1000
2023/go/day12/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
144
2023/go/day13/day13.go
Normal file
144
2023/go/day13/day13.go
Normal file
@@ -0,0 +1,144 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"adventofcode2023/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type mirrorLoc struct {
|
||||
orient string
|
||||
index int
|
||||
}
|
||||
func Part1(input string) int {
|
||||
count := 0
|
||||
|
||||
patterns := strings.Split(input, "\n\n")
|
||||
for p, pattern := range patterns {
|
||||
rows := strings.Split(pattern, "\n")
|
||||
if v, ok := findMirror(rows); ok {
|
||||
count = count + v * 100
|
||||
} else {
|
||||
cols := swap(rows)
|
||||
if v, ok := findMirror(cols); ok {
|
||||
count = count + v
|
||||
} else {
|
||||
utils.PanicOnErr(fmt.Errorf("p: %v\n %v\n", p, pattern))
|
||||
}
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
count := 0
|
||||
patterns := strings.Split(input, "\n\n")
|
||||
|
||||
for p, pattern := range patterns {
|
||||
rows := strings.Split(pattern, "\n")
|
||||
loc, _ := findMirrorLoc(rows)
|
||||
found := false
|
||||
for i:=0;i<len(rows[0])*len(rows);i++{
|
||||
newRows := smudge(i, rows)
|
||||
if v, ok := findNewMirrorLoc(loc, newRows); ok {
|
||||
if v != loc {
|
||||
found = true
|
||||
if v.orient == "row" {
|
||||
count = count + v.index * 100
|
||||
} else {
|
||||
count = count + v.index
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if ! found {
|
||||
utils.PanicOnErr(fmt.Errorf("p: %v\n %v\n", p, pattern))
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func smudge(i int, rows []string) []string {
|
||||
out := make([]string, len(rows))
|
||||
copy(out, rows)
|
||||
col := i % len(rows[0])
|
||||
row := i / len(rows[0])
|
||||
if col >= 0 && col < len(rows[0]) {
|
||||
v := rows[row][col]
|
||||
if v == '#' {
|
||||
out[row] = out[row][:col] + "." + out[row][col+1:]
|
||||
} else {
|
||||
out[row] = out[row][:col] + "#" + out[row][col+1:]
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func findNewMirrorLoc(loc mirrorLoc, rows []string) (mirrorLoc, bool) {
|
||||
if v, ok := findNewMirror(loc, "row", rows); ok {
|
||||
return mirrorLoc{"row", v}, true
|
||||
}
|
||||
cols := swap(rows)
|
||||
if v, ok := findNewMirror(loc, "col", cols); ok {
|
||||
return mirrorLoc{"col", v}, true
|
||||
}
|
||||
return mirrorLoc{}, false
|
||||
}
|
||||
|
||||
func findMirrorLoc(rows []string) (mirrorLoc, bool) {
|
||||
if v, ok := findMirror(rows); ok {
|
||||
return mirrorLoc{"row", v}, true
|
||||
}
|
||||
cols := swap(rows)
|
||||
if v, ok := findMirror(cols); ok {
|
||||
return mirrorLoc{"col", v}, true
|
||||
}
|
||||
return mirrorLoc{}, false
|
||||
}
|
||||
|
||||
func swap(in []string) []string {
|
||||
out := []string{}
|
||||
for j:=0;j<len(in[0]);j++ {
|
||||
o := ""
|
||||
for i:=0;i<len(in);i++ {
|
||||
o = o + string(in[i][j])
|
||||
}
|
||||
out = append(out, o)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func findMirror(rows []string) (int, bool) {
|
||||
for i:=0;i<len(rows)-1;i++ {
|
||||
if rows[i] == rows[i+1] {
|
||||
if isMirror(i, 0, rows) {
|
||||
return i+1, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1, false
|
||||
}
|
||||
|
||||
func findNewMirror(loc mirrorLoc, orient string, rows []string) (int, bool) {
|
||||
for i:=0;i<len(rows)-1;i++ {
|
||||
if orient == loc.orient && i == loc.index - 1{ continue }
|
||||
if rows[i] == rows[i+1] {
|
||||
if isMirror(i, 0, rows) {
|
||||
return i+1, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1, false
|
||||
}
|
||||
|
||||
func isMirror(i int, offset int, rows []string) bool {
|
||||
if i == 0 || i == len(rows) - 1 { return true }
|
||||
|
||||
if i - offset < 0 || i+1+offset > len(rows) - 1 { return true }
|
||||
|
||||
if rows[i+1+offset] == rows[i-offset] {
|
||||
return isMirror(i, offset+1, rows)
|
||||
}
|
||||
return false
|
||||
}
|
||||
47
2023/go/day13/day13_test.go
Normal file
47
2023/go/day13/day13_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
|
||||
#...##..#
|
||||
#....#..#
|
||||
..##..###
|
||||
#####.##.
|
||||
#####.##.
|
||||
..##..###
|
||||
#....#..#`)
|
||||
require.Equal(t, 405, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
|
||||
#...##..#
|
||||
#....#..#
|
||||
..##..###
|
||||
#####.##.
|
||||
#####.##.
|
||||
..##..###
|
||||
#....#..#`)
|
||||
require.Equal(t, 400, r)
|
||||
}
|
||||
1377
2023/go/day13/input.txt
Normal file
1377
2023/go/day13/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
59
2023/go/day13b/day13.go
Normal file
59
2023/go/day13b/day13.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
_ "adventofcode2023/utils"
|
||||
"adventofcode2023/utils/inputs"
|
||||
_ "fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
return symmetry(input, 0)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
return symmetry(input, 1)
|
||||
}
|
||||
|
||||
func symmetry(input string, smudges int) int {
|
||||
ans := 0
|
||||
|
||||
patterns := strings.Split(input, "\n\n")
|
||||
for _, pattern := range patterns {
|
||||
grid := inputs.ToGrid2D[rune](pattern, "\n", "", ' ', func(c string) rune { return rune(c[0])})
|
||||
G := grid.Matrix()
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
// vertical symmetry
|
||||
for c:=0;c<C-1;c++ {
|
||||
badness := 0
|
||||
for dc:=0;dc<C;dc++ {
|
||||
left := c-dc
|
||||
right := c+1+dc
|
||||
if left < 0 || left > right || right > C -1 { break }
|
||||
for r:=0;r<R;r++ {
|
||||
if G[r][left] != G[r][right] {
|
||||
badness += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if badness == smudges { ans += c+1 }
|
||||
}
|
||||
// horizontal symmetry
|
||||
for r:=0;r<R-1;r++ {
|
||||
badness := 0
|
||||
for dr:=0;dr<R;dr++ {
|
||||
up := r-dr
|
||||
down := r+1+dr
|
||||
if up < 0 || up > down || down > R -1 { break }
|
||||
for c:=0;c<C;c++ {
|
||||
if G[up][c] != G[down][c] {
|
||||
badness += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if badness == smudges { ans += 100*(r+1) }
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
47
2023/go/day13b/day13_test.go
Normal file
47
2023/go/day13b/day13_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
|
||||
#...##..#
|
||||
#....#..#
|
||||
..##..###
|
||||
#####.##.
|
||||
#####.##.
|
||||
..##..###
|
||||
#....#..#`)
|
||||
require.Equal(t, 405, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
|
||||
#...##..#
|
||||
#....#..#
|
||||
..##..###
|
||||
#####.##.
|
||||
#####.##.
|
||||
..##..###
|
||||
#....#..#`)
|
||||
require.Equal(t, 400, r)
|
||||
}
|
||||
1377
2023/go/day13b/input.txt
Normal file
1377
2023/go/day13b/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
95
2023/go/day14/day14.go
Normal file
95
2023/go/day14/day14.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package day14
|
||||
|
||||
import (
|
||||
_ "adventofcode2023/utils"
|
||||
"adventofcode2023/utils/grid2d"
|
||||
"adventofcode2023/utils/inputs"
|
||||
"fmt"
|
||||
_ "strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
grid := inputs.ToGrid2D[rune](input, "\n", "", ' ', func(c string) rune { return rune(c[0])})
|
||||
// fmt.Println(grid.StringWithFormatter(func(c rune, x int, y int) string { return string(c)}))
|
||||
slide(grid)
|
||||
// fmt.Println(grid.StringWithFormatter(func(c rune, x int, y int) string { return string(c)}))
|
||||
return score(grid)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := inputs.ToGrid2D[rune](input, "\n", "", ' ', func(c string) rune { return rune(c[0])})
|
||||
// fmt.Println(grid.StringWithFormatter(func(c rune, x int, y int) string { return string(c)}))
|
||||
x:= 0
|
||||
for j:=0;j<125;j++ {
|
||||
for i:=0;i<4;i++ {
|
||||
slide(grid)
|
||||
grid = rotate(grid)
|
||||
}
|
||||
if score(grid) == 101375 {
|
||||
fmt.Println(j, j - x)
|
||||
x = j
|
||||
}
|
||||
}
|
||||
fmt.Println(score(grid))
|
||||
for j:=999999840+125;j<1000000000;j++ {
|
||||
for i:=0;i<4;i++ {
|
||||
slide(grid)
|
||||
grid = rotate(grid)
|
||||
}
|
||||
if score(grid) == 101375 {
|
||||
fmt.Println(j, j - x)
|
||||
x = j
|
||||
}
|
||||
}
|
||||
// fmt.Println(grid.StringWithFormatter(func(c rune, x int, y int) string { return string(c)}))
|
||||
return score(grid)
|
||||
}
|
||||
|
||||
|
||||
func slide(grid *grid2d.Grid[rune]) {
|
||||
G := grid.Matrix()
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
for c:=0;c<C;c++ {
|
||||
for r:=0;r<R;r++ {
|
||||
for dr:=0;dr<R;dr++ {
|
||||
if G[dr][c]=='O' && dr>0 && G[dr-1][c]=='.' {
|
||||
G[dr][c]='.'
|
||||
G[dr-1][c] = 'O'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func rotate(grid *grid2d.Grid[rune]) *grid2d.Grid[rune] {
|
||||
G := grid.Matrix()
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
New := grid2d.NewGrid[rune](R, C, '?')
|
||||
NG := New.Matrix()
|
||||
for r:=0;r<R;r++ {
|
||||
for c:=0;c<C;c++ {
|
||||
NG[c][R-1-r] = G[r][c]
|
||||
}
|
||||
}
|
||||
return New
|
||||
}
|
||||
|
||||
func score(grid *grid2d.Grid[rune]) int {
|
||||
ans := 0
|
||||
|
||||
G := grid.Matrix()
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
|
||||
for r:=0;r<R;r++ {
|
||||
for c:=0;c<C;c++ {
|
||||
if G[r][c]=='O' {
|
||||
ans += len(G)-r
|
||||
}
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
37
2023/go/day14/day14_test.go
Normal file
37
2023/go/day14/day14_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package day14
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`O....#....
|
||||
O.OO#....#
|
||||
.....##...
|
||||
OO.#O....O
|
||||
.O.....O#.
|
||||
O.#..O.#.#
|
||||
..O..#O..O
|
||||
.......O..
|
||||
#....###..
|
||||
#OO..#....`)
|
||||
require.Equal(t, 136, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`O....#....
|
||||
O.OO#....#
|
||||
.....##...
|
||||
OO.#O....O
|
||||
.O.....O#.
|
||||
O.#..O.#.#
|
||||
..O..#O..O
|
||||
.......O..
|
||||
#....###..
|
||||
#OO..#....`)
|
||||
require.Equal(t, 64, r)
|
||||
}
|
||||
100
2023/go/day14/input.txt
Normal file
100
2023/go/day14/input.txt
Normal file
@@ -0,0 +1,100 @@
|
||||
O...#.O......#...##....O#.#.OO...O.#OO#.....#O.O.....#......#.OO...O...O..O#O#....#...O..O...O.....O
|
||||
.OO......O.OO.O.#.#O.O...#.##OO.....#.#O#...OOOOO..##O#O..O#O.##O...#O....O#.#.OO....#.........O.O.O
|
||||
......O.O.O.....O.#.#.#OO#O#.O...O.#.......#O....#.O.#....OOO...#....O#O.......#......O...O##...O...
|
||||
O...##O..#....OO.OO....O...O...O#..##.OOO..O..#OO....###....OO.O.O...........O...O..O.....#.#..O.O#.
|
||||
............#.#.##O.O.#.#OO#........O..O.O..##....O.#..#O..O...O#.#.#.........O...........OO......O.
|
||||
#.OO........#..#O.#......#....#....#......OO..OO...O#...#...#..##..O#.O......#.#..O..#O#...#..#.O#.O
|
||||
O.O.##...........O...O..O...O.OO.......##....#...O.....##...#.....OO...O.O#...OO..........O...O..#O.
|
||||
.O##....#.O#O....O.O.#.#O.O#..OO..##..#OO.#...#......#.#O#.....O...O#.O...#..O.#.#......#.##.O....O.
|
||||
.........#..#.O..O..O.O...#.#.O...#.OOO.##..#.O.....OO#....O...OOO#.O#....##O..#.O.O.....O.O.O.O..O.
|
||||
......#O.....OOO###.O..O####O.#.O...............#..O......##O...#.#..###...O....#O...OO.OO.O......O.
|
||||
#.O....#.O..#O...#...#...O....OOO.#O.#.#..#.....#.#..OO..#OO.......#OO.OOO....O.#O.#.O......####..O.
|
||||
OOOO...#.OO.#....O...O.O...##....#OO...O.##.O.....###..O........OO..O.O.......#.#...O..#..O.#..O....
|
||||
OOO..##....O...O.....O#..O.O.#..O..#.#.#..O........O..#OOO.....#....O#OO.#.#.....O..#..O...O..O.#OO#
|
||||
...##.#.##.#O....O#..O..O.........#.#.#O...O.......O...O#..OOOO....O...O.OO#.O.##...#....O..O.......
|
||||
....##.###OOO.O...#.......OO....OOO....O.OO#..O.#..OO....OO......O..OO...OOO.OO#...#..OOO..O.###O...
|
||||
O###O.....O.O.#O#.O.O#O.O###.....O..O........#....#..O#..#.#..O...........#......#OO........O..O####
|
||||
.#.#.OOO.O.......#O..O.#..O.OO.OO.O..O.#.#...O.O.OO..##..O...#...#O#..O.........O.O..O.O#....O..#O..
|
||||
.#..#O.#O..#.O.O.O...#OO....#...O....O..O.O...#..#.##O.O..O..#O.....OO##...O#.......O#O.#..........#
|
||||
#O...#.#OO.O...#O...O...#.#.O#..#.O#.###.#......O..O....#..#.OO..#....O..O.O....#.O.O.O.#..O..OOO..O
|
||||
O.....#...#.#OOO.OOOO..#O.O.#...O.##..OO..#O...#.....OO#..#.#...O##OO...O.....O..#...#...........O.O
|
||||
.##.O#.O..#O#.O##.O.#.........##.O......#OO...OO.......#...#O.O#...O..#.#...O..#...#O...O.#....OO.OO
|
||||
.O#OO.O..#...#..O..O...##.O....###O.....O...#.#OOO...OO...O.......#.#.#.OO....#OO.#..O..........OO..
|
||||
.....#OO.O..O.O.O...O.O#.#.O...O..#...O##.......#......#O...#.#.#....#..O.O..#..........O..#.#..#O..
|
||||
...O.O.O.OO...O#..O..OO..O#.#.O.#OO..O.O..OO..O#...#.O#...O.......#..#..O..##..O..#O......O.OO...O.O
|
||||
#.O....O.O.#...O.....O.....O#......#.#..OO...#.....O.#.#.O...#.#....#....O#.O.#......#OOO.O...O#....
|
||||
...OOO......#..O..O#.......#....O#OO..#O.#.#...#...O.O..OO..#.O...O..#.....OO..O..#...#.O...O#..O.OO
|
||||
#OO.OO#.OOO...##............O....O.O..#.##.#.O.........##...#O.O..#................#..O.O.O#O.O#..##
|
||||
.O.O.O##..#O.O#O...##.#OO#...#.OO#..O...O#...O....O#..OO....O....#...O...#OO.OO#O....#..O..#OO....O.
|
||||
.OO.#.......#...O...OO..#..OO.O.O.OO#O.O.O...O....O#..#.O.........O..#.O...#.#...O.O......O........O
|
||||
.O....##..#....#.....O.#...O.O.#....#....OOOO...O.O###.O........O.....O.O..#.##OOO.O.......#.#.O..O.
|
||||
.#.....O...#.O...#........#...#....#OO.O...O#O........OOO...#.O....OOO#.O.....OO....#.#...#..OO..#..
|
||||
OO.OO...O..#..#O....O.O....OOOOO.#O.#O.O...#.O....O#.O.O.#O.#...#..O...O.#O.O.#..O....OOO......#.O#.
|
||||
.O##..OO.....#.OO..#..O..#...#.#........O..OO...#O..O....#..O..O#.....O#..##O..O#.##.#...#.O..O.O.O.
|
||||
..#...#O.....OO#.....O..#.#O.#.#..#..O.....#...OO.#.....O..O.O##.O.....OOOO.#O.....O.#..O........#.#
|
||||
.#.#O..O.O..#..O##.....O.OO...##.........O...####..O..O....#O..O.....##........O.#..#.#OO.#..O.##.O#
|
||||
#...#.O....OO......#O...#O..O#..#O#O.#..#.....OO....OO#..#O....O.O..#.O.#.....O#.O.OO..O#.O.O..O.O#.
|
||||
OO....OO......#O........#O...#.#..O##....O#..#.#O.O.#....O..O..O.O....O.......#..OOO#.........O....O
|
||||
O.....#O.OO##......#O##..O..O...##..O..........O..OO.O..#O....O..OOO#OO.##..#....O#..#...O.O.O...O..
|
||||
.............#.#.#.O...#.#..#......O.#.O..#....#..##....#.##.##.#.O...O.O..#.#.#...OO....O..#O..#..O
|
||||
.O.#.....O.O..O..##O...OO.#.O....#..#.#...O.O#...#O.O.OO...O..#..OO...O...O...O.....#.O..O#..#.#..OO
|
||||
.....O..OO......#.#.#.O.##.OO...O..O.#..#...#OO....OOO......O.OO.#.O..O#O...O.#......OO##O.O.#O..O..
|
||||
O##O.#.#..#..OO.O.........#O.#..O.#.##.O#..OOOO..#....O...O.........O..O..###...O...O.#.....O..##.O.
|
||||
..O...#O#O.O...O.#..#O.......OO...........#...#..##.O......#..O.O.#OO.OO.#O....#.O.....O..#..#.#..#.
|
||||
O#..O..##O#....O..OOO..OO...#O..O.O...O#O...OO.O##.O#O..#......OO##O.##...OOO.O..#....O##O..#......#
|
||||
..#O...O..O.O...#..O.O...#O.....O.O......##OO#..O......#..O.#.O......OO.#O........O.....OO...O...O.O
|
||||
........OO.#.OO..O......#...#...#..OOOO.OO.#....O.OO...O.##.....O.O....#O.#.OO..##.##..#.#O#.OO...O#
|
||||
....#......#O.OO.....OOO....OO..O.O.O....##..O..O.O#.O....O.#O.#O.....O..O........#O.....O.O.....O#.
|
||||
#.O#.O#......##.....O.#O...###...##....#O#.#.#....OO...O..#.O....O..#..#..O..........O......#.O.O...
|
||||
.O.#..O#.OO....O.#...#O....#....OO......#O.O..#O..........O.#..#...#OOO........#.#.........O.#..O...
|
||||
#OO.OO..O..O.O.#O.O.....O.##..#.O#..#.O....#........#.OOO#.#.....#.#.......O#..##..#.OO....O#O#.....
|
||||
.......#O.O....#.OOO..OO...O...#....O..#.#....OO..O....O.#.O.#O#..O#.#.O..O......##...OO..#....O.#..
|
||||
.O..O#.#OO.O.O.O.##...O..O.O..O.##O...#.O..O..O..O..O.....O...#..OO#O..O###...#...#....O##.OO...#...
|
||||
#O....#...##..O..#...#OO.O.O.#......O...O.#.#O..O...O....OOO..O.O..O...O.OO...O...#..O....O#.###....
|
||||
....#..O.....##.O.......##.##..OOO.O.#.#.....#....O..#..O....#....O...#.O..O#..O##...#.##....O.#OO##
|
||||
O....O...OO.O........#..O...#..#.....O......O.O.OO.OO..#....O..O.............##.O.....##O#.OOO......
|
||||
........#.O.####O.OO.#.O..O.O.#.#....OO#.......O..#....##.OOO..O.O.O..#.O.#...O.O.O..O.##O..O#....O.
|
||||
...#....#.....O....O.O.O##.O..#O.OO...#.##.O..###OO##.O......#..##.OO...O.......O.......#..O.#.O..O.
|
||||
.O.O...O......OO.#....#O..O.O.O..OO.O..O##O...O....O..OO.#..O....O..#.O..OO.OO....O#O..#.O..#O...#.#
|
||||
..O#O.#O..#...##..#.O...OO..O#.......#..O........#.OO#..O#.#.#O....##...O.........O......OO#.....O.#
|
||||
....OO.......###..O#.....O##..#O..#..#.O.....##.......##..O#O....#....#O.O..#..#..O.###O..#.O#......
|
||||
O..##..O...#..O...O#OOO....#.O##O.#........#.O..O.#..#.OO.#O.#.....##.O..O.O....#..#..OO....#..#..##
|
||||
.#...O.OO#O.O..O.##O..O#...##...O....OO.O#....#...#O.O#....O..........#....#............##.......#..
|
||||
.O.#........##O...#O..O..O....OO#O....#.O..OO.##..O..OO#.###OO.....#..#.......O.#.....OO........OO.#
|
||||
.OO...O.#..##.....OO..O.O.O.#.###.##.O.#..O..#..O..O...##.#......O....O.O.........O..#.O.O#O.#O...#.
|
||||
#..#.#..O...##.....OO#O.OOO.....#...#.....##.#...O....O....#..OO#.#.OO....#.....O.O...O#.#..#..O#O.O
|
||||
.O#.O.#..O..O#...OO...O...O#...O..O..#.O..#...O#.#....O......O#...O...OO.O##.#O....O....#OO....#O...
|
||||
OO..OOO.O......OO...OO#O...#.#.#O.OOO#....#.OO#.#.O.#......O.O.OO#..O..#..O.O#.O#.O....O..O...O.....
|
||||
...OO....O...#OO#..#..O.#O#....O.....OO.O.#.OO##.....#..O#.OO..#.#.O#..#..O.#..O....#....O.#O...OO#O
|
||||
..#.......OO..##.O#...O#....O.#.O..##..#O.......#O#......O..O.........O#..#OO..O..#O.#.#.O.O#.#OO#.O
|
||||
...#O#...O...OO...OO..OO...#OO...O...##.O....##.#O##.O....#..O#..O.....O.......###.#.OO#...O......#.
|
||||
.O.OO#O##O##...#..#....#..#O...O#..O.O##......#........#O.........#.O....O..#..O.....O..#......O.#.#
|
||||
..#....#.O.O.O..O.....O.O#O.O..#......O............O.........O#.O....#.O#..O..O.#OO.....#......O...#
|
||||
OO...#..O..O##.#.#O.O.#.#....O....O...O.#..O##...O...#.O...#.O.OO...#........O#O..O.O.O..O.....#.O..
|
||||
.OOO....#...O..O.....O..O...O...O..O...O#...#O....O.O...#..OO##.O.#..O..........O#..#..#..OO#.....#.
|
||||
O..#..O#....#O..##O..#.#.......OO..O..#...O....O.#....O..O.##........O...O..OO...#....OO#..O.#.#.#..
|
||||
O#O.O.O#.#OO#..OO.O.#......#.....#.......##.O..#.O..#..OO..O.#.#.O.O.O#.#......O....####OO#.#O#OO.#.
|
||||
.#.....O#..O#O#..OO...#.O.#....#.#..##....O##....#.........##OO...##...O......#.OO...#O....O.O.O#O..
|
||||
O......#.O....O...O.....OO.#....#O.##....#.O.O...O..#...O....#.O....O.O....#.OO.#.......#...#..#...O
|
||||
...#OO..#......#..OO.O.O.##.O....O.##O##.OO#O.O.O..O.#O#O.OO...........O...###.#......O..#..#O#..OOO
|
||||
O..O.#..O.OO.O...OO.OO..OOOO....O...#....##.OO.O.....#.......O.O........O.#.......#.......#..#.O..O.
|
||||
.OO.##...#O..O#....O....#..O#....#.....O...O#.....OOO#.....................#..#..#..#O.......O.#OO..
|
||||
.#OO..O....O..#.....#O...OO.#....#.#.O...O.#........O...O..O..OO#..#.....#.......OOOOO.OO....O....O.
|
||||
.O#...#.......O.O...O.O.O#...OO.O#...O#O.O.#......#......O..O##.##.....O.....##...........O#...O....
|
||||
.#.O.O#.....O.#..OO......#O.#..O..O.O.O..#.#...O##.#O..OOO......#...#..OO...O.#.....#O.OOO...#.O..##
|
||||
.........O..##OO.#OOOO.O.O..OOO...OO.#.....#...O.#O##..O#..#.#..#...#..O.O...#OO.O...O...#O...#..#..
|
||||
.#.#O.#...#OO.O.........O#..O...OO#.....O....OOOO#.....O.O....#...O...........O#.#.O..O.#.O.#.O.#.#.
|
||||
......O.#...O.....O.O..O#...O.#........#.O...O.O....#..O#....O.#.O.O....O...#OO...#........OO..O.O.O
|
||||
....O.O..OO.....#...OOOO.O#............O#OO....OOOOOO..#..#O#..#.#.O.OO.#O.....O.#......##..O#..#O..
|
||||
..#......#...#O.#..#.#....OOO#...O.#....O..#O.....O.....O.O......O.......O.O..O..O.OO.O.#OO..O#...#.
|
||||
.O.#.O.OO..O#.O#OO..........O.......O..#..#.#..O...#...##.....####...#........##O.......#....#...O##
|
||||
........#.#.O.#O.......#O...O...#.#O..#OOO..#O..###...O.#.#O...O.O#..O..O...O.O....###.OO.#OO..O.#.O
|
||||
..#O....#..O..####.O#...O....O.#O.##.O....O.O......O#O...OO###...O..#........#.#O.O#OO.......#.....O
|
||||
....O.....#.#.O.#..O.#O.#.#O.#.......OO.....OOO...O.O..#.#....#..O.O..#.OO.O..O..OO##.....#.O..OO#O.
|
||||
O#O..OO.O....OO.#O......O......#...#.....O.#OO.#.....OO..O#.O..O.O...#....O.O..OO.O....#....OO..O...
|
||||
...O.....##....#....#....#......O#O..OO.....OO#O.OO......#OO.......O.#..###OO...#.O..OO.#.O.O#OO..#.
|
||||
.O.#.O..#O.....#.#O....##OO.#O..##..##.##...#OO.O.#O#..O..O.O..O..##O.O.....O.OOO..#..#O..O#..OO...O
|
||||
..##O#O.O.#.........O....O.OO#O#O.....O.....O#O.OO.O......O.O.OO......#.....O.O.O.O.O.....#.O.......
|
||||
.....#OO.#O........O#....O.#OO.OO........#.O....O.OOOOOO.#.#O......O.#...O#.O.O..OO.....O.OO...#.O.#
|
||||
.....#................OO..OOOO..#.....O.###O.O...O..#O..........OO.#...OO.O#...O......O..OOOO.#..###
|
||||
O.....O...#O.#..........#O......O..OOO#....O.OOOO....O..#..#O....O.....O#..O..#.O.O....#OO.#....#O..
|
||||
80
2023/go/day15/day15.go
Normal file
80
2023/go/day15/day15.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package day15
|
||||
|
||||
import (
|
||||
"adventofcode2023/utils"
|
||||
_ "fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Lens struct {
|
||||
label string
|
||||
fl int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
ans := 0
|
||||
seqs := strings.Split(input, ",")
|
||||
for _,seq := range seqs {
|
||||
ans += hash(seq)
|
||||
}
|
||||
|
||||
return ans
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
Boxes := [256][]Lens{}
|
||||
cmds := strings.Split(input, ",")
|
||||
for _,cmd := range cmds {
|
||||
if cmd[len(cmd)-1] == '-' {
|
||||
label := cmd[:len(cmd)-1]
|
||||
hash := hash(label)
|
||||
nl := []Lens{}
|
||||
for _, lens := range Boxes[hash] {
|
||||
if lens.label != label {
|
||||
nl = append(nl, lens)
|
||||
}
|
||||
}
|
||||
Boxes[hash] = nl
|
||||
} else {
|
||||
tokens := strings.Split(cmd, "=")
|
||||
label := tokens[0]
|
||||
fl := utils.MustAtoi(tokens[1])
|
||||
hash := hash(label)
|
||||
nl := []Lens{}
|
||||
if len(Boxes[hash]) == 0 {
|
||||
Boxes[hash] = append(Boxes[hash], Lens{label:label, fl:fl})
|
||||
} else {
|
||||
found := false
|
||||
for _, lens := range Boxes[hash] {
|
||||
if lens.label == label {
|
||||
nl = append(nl, Lens{label:label, fl:fl})
|
||||
found = true
|
||||
} else {
|
||||
nl = append(nl, lens)
|
||||
}
|
||||
}
|
||||
Boxes[hash] = nl
|
||||
if ! found {
|
||||
Boxes[hash] = append(Boxes[hash], Lens{label:label, fl:fl})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ans := 0
|
||||
for i, box := range Boxes {
|
||||
for j, lens := range box {
|
||||
ans += (i+1) * (j +1) * lens.fl
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func hash(in string) int {
|
||||
result := 0
|
||||
for _, letter := range in {
|
||||
result += int(letter)
|
||||
result = result * 17
|
||||
result = result % 256
|
||||
}
|
||||
return result
|
||||
}
|
||||
17
2023/go/day15/day15_test.go
Normal file
17
2023/go/day15/day15_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package day15
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1("rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7")
|
||||
require.Equal(t, 1320, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2("rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7")
|
||||
require.Equal(t, 145, r)
|
||||
}
|
||||
1
2023/go/day15/input.txt
Normal file
1
2023/go/day15/input.txt
Normal file
File diff suppressed because one or more lines are too long
BIN
2023/go/day16/__debug_bin946177999
Executable file
BIN
2023/go/day16/__debug_bin946177999
Executable file
Binary file not shown.
202
2023/go/day16/day16.go
Normal file
202
2023/go/day16/day16.go
Normal file
@@ -0,0 +1,202 @@
|
||||
package day16
|
||||
|
||||
import (
|
||||
_ "adventofcode2023/utils"
|
||||
"adventofcode2023/utils/grid2d"
|
||||
_ "adventofcode2023/utils/grid2d"
|
||||
"adventofcode2023/utils/inputs"
|
||||
"fmt"
|
||||
_ "strings"
|
||||
)
|
||||
|
||||
type Tile struct {
|
||||
object rune
|
||||
energized int
|
||||
}
|
||||
|
||||
type Beam struct {
|
||||
dir rune
|
||||
r int
|
||||
c int
|
||||
rm bool
|
||||
}
|
||||
|
||||
var startBeams []Beam
|
||||
|
||||
func Part1(input string) int {
|
||||
beams := []Beam{}
|
||||
beams = addBeam(beams, Beam{'s', 0, 3, false})
|
||||
grid := inputs.ToGrid2D[Tile](input, "\n", "", Tile{}, func(c string) Tile { return Tile{ object: rune(c[0]), energized: 0}})
|
||||
return score(grid, beams)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := inputs.ToGrid2D[Tile](input, "\n", "", Tile{}, func(c string) Tile { return Tile{ object: rune(c[0]), energized: 0}})
|
||||
G := grid.Matrix()
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
ans := 0
|
||||
for r:=0;r<R;r++{
|
||||
beams := []Beam{}
|
||||
grid := inputs.ToGrid2D[Tile](input, "\n", "", Tile{}, func(c string) Tile { return Tile{ object: rune(c[0]), energized: 0}})
|
||||
beams = addBeam(beams, Beam{'e', r, 0, false})
|
||||
ans = max(ans, score(grid, beams))
|
||||
beams = []Beam{}
|
||||
beams = addBeam(beams, Beam{'w', r, C-1, false})
|
||||
grid = inputs.ToGrid2D[Tile](input, "\n", "", Tile{}, func(c string) Tile { return Tile{ object: rune(c[0]), energized: 0}})
|
||||
ans = max(ans, score(grid, beams))
|
||||
}
|
||||
for c:=0;c<C;c++{
|
||||
beams := []Beam{}
|
||||
grid := inputs.ToGrid2D[Tile](input, "\n", "", Tile{}, func(c string) Tile { return Tile{ object: rune(c[0]), energized: 0}})
|
||||
beams = addBeam(beams, Beam{'s', 0, c, false})
|
||||
ans = max(ans, score(grid, beams))
|
||||
beams = []Beam{}
|
||||
beams = addBeam(beams, Beam{'n', R-1, c, false})
|
||||
grid = inputs.ToGrid2D[Tile](input, "\n", "", Tile{}, func(c string) Tile { return Tile{ object: rune(c[0]), energized: 0}})
|
||||
ans = max(ans, score(grid, beams))
|
||||
}
|
||||
|
||||
return ans
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func score(grid *grid2d.Grid[Tile], beams []Beam) int {
|
||||
fmt.Println(grid.StringWithFormatter(func(t Tile, x int, y int) string { return string(t.object)}))
|
||||
G := grid.Matrix()
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
fmt.Println("r:", R, "c:", C, "tiles:", R*C )
|
||||
for i:=0;i<1000;i++ {
|
||||
beams = rmBeams(beams)
|
||||
fmt.Println(i, ":", len(beams), ":", energy(G))
|
||||
for i, _ := range beams {
|
||||
r := beams[i].r
|
||||
c := beams[i].c
|
||||
if r >= 0 && r < R && c >= 0 && c < C {
|
||||
G[r][c].energized++
|
||||
switch beams[i].dir {
|
||||
case 'n':
|
||||
tile := &G[r][c]
|
||||
switch tile.object {
|
||||
case '.':
|
||||
beams[i].r--
|
||||
case '|':
|
||||
beams[i].r--
|
||||
case '-':
|
||||
beams[i].dir = 'e'
|
||||
beams[i].c++
|
||||
beams = addBeam(beams, Beam{'w', beams[i].r, beams[i].c-1, false})
|
||||
case '\\':
|
||||
beams[i].dir = 'w'
|
||||
beams[i].c--
|
||||
case '/':
|
||||
beams[i].dir = 'e'
|
||||
beams[i].c++
|
||||
}
|
||||
case 'e':
|
||||
tile := &G[r][c]
|
||||
switch tile.object {
|
||||
case '.':
|
||||
beams[i].c++
|
||||
case '-':
|
||||
beams[i].c++
|
||||
case '|':
|
||||
beams[i].dir = 'n'
|
||||
beams[i].r--
|
||||
beams = addBeam(beams, Beam{'s', beams[i].r+1, beams[i].c, false})
|
||||
case '\\':
|
||||
beams[i].dir = 's'
|
||||
beams[i].r++
|
||||
case '/':
|
||||
beams[i].dir = 'n'
|
||||
beams[i].r--
|
||||
}
|
||||
case 's':
|
||||
tile := &G[r][c]
|
||||
switch tile.object {
|
||||
case '.':
|
||||
beams[i].r++
|
||||
case '|':
|
||||
beams[i].r++
|
||||
case '-':
|
||||
beams[i].dir = 'e'
|
||||
beams[i].c++
|
||||
beams = addBeam(beams, Beam{'w', beams[i].r, beams[i].c-1, false})
|
||||
case '\\':
|
||||
beams[i].dir = 'e'
|
||||
beams[i].c++
|
||||
case '/':
|
||||
beams[i].dir = 'w'
|
||||
beams[i].c--
|
||||
}
|
||||
case 'w':
|
||||
tile := &G[r][c]
|
||||
switch tile.object {
|
||||
case '.':
|
||||
beams[i].c--
|
||||
case '-':
|
||||
beams[i].c--
|
||||
case '|':
|
||||
beams[i].dir = 'n'
|
||||
beams[i].r--
|
||||
beams = addBeam(beams, Beam{'s', beams[i].r+1, beams[i].c, false})
|
||||
case '\\':
|
||||
beams[i].dir = 'n'
|
||||
beams[i].r--
|
||||
case '/':
|
||||
beams[i].dir = 's'
|
||||
beams[i].r++
|
||||
}
|
||||
}
|
||||
} else {
|
||||
beams[i].rm = true
|
||||
}
|
||||
}
|
||||
fmt.Println(grid.StringWithFormatter(func(t Tile, x int, y int) string { if t.energized > 0 {return "#"}; return "."}))
|
||||
}
|
||||
fmt.Println(grid.StringWithFormatter(func(t Tile, x int, y int) string { if t.energized > 0 {return "#"}; return "."}))
|
||||
return energy(G)
|
||||
}
|
||||
|
||||
func rmBeams(slice []Beam) []Beam {
|
||||
var result []Beam
|
||||
|
||||
for _, value := range slice {
|
||||
if ! value.rm {
|
||||
result = append(result, value)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func addBeam(beams []Beam, beam Beam) []Beam {
|
||||
for _, value := range startBeams {
|
||||
if value == beam { return beams }
|
||||
}
|
||||
startBeams = append(startBeams, beam)
|
||||
for _, value := range beams {
|
||||
if value == beam { return beams }
|
||||
}
|
||||
return append(beams, beam)
|
||||
}
|
||||
|
||||
func energy(G [][]Tile) int {
|
||||
ans := 0
|
||||
R := len(G)
|
||||
C := len(G[0])
|
||||
for r:=0;r<R;r++ {
|
||||
for c:=0;c<C;c++ {
|
||||
if G[r][c].energized > 0 {
|
||||
ans++
|
||||
}
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
68
2023/go/day16/day16.py
Normal file
68
2023/go/day16/day16.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/python3
|
||||
import sys
|
||||
import re
|
||||
from copy import deepcopy
|
||||
from math import gcd
|
||||
from collections import defaultdict, Counter, deque
|
||||
D = open(sys.argv[1]).read().strip()
|
||||
L = D.split('\n')
|
||||
G = [[c for c in row] for row in L]
|
||||
|
||||
R = len(G)
|
||||
C = len(G[0])
|
||||
|
||||
DR = [-1, 0, 1, 0]
|
||||
DC = [ 0, 1, 0,-1]
|
||||
|
||||
def step(r,c,d):
|
||||
return (r+DR[d], c+DC[d], d)
|
||||
|
||||
def score(sr,sc,sd):
|
||||
POS = [(sr,sc,sd)]
|
||||
SEEN = set()
|
||||
SEEN2 = set()
|
||||
while True:
|
||||
NP = []
|
||||
if not POS:
|
||||
break
|
||||
for (r,c,d) in POS:
|
||||
#print(r,c,d)
|
||||
if 0<=r<R and 0<=c<C:
|
||||
SEEN.add((r,c))
|
||||
if (r,c,d) in SEEN2:
|
||||
continue
|
||||
SEEN2.add((r,c,d))
|
||||
ch = G[r][c]
|
||||
if ch=='.':
|
||||
NP.append(step(r,c,d))
|
||||
elif ch=='/':
|
||||
# up right down left
|
||||
NP.append(step(r,c,{0:1, 1:0, 2:3, 3:2}[d]))
|
||||
elif ch=='\\':
|
||||
NP.append(step(r,c,{0:3, 1:2, 2:1, 3:0}[d]))
|
||||
elif ch=='|':
|
||||
if d in [0,2]:
|
||||
NP.append(step(r,c,d))
|
||||
else:
|
||||
NP.append(step(r, c, 0))
|
||||
NP.append(step(r, c, 2))
|
||||
elif ch=='-':
|
||||
if d in [1,3]:
|
||||
NP.append(step(r,c,d))
|
||||
else:
|
||||
NP.append(step(r, c, 1))
|
||||
NP.append(step(r, c, 3))
|
||||
else:
|
||||
assert False
|
||||
POS = NP
|
||||
return len(SEEN)
|
||||
|
||||
print(score(0,0,1))
|
||||
ans = 0
|
||||
for r in range(R):
|
||||
ans = max(ans, score(r,0,1))
|
||||
ans = max(ans, score(r,C-1,3))
|
||||
for c in range(C):
|
||||
ans = max(ans, score(0,c,2))
|
||||
ans = max(ans, score(R-1,c,0))
|
||||
print(ans)
|
||||
37
2023/go/day16/day16_test.go
Normal file
37
2023/go/day16/day16_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package day16
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(
|
||||
`.|...\....
|
||||
|.-.\.....
|
||||
.....|-...
|
||||
........|.
|
||||
..........
|
||||
.........\
|
||||
..../.\\..
|
||||
.-.-/..|..
|
||||
.|....-|.\
|
||||
..//.|...`)
|
||||
require.Equal(t, 46, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(
|
||||
`.|...\....
|
||||
|.-.\.....
|
||||
.....|-...
|
||||
........|.
|
||||
..........
|
||||
.........\
|
||||
..../.\\..
|
||||
.-.-/..|..
|
||||
.|....-|.\
|
||||
..//.|...`)
|
||||
require.Equal(t, 51, r)
|
||||
}
|
||||
110
2023/go/day16/input.txt
Normal file
110
2023/go/day16/input.txt
Normal file
@@ -0,0 +1,110 @@
|
||||
\.......................\..........................................-..................-.../................-..
|
||||
....../.......\...-......-.|...\..............\.................|............././....-........................
|
||||
...............-...-........................................\......\..-.............|......-....\....-........
|
||||
..\..|.|...........................-.|........................................./.|....|................|......
|
||||
|../................|............................................................\........../..\..............
|
||||
........\............../................/..........................\...\....|............./....-.........\\...
|
||||
.................-...-...................\../........-|.................../......-...........|................
|
||||
........-............/...|-............-.....\.|..............-....-../\../..................\...\././........
|
||||
........................-|................................................................-........-..........
|
||||
-......./.................|.....\.................\.....//............-........./..../....|...................
|
||||
....-.............-........-..........-|.......|...../...\...................\.....................|..........
|
||||
...|...\.........|.................|.....|....-....\.......\./........................-.../..../.....-........
|
||||
....|....-.-..............\.........|.......................-.......-..............\................/.........
|
||||
.....|.\...........-.................-.-........../...\............|...............|...|......./.......|...../
|
||||
.....\.........................-.../..-./...\...................../......\...-.......|.\........-|............
|
||||
............|.....................................-....../....\.............../-...|...\..\................./.
|
||||
......-./|....../............|.........\............-../...-......./.\..\....../......|/...\..................
|
||||
................................|.......|..-..../.............................../.-..................-..-/..|.
|
||||
...............................-......./......................|./...............-............./....../........
|
||||
..................../....................\........\...........................-............/.../..............
|
||||
.|||......../.................|.................../..\............................-......./..|...|/.-.........
|
||||
......-......./\....../.........|....../.......-...............|.\........-............/.../..................
|
||||
.....................-.\/|................//.../.........|.|......\.-..|.........|.........\..................
|
||||
.........................\/.......|.|............................|........|.............................././..
|
||||
.................................|.................\../..|/.................\.................-...-........-/.
|
||||
......................-...-.........../...........................\....\......-..-.......\.-....\....|........
|
||||
......-......../..............\/..................\..|........-..............|...-...../......|...............
|
||||
|.......|.../....|..............//.....................|..........|/......../................|................
|
||||
...|.|..................../|..../.-.......-...........|.....|./....\......-......-................|...........
|
||||
......\/./.|\..../|.|..|..........-....|...........|.-.|...................-.\.....|....................\.....
|
||||
......../.\......................|.....|...........|.........../.......|....|...|.......-......../......\...-.
|
||||
...|...-...||......-..|..-...........|.-.................|.................................-..................
|
||||
..............-.\.-........|......\..........................................\./.\........../.....|...........
|
||||
../\.........|...............|............|.\/.-/.................-....|...-.................-.....|..../.....
|
||||
....................../......../..../-.....\........................\..-.\....|....-.........../-.............
|
||||
.................................|................|.........|................../|.....|....\\............/.\..
|
||||
...///./.....\.................|/.....................\...................-............|................|.....
|
||||
............-...........................--........\................/.............-\................\.....-.../
|
||||
...............\.........../|............................|.....................\...-...\.....................-
|
||||
...\.............|.............|................\............\|...../...|.........................|...........
|
||||
..................|......|..........-.-..............\.........................\..............................
|
||||
....-................../.........../...|................/...............|./.|.../....\..../......./......//...
|
||||
...../....../..............................|...\../..........-..........-........-..//..../...................
|
||||
...............-......|......................|./........./............/..-...........|../.....-........-./....
|
||||
..\.........................|...-.......\.................|..............-........\....-.............-....|...
|
||||
.......|......|....../........\...........|......-........../......-..................../....................\
|
||||
.......................|....-..|........./.|.-...............|..\......\.....-.......\...-/....|/.........\...
|
||||
\......\..-.....................\..........................\................................../...........\...
|
||||
-....-......../............................................................../.\.......|..............|....-..
|
||||
........|......................|.............-....\................................./..\.......|..........-...
|
||||
...-...............|........./......\...../.......|...|...............\.../...\.../......|.....-.\......\.....
|
||||
............./.....|......................|.....................................\...||.................-....|.
|
||||
./.....-................/........|./....-......../......./..............\..................................\..
|
||||
.../..../\........-..........................|.-/.|..\................\\-.......|......./...||.......|........
|
||||
.....-.........................-...............\...........|.............-.\.../.|......-.|......../...-.....-
|
||||
......\....................|...../......................|.../......-..|............|......./.../.........|....
|
||||
...|...........-....................................../.|............./....|..../........./.....\../..........
|
||||
....../.../................\........................\...\....\......\............../|...............\.-.......
|
||||
./....\.../.............|............................-.../............../............/...........\...|........
|
||||
............................|.................|/..........//.........../..-...............|...................
|
||||
.....\......\.................|.....|...\-./...............\................|....../.....-..\........-....-...
|
||||
........................./-........\................./........-/.|....-.......\............-/\......|.\...-...
|
||||
..../../..|.|...............\.......................................-.........................................
|
||||
...........|...................................................-...-......|..................\............../.
|
||||
/....|......................................................................|\.../.......-...........-...|....
|
||||
......|.-.\......-........|.....-..|.\..............-......./......-|.........................-...............
|
||||
............\......................................|........................|.-...............................
|
||||
.........-.........../....\./....../.-...-..//.........../.......\\...........................................
|
||||
........\......../............./...-......\.../..|..|............................../......../..\..............
|
||||
--.........|.....-...|............../...|.......|..............\|............|.........................|.-....
|
||||
-\......./..............-....-....\...|.-........\/.\./............-/...\........|-.........../../...\........
|
||||
.\|\..............-......-.\...-....\..........................\........|...........-......./.............../.
|
||||
..........................|...\..../.../..........\.............-...//...............\..................-.....
|
||||
........./..........................\............|-.....|..-...|......../........-...........................\
|
||||
.......\.../.....\....../.......|..|...............-......................|....-...................-.|........
|
||||
......|.......\.../..............................-..............................|......-.-...................\
|
||||
/.....|.......-............/|.....|-......./..../......-........../..|......../.-..\..../....../...|..........
|
||||
............/..--..........-............\.......\................\........................../../....|.........
|
||||
..|..-................|.|..|................/.......\............-//.......................\..\...............
|
||||
.......................-......-..................|....\................-......\.|....\....|..../../|.-........
|
||||
........................-..................-...........................-..-................-................|.
|
||||
/.\....|.-.................................\..-.....\./.........../-.|..............\..\.....--|/....\........
|
||||
.......-..-../..................\..--|..............|...............|\........|...--................|./.\.....
|
||||
..........|................-.......|..................................................|...................|...
|
||||
-.-..|....-.|........-./...|.-.........\.....\/........-........\........../................./.../........\...
|
||||
..................../...|/......................................../............\.|./../................/\|....
|
||||
...//.........................\....../..............\../.......-..\....|......................................
|
||||
............................./..|./../.........-/..\..........................................................
|
||||
......\.....|..................|..................\.....\.-..\...../............................../...........
|
||||
..........\...........-..........-.....-....\/................../.................................\.....|..\..
|
||||
..../.\...................................\............\...\....|.................|.....................-.....
|
||||
...........-...........................\.......|-../.|....|.....|......................-...../................
|
||||
.......|.........\..............|....\...-......../...........-.....-..-...........-..................\...\.|.
|
||||
...........|.......................|....-..........\............................\.................../.\.......
|
||||
..../.................\.......-..|.................../........................|...............\...........-.|.
|
||||
............./..|.-\..../.....-............-....|..\......|......../............-.........|................\..
|
||||
...................\...\/......\............|......................\....|...................-./-..............
|
||||
..-\...........|.................../.....|....|............................-..|............\.............\....
|
||||
.|.....\....\........|..................\...............|..-/.........|.-/...........-............-...........
|
||||
.....\...../......-............|........./..|............-........................\....-......................
|
||||
......\......../........|..............\...-..-...|.......................................................|...
|
||||
...................|.................................\.....\...........................|../.|.-......-........
|
||||
..................|..............\.....\............|........../....../...............\.........\.............
|
||||
..|...........-..../....\.........--...\................../.............-...-....................-..../....|..
|
||||
.|...\...................|......-...........-\..........\.....|.....|..........|.........|....|-../...........
|
||||
.............\|...................../\...............\....../.......-....\.....................-..............
|
||||
.......//.....................\....\......\......\.........|...................../......../.........\......-..
|
||||
.\./.........-...-./-.\.............../......|................................\|....\...../....-..............
|
||||
.......|......../......../......./.........../...............|............................../..|......../.....
|
||||
............./.........|.....-./.........../....-......./|......-................|............................
|
||||
@@ -14,6 +14,18 @@ import (
|
||||
"adventofcode2023/day05"
|
||||
"adventofcode2023/day06"
|
||||
"adventofcode2023/day07"
|
||||
"adventofcode2023/day08"
|
||||
"adventofcode2023/day09"
|
||||
"adventofcode2023/day10"
|
||||
"adventofcode2023/day11"
|
||||
"adventofcode2023/day12"
|
||||
"adventofcode2023/day13"
|
||||
"adventofcode2023/day14"
|
||||
"adventofcode2023/day15"
|
||||
"adventofcode2023/day16"
|
||||
|
||||
|
||||
|
||||
)
|
||||
// Usage: go run main.go <NN>
|
||||
// assumes input is in day<NN>/input.txt
|
||||
@@ -43,6 +55,33 @@ func main() {
|
||||
case 7:
|
||||
fmt.Printf("part 1: %d\n", day07.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day07.Part2(utils.Readfile(d)))
|
||||
case 8:
|
||||
fmt.Printf("part 1: %d\n", day08.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day08.Part2(utils.Readfile(d)))
|
||||
case 9:
|
||||
fmt.Printf("part 1: %d\n", day09.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day09.Part2(utils.Readfile(d)))
|
||||
case 10:
|
||||
fmt.Printf("part 1: %d\n", day10.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day10.Part2(utils.Readfile(d)))
|
||||
case 11:
|
||||
fmt.Printf("part 1: %d\n", day11.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day11.Part2(utils.Readfile(d)))
|
||||
case 12:
|
||||
fmt.Printf("part 1: %d\n", day12.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day12.Part2(utils.Readfile(d)))
|
||||
case 13:
|
||||
fmt.Printf("part 1: %d\n", day13.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day13.Part2(utils.Readfile(d)))
|
||||
case 14:
|
||||
fmt.Printf("part 1: %d\n", day14.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day14.Part2(utils.Readfile(d)))
|
||||
case 15:
|
||||
fmt.Printf("part 1: %d\n", day15.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day15.Part2(utils.Readfile(d)))
|
||||
case 16:
|
||||
fmt.Printf("part 1: %d\n", day16.Part1(utils.Readfile(d)))
|
||||
fmt.Printf("part 2: %d\n", day16.Part2(utils.Readfile(d)))
|
||||
default:
|
||||
panic(fmt.Errorf("no such day: %d", d))
|
||||
}
|
||||
@@ -50,7 +89,7 @@ func main() {
|
||||
|
||||
// Reads day from os.Args.
|
||||
func day() int {
|
||||
latest := 6
|
||||
latest := 15
|
||||
if len(os.Args) == 1 {
|
||||
return latest
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ func (g *Grid[T]) SizeX() int {
|
||||
func (g *Grid[T]) SizeY() int {
|
||||
return g.sizeY
|
||||
}
|
||||
func (g *Grid[T]) Matrix() [][]T {
|
||||
return g.matrix
|
||||
}
|
||||
|
||||
func (g *Grid[T]) Get(x, y int) T {
|
||||
if x < 0 || x >= g.sizeX {
|
||||
|
||||
16
2024/.vscode/launch.json
vendored
Normal file
16
2024/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${fileDirname}",
|
||||
"args": ["2"]
|
||||
}
|
||||
]
|
||||
}
|
||||
54
2024/gareth/day01/day01.go
Normal file
54
2024/gareth/day01/day01.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package day01
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
var leftList, rightList []float64
|
||||
total := 0.0
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
sides := strings.Fields(line)
|
||||
leftNum, _ := strconv.ParseFloat(sides[0], 64)
|
||||
rightNum, _ := strconv.ParseFloat(sides[1], 64)
|
||||
leftList = append(leftList, leftNum)
|
||||
rightList = append(rightList, rightNum)
|
||||
}
|
||||
|
||||
sort.Float64s(leftList)
|
||||
sort.Float64s(rightList)
|
||||
|
||||
for i := 0; i < len(leftList); i++ {
|
||||
total += math.Abs(leftList[i] - rightList[i])
|
||||
}
|
||||
return int(total)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
var leftList, rightList []int
|
||||
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
sides := strings.Fields(line)
|
||||
leftNum, _ := strconv.Atoi(sides[0])
|
||||
rightNum, _ := strconv.Atoi(sides[1])
|
||||
leftList = append(leftList, leftNum)
|
||||
rightList = append(rightList, rightNum)
|
||||
}
|
||||
|
||||
counts := make(map[int]int)
|
||||
for _, num := range rightList {
|
||||
counts[num]++
|
||||
}
|
||||
|
||||
similarityScore := 0
|
||||
for _, num := range leftList {
|
||||
similarityScore += num * counts[num]
|
||||
}
|
||||
|
||||
return similarityScore
|
||||
}
|
||||
27
2024/gareth/day01/day01_test.go
Normal file
27
2024/gareth/day01/day01_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package day01
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`3 4
|
||||
4 3
|
||||
2 5
|
||||
1 3
|
||||
3 9
|
||||
3 3`)
|
||||
assert.Equal(t, 11, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`3 4
|
||||
4 3
|
||||
2 5
|
||||
1 3
|
||||
3 9
|
||||
3 3`)
|
||||
assert.Equal(t, 31, r)
|
||||
}
|
||||
1000
2024/gareth/day01/input.txt
Normal file
1000
2024/gareth/day01/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
76
2024/gareth/day02/day02.go
Normal file
76
2024/gareth/day02/day02.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package day02
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
total := 0
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
var report []int
|
||||
nums := strings.Fields(line)
|
||||
for _, num := range nums {
|
||||
intnum, _ := strconv.Atoi(num)
|
||||
report = append(report, int(intnum))
|
||||
}
|
||||
if isSafe(report) {
|
||||
total++
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
total := 0
|
||||
lines := strings.Split(input, "\n")
|
||||
for _, line := range lines {
|
||||
var report []int
|
||||
nums := strings.Fields(line)
|
||||
for _, num := range nums {
|
||||
intnum, _ := strconv.Atoi(num)
|
||||
report = append(report, int(intnum))
|
||||
}
|
||||
if isSafeWithDampener(report) {
|
||||
total++
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func isSafe(report []int) bool {
|
||||
increasing := report[1] > report[0]
|
||||
decreasing := report[1] < report[0]
|
||||
|
||||
for i := 1; i < len(report); i++ {
|
||||
diff := report[i] - report[i-1]
|
||||
absDiff := int(math.Abs(float64(diff)))
|
||||
|
||||
if absDiff < 1 || absDiff > 3 {
|
||||
return false
|
||||
}
|
||||
|
||||
if (diff > 0 && !increasing) || (diff < 0 && !decreasing) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func isSafeWithDampener(report []int) bool {
|
||||
if isSafe(report) {
|
||||
return true
|
||||
}
|
||||
|
||||
for i := 0; i < len(report); i++ {
|
||||
modifiedReport := append(report[:i], report[i+1:]...)
|
||||
if isSafe(modifiedReport) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
27
2024/gareth/day02/day02_test.go
Normal file
27
2024/gareth/day02/day02_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package day02
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9`)
|
||||
assert.Equal(t, 2, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9`)
|
||||
assert.Equal(t, 4, r)
|
||||
}
|
||||
1000
2024/gareth/day02/input.txt
Normal file
1000
2024/gareth/day02/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
45
2024/gareth/day02/poc.py
Normal file
45
2024/gareth/day02/poc.py
Normal file
@@ -0,0 +1,45 @@
|
||||
def is_safe(report):
|
||||
increasing = report[1] > report[0]
|
||||
decreasing = report[1] < report[0]
|
||||
|
||||
for i in range(1, len(report)):
|
||||
diff = report[i] - report[i - 1]
|
||||
abs_diff = abs(diff)
|
||||
if abs_diff < 1 or abs_diff > 3:
|
||||
return False
|
||||
if (diff > 0 and not increasing) or (diff < 0 and not decreasing):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def is_safe_with_dampener(report):
|
||||
if is_safe(report):
|
||||
return True
|
||||
for i in range(len(report)):
|
||||
modified_report = report[:i] + report[i+1:]
|
||||
if is_safe(modified_report):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def read_reports_from_file(filename):
|
||||
reports = []
|
||||
with open(filename, 'r') as file:
|
||||
for line in file:
|
||||
report = list(map(int, line.split()))
|
||||
reports.append(report)
|
||||
return reports
|
||||
|
||||
def main():
|
||||
filename = 'input.txt'
|
||||
reports = read_reports_from_file(filename)
|
||||
|
||||
safe_count = 0
|
||||
for report in reports:
|
||||
if is_safe_with_dampener(report):
|
||||
safe_count += 1
|
||||
|
||||
print("OUTPUT:", safe_count)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
49
2024/gareth/day03/day03.go
Normal file
49
2024/gareth/day03/day03.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package day03
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
total := 0
|
||||
|
||||
regex := regexp.MustCompile(`mul\((\d+),(\d+)\)`)
|
||||
matches := regex.FindAllStringSubmatch(input, -1)
|
||||
|
||||
for _, match := range matches {
|
||||
if len(match) == 3 {
|
||||
x, _ := strconv.Atoi(match[1])
|
||||
y, _ := strconv.Atoi(match[2])
|
||||
total += x * y
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
total := 0
|
||||
isEnabled := true
|
||||
|
||||
mulRegex := regexp.MustCompile(`mul\((\d+),(\d+)\)`)
|
||||
doRegex := regexp.MustCompile(`do\(\)`)
|
||||
dontRegex := regexp.MustCompile(`don't\(\)`)
|
||||
|
||||
tokenizeRegex := regexp.MustCompile(`(mul\(\d+,\d+\)|do\(\)|don't\(\))`)
|
||||
tokens := tokenizeRegex.FindAllString(input, -1)
|
||||
|
||||
for _, token := range tokens {
|
||||
if doRegex.MatchString(token) {
|
||||
isEnabled = true
|
||||
} else if dontRegex.MatchString(token) {
|
||||
isEnabled = false
|
||||
} else if mulRegex.MatchString(token) && isEnabled {
|
||||
mulMatch := mulRegex.FindStringSubmatch(token)
|
||||
x, _ := strconv.Atoi(mulMatch[1])
|
||||
y, _ := strconv.Atoi(mulMatch[2])
|
||||
total += x * y
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
17
2024/gareth/day03/day03_test.go
Normal file
17
2024/gareth/day03/day03_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package day03
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))`)
|
||||
assert.Equal(t, 161, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))`)
|
||||
assert.Equal(t, 48, r)
|
||||
}
|
||||
6
2024/gareth/day03/input.txt
Normal file
6
2024/gareth/day03/input.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
-:-]what()(+/mul(957,396)?mul(550,844)%+why())-? #}from()mul(488,628)%} ~**mul(770,931)$~mul(791,733)<{mul(985,350)<#why()don't()what()select()$what())]what()who()mul(327,185))<^^mul(542,68)#?who()<from()';^how()mul(619,952)/where(){(!);'@,mul(551,161)select()>when()do()from()mul(51,291)[where()!{]/}'@?mul(233,511)@what()]mul(311,967))&who()how()mul(839,578)^who()]}mul(266,735){mul(176,670)mul(154,710)*select()](':^,mul(531,801)# *why()why()mul(30,325)~,where();select()select()}-/when()mul(512,729)+where();[mul(720,339)[~*when()mul(722,867)!);{+mul(582,286)^:)what()@mul(604,485) (who()why()who()from()[mul(128,295)how()?!%~~<what()mul(156,267)'how(689,161):where()mul(206,221) mul(835,81);] %mul(562,798)^{%where()mul(38,166)#!what()mul(185,550)^! ?,+;}}mul(685,101)select()mul(316,869)>[~}{[&;mul(548,186))(%];mul(841,290)when()where()'?mul(646,803)mul(553,782)how()when()-mul(569,604)@ ++:/%why()]select()mul(257,598)#mul(897,819)how()what()from()how()]when()~/!}mul(856,271)+&why(){}why()>who()mul(373,408)-who()^&%>';,when()mul(54,88)what()!mul(663,711)$#(?;^from()mul(898,810)when()from()%@mul(776,102)why()mul(303,842)!/,%<^;mul(840,791){[@mul(909,714)don't()>who()why()from(545,686)%~mul(483,956)^'why()from()where()$>*:mul(931,649) mul(800,313)):mul(31,69)mul(549,670)$;mul(327,976)@who()^mul(627,907)/[@what(925,706) ;^who()!mul(629,813)when(){$&where(){#mul(504,147)?mul(222,429)#who()*/!select()<what()mul(310,934)])^/$]mul(917,911)-%how()?[;,mul(823,273)*[~select()/select()~%mul(703,815)what()where()?what():'?[who()mul(966,52)how()&-~(%[(^mul(913,694)mul(190,570),&<%'from()where()what(979,309):+mul(662,926)/<!when()'select(),/&*mul(655,410) how()}mul(386,934)where()[mul(159,595)@']from()when()#?@mul(356,559)&)>?$ mul(439,336)?from()*select()*}when()]who()mul(148,356)(who()+mul(271,905)mul(564,172)@?(~mul(628,470)#} mul(301,170)?@,^don't();&:^&how(605,264))(what()'mul(896,108),$mul(413,431):<>where();how()>!}when()do()!}/&:when()>mul(754,737)~:#:* mul(962,620)}mul(26,490)!~,mul(450,234){/]who() <;{mul(938,932)?--#%};}mul(140,314)(-}/,[mul(202,839)^why()-!},mul(459,716),mul(600,932)}when()]who()}who())&mul(752,142$mul(174,573)mul(231,182)from()mul(308,661)what()} mul(178,99)&^*[(mul(858,730)~}from()^mul(17,545)what()~{~*^what(90,714)how(),mul(63,969)-]mul(364,49);mul(130,598<:&why()select(879,794)mul(46,169)>&how()%mul(564,506)/what(255,868)mul(415,375)':@who()mul(525,772)<$mul(277,787)[~mul(314,321)'&@$^%mul(741,325)?(%#;*mul(459,703)why()~what()mul(250,38)what()<-$)when()%(don't()mul(296 ',mul(673,933)?#<@who()from()^?mul(831,912)?/*mul(407,853)mul(119what()why()>mul(816,762) how()<}~from()how()/@:mul(792,799)()@?%:$:mul(289,264)
|
||||
why(),'*),from()mul(767,350):>~mul(123,684)@from()>mul(722,338)<'<select()what()}*select()mul(993,866)where()[;'select()what()select()?why()mul(357,705)what(){+&mul(590,928)how()[why()how()+what()><why()how()mul(417,421)/[?where()mul(298,609)*%who()#where()}why()(~+mul(233,280)when()mul(740,13)where()#why()!/mul(702,342)@;mul(945,10)[}!#mul(758<mul(969,595)+how()from(573,280)what()mul(351,944)what()where()]+<how()&[^mul(211,333)what(590,707)<'mul(579,209)do()^what(324,278):<+)!mul(482,641,^why()/<$from()select()mul(302,432);$where(){*mul(58,633)#]+,select()'$mul(534,736)@+~@what()/mul(492,990)'mul(606,447)~}, #@$)$/mul(878,726)'++'who()!where()what(777,25)why()mul]@>mul(252,529)do()%)%^when()!mul(731,123)mul(582,378)-mul(934,355}where()what()how()@%<[>;<do()(mul(709,553)])?&~mul(936,634)when()who(),do()#$$mul(917,683)select()when()+mul(858,234)!mul(828,850)@(?)^)mul(244,230)*^/%what()[^$who()@mul(716,56)from()/mul(312,20)!)mul(333,734)select()from()from():$how()+$${mul(443,208) &when()&$-&:mul(4,320):*;&#~~mul(261,16)&select()'@who()~^+mul(597,905)]]()who()(mul(273,2)who()how()#+?when(263,200)/mul(699,563)$don't()why()]!mul(744,844)>:mul(5,63) who()!mul(946,479)+}select()$@mul(478,71)~<()-#mul(500,398)'from(612,869)select(98,846)!!<]:select()mul(785,98)',select()//:-mul(192,182):{ why(){;mul(910,471)&^+&who(424,579)/:select()[mul(217,829)where()how(423,674)$*mul(318,444)[!?~mul(254,793)who()select(521,861)how()mul(54,186)why()[:^;-mul(109,234)mul(465,266)+?([-mul(518,485)^mul(403,383)mul(726:how()when()#mul(344,785)/}+?mul(97,996)+@'mul(637,749)how()-%+mul(302,591)don't()%^]}!)]mul(524,902)$[]/*mul(839,651)}^)$when()'what()mul(270,805)#mul(566,750){ how()/mul(716,302)/&*>@-what()>when()what()mul(602,574)+where(619,83)mul(235,585)?where()[%select()+>where(){]mul(209,404)~where(),why()how()-/-mul(123,125)^'how()who()$}/;mul(851,629)how()who()'#;$ do():select()!when()[>+>mul(576,669)what()!,'?from()&mul(423,260) how()-mul(910,922)?<@'->(mul(274,173)why()}<~from(601,667)mul(282,816)<how()when()when()' ^from()mul(939,359)mul(385,79)who()&when()-^?-^don't()how()+*/mul~@, @/!$mul(526,30)}(:~from()do()who()$/!~)what():%mul(366,255)(*+>from(953,125)~mul(98,837)&[how()[what()mul^%} '$from()^-;mul(439,801)mul(761,498))>$'-why()<</mul(557,979)[mul(224,700)*mul(917,173)[-(~;mul(44,236)%select()what()( ![(who()mul(153,275?how()(!/mul(627,465)%/>who():mul(109,723)from()who()mul(391,416)& -how()>mul(496,170)^'${mul(657,96)why(611,959)why())from()%+mul(62,175)>}~,%from() >mul(92,927)mul(17,279)!why(){+where()}how()mul(939,286){;mul(744,904) from()?''who()&who()how()mul(170,192)@,mul(499,985)';from()})!{+who(){mul(572,653)#:why()mul(720,626who()from()(%:mul(676,779)!why() when(58,261)^ *mul +from(){)')@!*mul(802,646)how()(-+[;#when() {mul(742,576)<where()>]* ;mul(38,717)?what()}'how(184,130)mul(126,115)]@>mul(512,978)/where()+*why()mul(705,242)?{$how();when()mul(173,898)'(~who()mul(536,621)&^from()select()when()?@mul(52,680)] -%@;][mul(971,573)^mul(879,466)
|
||||
mul[!-,why()(?mul(770,624)~:mul(197,580){{(%mul(678,337)what()mul(951,457)'<#mul(679,253)?do()who();& who()select()mul(105,231)+{&!when()who()how()!')mul(262,609)):,{'from()/?@}don't()*:mul(471,462):([(@;from()mul(734,965)/&/where()mul(885,324)why(){>/#<:mul(390,818)!mul(684,730)*>>{[!what()what()mul(824,893)mul(801,597/why()!when()how() '>from()%mul(165,825)who(837,795)?? why(187,949)mul(703,551) when()'mul(759,898)select()#$$ where()where()mul(694,292)%(who()%#}mul(884,767)^<mul(900,512)^what(862,782)%*}mul(484,385)]where()where()mul(593@{what()?{{@&who()^*mul(511,975)+%from(193,630)@-~how()/<mul(161,30)mul(462,217)mul(283,656)when()mul(733,613)what()^what()why()/where()what()^!mul(777,858)^select()mul(732,203)how()<mul(574,457)select()where()$who()when()~where()#}mul(525,448)*mul(5,230)mul(347,280)<from()#what()mul(613,165)@who(609,769)@~/,%#;*mul(298,242)what()+~when():($-(mul(118,981)mul(72,529)$^~select(306,809),!/(mul(864,257))what()-?mul(308,631)? //*&,/!don't())>:$mul(945,214) where()how(837,748)(mul(537,489)(%{mul(594,245)who()from()from()%}!)])why()mul(832,704)^~mul(902,18)how()what()who()/#'-#mul(345}who()when()?]&^mul(873,161)^mul(81,518)]$mul(875,700)how()where()(mul(735,369)/-< why()@>mul(703,274)-<mul(949,449)what()+(>from()when()**,)mul(204,896)]+mul(28,596);why()#select()'#]mul(774,171< why() !from()mul(29,711)mul(28,600)}when()!@(^why()~{mul(555,761)%}do()from()-mul(139,179){how()'?mul(294,354)}where()mul(317,957)]select()#;where() where()^@from()mul(461,831)~who(75,120)%who()@-&;,)mul(563,131)mul(607,401)select())from())&,mul(26,412)select(726,797)&)how()@select()mul(416,615)(what()select()!()<<what()who(299,911)mul(628,777){mul(712,971)(*]what()from()<>#;&mul(921,158)>- mul(245,598)select()what()*({mul(468,522)]^select(574,638)]@};do()from(799,930)%who()#:[how()mul(413,674)[how()*mul(327,432)%?@'mul(486,644)}~>-mul(637,16)how(254,818){%where()#where()who():who()mul(431,749)$$where(228,303)<!why(109,819) ]mul(693,21) where(396,89)[mul(60,538){mul(738,595))-&why()how()why()(mul(698,770))*>,%+&mul(593,337)}#:where(){why()[+&!mul(520,180)^mul(723,959)mul(492,739){/?mul(327,463)?-select()-<,mul(102,950)!#do()@when()-when()},select()/mul(274,979/from())who()(~)!^$mul(78,739)why()@{~mul(819~?~+]>@mul(824,208)}mul(338,41)where() &*;;&what()mul(888,646)from(),$:-who(263,596)!!-from()mul(396,204)>{)>{?(%{mul(885,937);!what()&%!<mul(178,507)mul(833,974)^mul(842,332)>from()}mul(207,417)(<;what()mul(187,893)((&&}&why()*)-mul(589,985)^how(310,10)when(),]:mul(989,534)$where()mul(552,604;(!;select(){){where()#mul(152,511)+/$!;+/<+]mul@select()::when()who()how()!what()mul(446,994)from()<}what()select()'why(244,102)+<select()mul(516,369)]&mul(707,483):@}%?what()from()don't()mul(407,712)$:{&:,,,?mul(112,3)-~- what()>)%}who()mul(693,903)?*/}select()mul(282,115)[];why(){mul(925,276)how()&{what()&$when()&-!mul(191,385)*)mul(446,703)[>what()?*}what()^who()*mul(997,718)!>$)@,^*)mul(788,724)from()#&]~/<,)how()mul(181,531)[(why()[mul(409,206)what(604,231) when()why(921,229)]>where()//mul(199,96)when()why()#!/usr/bin/perl~%>~ &:mul(239,884)
|
||||
what())[$^+why()mul(118,89)mul(689,203)#,,what()what()mul(633,394)from();~from()!where()*?@mul(568,753)/[+when()?%:mul(828,475)what()don't()-;@ mul(509,544)[when()};<+'(mul(235,757)<+:%select():mul(241,373)$mulselect() (%where()where()]-)mul(306,62)from()what()mul(285,414)!*&&>who()#mul(543,866)/~select()[+don't()/><why()from() ~#mul(983,515)#mul(731,258)mul(894,831){>)where()!when(),'mul(701,189)/';!:]+how(902,507)-^mul(847,104)mul(883,112){'~}&mul(697,190)what()%-mul(220,860)+^mul(765,74)select(),$who()<mul(685,855)!what()where()why()#{,-;mul(302+^(who()]from()~<?where():mul(383,623)::~(>,@mul(639,551);(mul(26,80)why(480,988)^why():? <[mul(672,116@mul(316,879)}mul(498,582) @,:{'why(589,887)mul(39;]mul(855,31)^from()?mul(93,510)mulwho(){@-what()<where()~select()mul(225,679) 'mul(305,662)/:,mul(887,727)?:~:&/select()#:<mul(755,830)^#}+@)how()?^mul(14,79)-mul(433,926)what()'mul(458,711)>from();where()from()~:(mul(688,799)~when()>from()-select()who()~<mul(71,560)( who()? +#^who()[mul(70,477)}>#+{ >mul(275,916)#?-mul(359,865)where(441,672)'}what()[from()when()<>who()mul(909,227)$:!'mul(330,478)!?[;(+#what(919,466)&/mul(73,181)[{how()mul(403,182);mul(249,968):!from()?!{#-mul(661,975)!-;}'mul(999,285)select(565,140)+>@,$:from(47,825)~!mul(599,436))<when(603,518)@mul(567,365)?(}}where()<{:who()?mul(755,613) <*who()mul(448,608)$$mul(507,887)mulwhen()]when()^$+@();+mul(846,707)]mul(932,511)who()}}where()#mul(122,316)#>+ [>%!mul(959,617)mul(5,150)where()@;&mul(630,775)<select(686,710)who()/';[*%select()mul(859,837)'mul(451,3)(when()($/+mul(499,794){]mul(194,78)from()'?don't();mul(47,314){who()~/]mul(526,464)why(666,133)#}/;]:mul(223,721)how()><&-:;mul(114,820[don't()when()#how()mul(976,290;+-from()where()]mul(338,47)when()what()where()%]mul*who() #+what()mul(679,324)mul(859,321)%'mul(446,297),#select();<mul(797,938)who()mul(531,845)}*select()@{mul(661,677)/)'*mul(837,800)<who()select()<]}<@mul(844,594))when()where():'mul(75,307)mul(676,67)(]what()<select()?mul(851,92)+&)mul(683,41)?<,/:~'mul(179where()from()~<mul(674,897)/!how(529,298) *[}from(),mul(362,131)}! % $mul(168,955)mul(517,218)[(,mul(740,567)}~[)$@from(),do();]mul%/%]why()mul(777,920)what()what()$;<what()mul(307,462)-+from()what()/$select()select()do()<select()&from()why()why()&mul(522,562))<how()-!+when(413,672)&)mul(621~(?select()<*-why()mul(372,852)}]~mul(668,335)mul(512,514){%mul(873,547)[*(mul(887,814)]>';from()mul(206,301)why()-'mul(87,734)<where()+:mul(844,819){#^^mul(130,409)[('@what() ;mul(916,629)@@who()-?}mul(320,288)what()?mul(184,677)[@#select()+::-select(929,36)/mul(329,568)
|
||||
{^mul(75)<:from(){select()select()mul(833,211):[-'mul(702when()who(21,237)+)&!>mul(735,118)] {/what()*@^what()where()mul(685,883)when()what()mul(91,84)}]<select()why(795,767)@why()]}$mul(711,291)select()--+<*who()mul(898,469^how()>-~where(){when(374,912)$do()>~,' how()mul(67,939),)&~@where()(mul(923,997)~,*$when()[from()from()mul(699,705)~/when()+}mul(214,775)'%mul(715,142)-;mul(290,853)from()$why()what()select()-@-mul(682,729)+^$}, !mul(197,39)mul(269,573)@^mul(819,945)/select()-do()%$~'#select() 'mul(64,956)[who()*who()@,)>+}mul(519,356);*/%>why()[[)mul(184,666)what()mul(892,160)+*&where(764,214)--]?(>mul(996,338)>when()what()]))&?mul(865,864))?@[::when()>what()>mul(218,296)&)%:<?mul(903,712),+mul(102,86)' ^,[>[~why()how(416,393)mul(118,100)from()select()#: $mul(7,742)how()&~how()>who()^mul(667,218)?/mul(218,898)!:$from()>mul(746,995)(+select()] when()}mul(971,429), !,&mul(505,165):!-)?-how()from()%mul(921,456)@mul(491,404)#how()-mul(284,834)#?(mul(667,960)]where():how()what(963,920)% what()don't())mul(236,336) why()why()select()where()^mul(33,901)mul(253,866)<#>$]%-mul(216,512),)from()what()what(464,183)where()select()@'}mul(98,640)' :)what()$%~#/mul(283,893)(mul(520,959)#^?{>@*when()when()]mul(80,420)where()mul(751,106)when()when()! how()mul(148,813)@><^[mul(740,246) how()where()!!/mul(242,262) who()who()%,mul(308(#/when()$mul(359,332)from()why()from()~$$^where()@mul(270,445)why()}%mul(623,449)where()how()?& />mul(759,849)-} (mul(84,200),$;who()[!mul(934,76)(@^:where()why()/'mul(650,46)[mul(105,265):)when()+ &'what()^mul(334,290)] $what()/mul(930,226,>^!%don't()mul(243,460){'#/what()+/mul(437,684)mul(501,579)/mul(243,174)mul(988( +<#where(206,306)where()[,from()mul(331,170)(?^~}#mul(940,949)>(,*+mul(925,961)^*from()select()^--^)(mul(994,182)+'+mul(153,816)~<!?[mul(31,276)don't()how():/!*] !^~mul(404,438)from()<]?)})>&mul(260,998)~:],],who()why(348,109)why()<don't()]#?)select()<<where(999,395)mul(342,366);what()select()~&~mul(120,353)when()]mul(198,41)][;(]:select()-[mul(947,937)$$when()-{mul(672,675);/!mul(14,647)>who()when(290,863)why(735,89)!from()@ >#mul(205,831)'$ %'mul(981,644)!<mul(100,956):{#select()#*mul(168,493)who()-%)#;{don't()^]who()~~ *mul(47,958)mul(130,976)how()~how()?what();mul(983who()(why()/)},]*:/mul(374,969)>#,*>mul(910,535))[who()#mul(220,934)how(271,592)-,*$,+mul(11,63)mul(783,580)^&*}~<mul(677,425))select()when()/how()mul(181,298)??why()how()&/mul(670,720)/@!when()where()#mul(403,306)]from()(from()why()*why()don't()^~from()[select()who()select()mul(516,37)what())}-*>(;from(){mul(21,444$what(274,202)<where(),}mul(706,78);select(275,134)]{&}why())@mul(302,87)[@[who()!when())mul(196,98)mul(918,675):,>how()mul(293,78)mul(189,814)#{}why(80,738)}from()mul(456,691)*@{(,[%mul(916,89)how())(]@mul(524,412)];:(mul(374,851)where()[mul(473,999)select()$what()}don't();];(}mul(327,69)%&+;:/what()don't()-%,'()mul(377,536)mul(31,322))@what()^select()mul(719,58)$why()~&what()']}mul(39,890)(+<#who(){how()!<mul(559,894);-&what()from()#$do()mul(256,3)where()^how()when()$:<what() mul(664^-from()}mul(469,922)from()>mul(299,824)(]](+mul(205,11)
|
||||
{mul(602,646)!% ^mul(384,953)do()&&:]<<select()#<mul(766,701)&@(what()who()+>mul(228,736){({}don't()-when()@*>-mul(278,494))/&<mul(596,290)select()when()),{ ~mul(563,584)mul(351,221)how():#where()[{%what(128,820)[ mul(754,363)!{)how()&''from()mul(388,712)?;'>?><(select()mul(916,219)select(),:{(<*mul(360,209)why();~}where()-(,mul~when()when()!where()@:;:#/do()select()select()!,how(972,480)~-how()who()mul(726,867):>mul(549,954)](how(802,821)select()how()[+^mul(535#select()}why()[what()]why()*{#mul(72,525)mul(809,41who()!~where(82,230)}mul(961,563)}who()what(417,588)<how()mul(756,106)!)when() [mul(733,591)how()[why(),<+@,mul(889,603)when()when()mul(60,212)mul(955,930)]~&)/!}-}&mul(206,66)where(882,366)~/<{mul(745,261)'<where()<why();select()(how()mul(74,146)where():~who()what()>&*mul}{,+?%^[when(34,108)who()mul(71,111)$+,}#~-<mul(265,932)]$what();^mul(775,136)mul(192,60)how(){)mul(212,476<who()?mul(264,266)[,^&/how(215,234)mul(447,79)!!+;,who()@{mul(897,924)^what()-%((don't()mul(259,393)who()when(956,639)&where()]@{,mul(637,712)%(mul#'select()!~<+<do(),#&<:% -{)mul(914,330)when()-)?@]{where(240,411)*select()mul(191,984),%?-what()+{mul(623,7)+mul(899,145)</why()select()what()<{~mul(849,743)!where() mul(43,318)when()!~$)mul(607,51)!?<mul(123,500)<]how()!what(){(mul(380,536),mul(367,657)~{,why()?-*$mul(589,520)(#mul(568,853)!-how()'^what()}'^mul(924,205),};'/^!!@mul(765,625)*!+where()[@select()-~do()!!,who()+%mul(369,495)()/mul(530,282)mul(148,870)]*where()mul(668,764)%who()how()how()&![who()mul(678,727)>^]@ when(){:@mul(545,335) &how()from()<:mul(958,59)$ (what()mul(886,155)how()&+mul(525,132)<&}who(502,340)select()when()#^mul(339,398)who(),(how())@@how()$$mul(831,852)when()don't()>mul(935,45) select(930,598)!:select()mul(693,62)(mul(681,508)how()^@*;)mul(235,731)who(468,32)#~>don't()#:what()where()when()~<who()-/mul(137,827)!who()!why()mul(806,939)from()mul(492,899)why()^),who()]#from()$ mul(384,731)>~^>@#{mul(2,62)mul(866,617),>% mul(806,586)how():{/mul(669,407)!/mul(457,522)mul(40,474)>)]select()who()}mul(451,794)]#mul(115,471)~mul(331,456)@^who(){#when()mul(672,70)where()who())(#how()what()!mul(438,748)-/mul(605,224)mul(46,34)~?'</'$#how()&mul(278,426) mul(710,864)mul(296,109);mul(481,73)&<,]mul(650,979) mul(575,478)how()$@%#;mul(319,368)][select()where()/ /,:when()mul(399,630)from()mul(9,26)~'do()mul(953,316)%''%{>mul(650,523)?mul(871,731)?%from(966,980)>when()mul(790,779) from()#$:,'mul(428,763)@# why()mul(724,6)select() ,mul(208,11)why()how()mul(287,562)$[:select()},?mul(531,36)/mul(12,351)#$+,:#:$when():mul(941,380)-[from()!)?-select()mul(102,544)when();~{select()~^;-do() ]who()from(),<who()]/>mul(959,599)>why()/,<%-,!mul(517,558)%])$mul(945,968)mul(854,265)?<when()mul(98,913)<&&}]+mul(830,92)where()]why(132,949)why()from()when()'when();{mul(615,131)(,;}^~!mul(973,226)how()^}){}mul(45,238) where()#)'!~ <
|
||||
91
2024/gareth/day04/day04.go
Normal file
91
2024/gareth/day04/day04.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package day04
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var directions = [8][2]int{
|
||||
{0, 1},
|
||||
{0, -1},
|
||||
{1, 0},
|
||||
{-1, 0},
|
||||
{1, 1},
|
||||
{1, -1},
|
||||
{-1, 1},
|
||||
{-1, -1},
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
grid := parseInput(input)
|
||||
return countXMAS(grid)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := parseInput(input)
|
||||
return countXMASPatterns(grid)
|
||||
}
|
||||
|
||||
func parseInput(input string) [][]rune {
|
||||
lines := strings.Split(strings.TrimSpace(input), "\n")
|
||||
grid := make([][]rune, len(lines))
|
||||
for i, line := range lines {
|
||||
grid[i] = []rune(line)
|
||||
}
|
||||
return grid
|
||||
}
|
||||
|
||||
func countXMAS(grid [][]rune) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
target := "XMAS"
|
||||
total := 0
|
||||
|
||||
for r := 0; r < rows; r++ {
|
||||
for c := 0; c < cols; c++ {
|
||||
for _, d := range directions {
|
||||
dr, dc := d[0], d[1]
|
||||
found := true
|
||||
|
||||
for k := 0; k < len(target); k++ {
|
||||
nr := r + k*dr
|
||||
nc := c + k*dc
|
||||
if nr < 0 || nr >= rows || nc < 0 || nc >= cols || grid[nr][nc] != rune(target[k]) {
|
||||
found = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if found {
|
||||
total++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func countXMASPatterns(grid [][]rune) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
total := 0
|
||||
|
||||
for r := 1; r < rows-1; r++ {
|
||||
for c := 1; c < cols-1; c++ {
|
||||
|
||||
topLeft := grid[r-1][c-1]
|
||||
topRight := grid[r-1][c+1]
|
||||
center := grid[r][c]
|
||||
bottomLeft := grid[r+1][c-1]
|
||||
bottomRight := grid[r+1][c+1]
|
||||
|
||||
if center == 'A' && ((topLeft == 'S' && topRight == 'S' && bottomLeft == 'M' && bottomRight == 'M') ||
|
||||
(topLeft == 'S' && topRight == 'M' && bottomLeft == 'S' && bottomRight == 'M') ||
|
||||
(topLeft == 'M' && topRight == 'M' && bottomLeft == 'S' && bottomRight == 'S') ||
|
||||
(topLeft == 'M' && topRight == 'S' && bottomLeft == 'M' && bottomRight == 'S')) {
|
||||
total++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
35
2024/gareth/day04/day04_test.go
Normal file
35
2024/gareth/day04/day04_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package day04
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`MMMSXXMASM
|
||||
MSAMXMSMSA
|
||||
AMXSXMAAMM
|
||||
MSAMASMSMX
|
||||
XMASAMXAMM
|
||||
XXAMMXXAMA
|
||||
SMSMSASXSS
|
||||
SAXAMASAAA
|
||||
MAMMMXMMMM
|
||||
MXMXAXMASX`)
|
||||
assert.Equal(t, 18, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`MMMSXXMASM
|
||||
MSAMXMSMSA
|
||||
AMXSXMAAMM
|
||||
MSAMASMSMX
|
||||
XMASAMXAMM
|
||||
XXAMMXXAMA
|
||||
SMSMSASXSS
|
||||
SAXAMASAAA
|
||||
MAMMMXMMMM
|
||||
MXMXAXMASX`)
|
||||
assert.Equal(t, 9, r)
|
||||
}
|
||||
140
2024/gareth/day04/input.txt
Normal file
140
2024/gareth/day04/input.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
XASXMAXXMSXXSMMSXMMSMXSMXMSSMSSSMMSMAMXMXSMMMMAXAMXSASXSSMMSSMXAMXMSAMXMMXAXXXSAMXXXXXMMXSXMXXSMASAMXMXAXXMASAMXXXMAMMMSXSXMXMMMSAASXSMSSMMS
|
||||
XASAMSSMAMMMAMAAAMASMAMAAXMASAAASAAMAMAMAAAAASMSSSSMAXAAAXASASMMMMMMXMASXMAMXXXXSMSMSXSAAXAMXMASMXMMSMSAXSXMMSXSMMAAMXAMAAMMAAAAXMXSAAAAXAAM
|
||||
MXSXMAAMXAAAXMMSSMAXMASXSSSSMMSMMSXSASMSMSSMMMAAAXXXXMMMMMXXAMMAAAASMMAAAXMASMXXXAAASAMMXSASASMMMAMXSASASASMAXXMAMSSSMSSMMAXSMMSXMMMMMMMXAMX
|
||||
SAMMMSSMMXXSXXXAAMSMSASXAAXMXXAAXXXMAXAAAXXMASMMMMMMXMXXXXSMXMSSMSASASMMXMMXMAAMASMSMSMAASXSAAAASAXAMAMXAAXMASMSSMXAMMMAMXSAMAMAASXMMSSMSAMX
|
||||
MASAAAAMSMMMMMMSMMMAMAXMMMMMXMSSMMXMSMMMMMAMXASAXAASXMMASAAXAXAXMXMXMXAASXMAMSXSAMMXMMMMMSAMXMSMSMSMMAMSMXMMASAMXAMMSASAMMXASAMSXMAMXAAXSAMA
|
||||
SSMXMSMAAMAAXXAMXASMMSMAMXSXSAMXXMAAAAXSXSAMXMASMSXMASXAMSAMXMMMSASMXMXMMAMSMXAMASXMXAASXMMMMXM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XMAMMSSX
|
||||
XSMMMASMMSSXSAMXMAAMASXXMAAASXMMSMAMMMASAMXAASAXXXSASMMMSMSMSSXXAMXMXMASXMASMMMASXMASXMMMXSAAMAMSMAAAASMXSAMSSSMMASAAAAMMAXMAMXAXAAMAMAMXAXX
|
||||
AXXXSXMAXXMXSSSMSSMSXMSSMMSMMMXXXAMXSMXMXMMSSMSMSAMXSAMXXXXMMMMAMXXXSSXMXSAMXXMXMXAXXMASXMSMMSMMSXSAMMSXMMMSXMAXMAMXMSMXSAMSXSXSMSMMXSASMASX
|
||||
134
2024/gareth/day05/day05.go
Normal file
134
2024/gareth/day05/day05.go
Normal file
@@ -0,0 +1,134 @@
|
||||
package day05
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Rule struct {
|
||||
X, Y int
|
||||
}
|
||||
|
||||
func ParseInput(input string) ([]Rule, [][]int) {
|
||||
sections := strings.Split(input, "\n\n")
|
||||
|
||||
ruleLines := strings.Split(strings.TrimSpace(sections[0]), "\n")
|
||||
var rules []Rule
|
||||
for _, ruleLine := range ruleLines {
|
||||
parts := strings.Split(ruleLine, "|")
|
||||
x, _ := strconv.Atoi(parts[0])
|
||||
y, _ := strconv.Atoi(parts[1])
|
||||
rules = append(rules, Rule{X: x, Y: y})
|
||||
}
|
||||
|
||||
updateLines := strings.Split(strings.TrimSpace(sections[1]), "\n")
|
||||
var updates [][]int
|
||||
for _, updateLine := range updateLines {
|
||||
parts := strings.Split(updateLine, ",")
|
||||
var update []int
|
||||
for _, part := range parts {
|
||||
page, _ := strconv.Atoi(part)
|
||||
update = append(update, page)
|
||||
}
|
||||
updates = append(updates, update)
|
||||
}
|
||||
|
||||
return rules, updates
|
||||
}
|
||||
|
||||
func ValidateUpdate(update []int, rules []Rule) bool {
|
||||
indexMap := make(map[int]int)
|
||||
for i, page := range update {
|
||||
indexMap[page] = i
|
||||
}
|
||||
|
||||
for _, rule := range rules {
|
||||
pageX, indexX := indexMap[rule.X]
|
||||
pageY, indexY := indexMap[rule.Y]
|
||||
if indexX && indexY && pageX > pageY {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func FindMiddle(update []int) int {
|
||||
n := len(update)
|
||||
return update[n/2]
|
||||
}
|
||||
|
||||
func SortUpdate(update []int, rules []Rule) []int {
|
||||
depen := make(map[int][]int)
|
||||
for _, rule := range rules {
|
||||
depen[rule.Y] = append(depen[rule.Y], rule.X)
|
||||
}
|
||||
|
||||
visited := make(map[int]bool)
|
||||
var sorted []int
|
||||
|
||||
for _, page := range update {
|
||||
if !visited[page] {
|
||||
sorted = Visit(page, depen, visited, update, sorted)
|
||||
}
|
||||
}
|
||||
|
||||
return sorted
|
||||
}
|
||||
|
||||
func Visit(page int, depen map[int][]int, visited map[int]bool, update []int, sorted []int) []int {
|
||||
if visited[page] {
|
||||
return sorted
|
||||
}
|
||||
visited[page] = true
|
||||
|
||||
for _, d := range depen[page] {
|
||||
if contains(update, d) {
|
||||
sorted = Visit(d, depen, visited, update, sorted)
|
||||
}
|
||||
}
|
||||
|
||||
sorted = append(sorted, page)
|
||||
return sorted
|
||||
}
|
||||
|
||||
func contains(slice []int, element int) bool {
|
||||
for _, item := range slice {
|
||||
if item == element {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
rules, updates := ParseInput(input)
|
||||
total := 0
|
||||
|
||||
for _, update := range updates {
|
||||
if ValidateUpdate(update, rules) {
|
||||
total += FindMiddle(update)
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
rules, updates := ParseInput(input)
|
||||
var invalidUpdates [][]int
|
||||
total := 0
|
||||
|
||||
for _, update := range updates {
|
||||
if !ValidateUpdate(update, rules) {
|
||||
invalidUpdates = append(invalidUpdates, update)
|
||||
}
|
||||
}
|
||||
|
||||
for _, update := range invalidUpdates {
|
||||
sortedUpdate := SortUpdate(update, rules)
|
||||
total += FindMiddle(sortedUpdate)
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
71
2024/gareth/day05/day05_test.go
Normal file
71
2024/gareth/day05/day05_test.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package day05
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`47|53
|
||||
97|13
|
||||
97|61
|
||||
97|47
|
||||
75|29
|
||||
61|13
|
||||
75|53
|
||||
29|13
|
||||
97|29
|
||||
53|29
|
||||
61|53
|
||||
97|53
|
||||
61|29
|
||||
47|13
|
||||
75|47
|
||||
97|75
|
||||
47|61
|
||||
75|61
|
||||
47|29
|
||||
75|13
|
||||
53|13
|
||||
|
||||
75,47,61,53,29
|
||||
97,61,53,29,13
|
||||
75,29,13
|
||||
75,97,47,61,53
|
||||
61,13,29
|
||||
97,13,75,29,47`)
|
||||
assert.Equal(t, 143, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`47|53
|
||||
97|13
|
||||
97|61
|
||||
97|47
|
||||
75|29
|
||||
61|13
|
||||
75|53
|
||||
29|13
|
||||
97|29
|
||||
53|29
|
||||
61|53
|
||||
97|53
|
||||
61|29
|
||||
47|13
|
||||
75|47
|
||||
97|75
|
||||
47|61
|
||||
75|61
|
||||
47|29
|
||||
75|13
|
||||
53|13
|
||||
|
||||
75,47,61,53,29
|
||||
97,61,53,29,13
|
||||
75,29,13
|
||||
75,97,47,61,53
|
||||
61,13,29
|
||||
97,13,75,29,47`)
|
||||
assert.Equal(t, 123, r)
|
||||
}
|
||||
1377
2024/gareth/day05/input.txt
Normal file
1377
2024/gareth/day05/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
142
2024/gareth/day06/day06.go
Normal file
142
2024/gareth/day06/day06.go
Normal file
@@ -0,0 +1,142 @@
|
||||
package day06
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Point struct {
|
||||
x int
|
||||
y int
|
||||
direction int
|
||||
}
|
||||
|
||||
const (
|
||||
Up = 0
|
||||
Right = 1
|
||||
Down = 2
|
||||
Left = 3
|
||||
)
|
||||
|
||||
var rows, cols int
|
||||
|
||||
var moves = []Point{
|
||||
{-1, 0, Up},
|
||||
{0, 1, Up},
|
||||
{1, 0, Up},
|
||||
{0, -1, Up},
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
grid, start, direction := ParseInput(input)
|
||||
total := PredictPath(grid, start, direction)
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid, start, direction := ParseInput(input)
|
||||
total := FindLoopingPositions(grid, start, direction)
|
||||
return total
|
||||
}
|
||||
|
||||
func ParseInput(input string) ([][]rune, Point, int) {
|
||||
lines := strings.Split(strings.TrimSpace(input), "\n")
|
||||
rows = len(lines)
|
||||
cols = len(lines[0])
|
||||
grid := make([][]rune, rows)
|
||||
|
||||
var start Point
|
||||
var direction int
|
||||
|
||||
for i := 0; i < rows; i++ {
|
||||
grid[i] = []rune(lines[i])
|
||||
for j, char := range lines[i] {
|
||||
if char == '^' {
|
||||
start = Point{i, j, Up}
|
||||
direction = Up
|
||||
} else if char == '>' {
|
||||
start = Point{i, j, Right}
|
||||
direction = Right
|
||||
} else if char == 'v' {
|
||||
start = Point{i, j, Down}
|
||||
direction = Down
|
||||
} else if char == '<' {
|
||||
start = Point{i, j, Left}
|
||||
direction = Left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return grid, start, direction
|
||||
}
|
||||
|
||||
func PredictPath(grid [][]rune, start Point, direction int) int {
|
||||
visited := make(map[Point]bool)
|
||||
current := start
|
||||
|
||||
visited[current] = true
|
||||
|
||||
// do while
|
||||
for {
|
||||
next := Point{current.x + moves[direction].x, current.y + moves[direction].y, Up}
|
||||
|
||||
if next.x < 0 || next.x >= rows || next.y < 0 || next.y >= cols {
|
||||
break
|
||||
}
|
||||
|
||||
if grid[next.x][next.y] == '#' {
|
||||
direction = (direction + 1) % 4
|
||||
} else {
|
||||
current = next
|
||||
visited[current] = true
|
||||
}
|
||||
}
|
||||
|
||||
return len(visited)
|
||||
}
|
||||
|
||||
func FindLoopingPositions(grid [][]rune, start Point, direction int) int {
|
||||
possiblePositions := 0
|
||||
|
||||
for i := 0; i < rows; i++ {
|
||||
for j := 0; j < cols; j++ {
|
||||
if grid[i][j] != '.' || (i == start.x && j == start.y) {
|
||||
continue
|
||||
}
|
||||
|
||||
grid[i][j] = '#'
|
||||
if IsLooping(grid, start, direction) {
|
||||
possiblePositions++
|
||||
}
|
||||
grid[i][j] = '.'
|
||||
}
|
||||
}
|
||||
|
||||
return possiblePositions
|
||||
}
|
||||
|
||||
func IsLooping(grid [][]rune, start Point, direction int) bool {
|
||||
visited := make(map[Point]int)
|
||||
current := start
|
||||
|
||||
step := 0
|
||||
for {
|
||||
step++
|
||||
next := Point{current.x + moves[direction].x, current.y + moves[direction].y, direction}
|
||||
|
||||
if next.x < 0 || next.x >= rows || next.y < 0 || next.y >= cols {
|
||||
return false
|
||||
}
|
||||
|
||||
if grid[next.x][next.y] == '#' {
|
||||
direction = (direction + 1) % 4
|
||||
} else {
|
||||
current = next
|
||||
|
||||
if visitStep, ok := visited[current]; ok && step-visitStep > 4 {
|
||||
return true
|
||||
}
|
||||
|
||||
visited[current] = step
|
||||
}
|
||||
}
|
||||
}
|
||||
35
2024/gareth/day06/day06_test.go
Normal file
35
2024/gareth/day06/day06_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package day06
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`....#.....
|
||||
.........#
|
||||
..........
|
||||
..#.......
|
||||
.......#..
|
||||
..........
|
||||
.#..^.....
|
||||
........#.
|
||||
#.........
|
||||
......#...`)
|
||||
assert.Equal(t, 41, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`....#.....
|
||||
.........#
|
||||
..........
|
||||
..#.......
|
||||
.......#..
|
||||
..........
|
||||
.#..^.....
|
||||
........#.
|
||||
#.........
|
||||
......#...`)
|
||||
assert.Equal(t, 6, r)
|
||||
}
|
||||
130
2024/gareth/day06/input.txt
Normal file
130
2024/gareth/day06/input.txt
Normal file
@@ -0,0 +1,130 @@
|
||||
#.............#.#...........................................................#..........#...........................#..........#...
|
||||
............#......................#.......#..#.........#...................##....................................................
|
||||
..............#...........#..#.......#.........#.#...........................#................................#......#............
|
||||
.....#......................................#......#..#...................#....................#......................#...........
|
||||
...#............................#................................#................................................................
|
||||
..........#..................#.....#......................................................#.......................................
|
||||
..#........#.......#.#...............................................................#......#.................................#...
|
||||
.#....#................#................#.....#...................#...............................................#..#............
|
||||
.......................................................................................#...#.#....#........##......#........#.#.##
|
||||
............................................#.................#.....................#..........................#..................
|
||||
....#..........##......................#.................................................................................#........
|
||||
......#.............##.........#.......#.........#.......#.............#...#.......#..............................................
|
||||
.#............................................................................#..........#....#...................................
|
||||
...#..#....#..............................#...........................................................................#...........
|
||||
.............#....................................................................................................................
|
||||
................................#..................##...................................#...............................#......#..
|
||||
..........#.........#.................#..........###...........................................#............#...#.................
|
||||
.............#....................................#.......#.#.#............#............................................#.........
|
||||
......#.#..............................................................................................#.........................#
|
||||
...#...#.........#.........#..#......#................##.................#........................................................
|
||||
.................................#......................#........#................#........................#......................
|
||||
.......................##..............#................#................#..............................#.........................
|
||||
.......#...#.....#.....##........................#..................##.....#......................................................
|
||||
.............................................#...........................#..........................................#.....#.......
|
||||
.........................#...............#....#..............#.......#...............#.#.................#.................#......
|
||||
...........................................................#....#..................................#..............................
|
||||
..........................#.................................................#............................##....#..................
|
||||
.................#...#.........................................................#........................#.....#..#................
|
||||
.........................#....#................................................#...#.....................#....#...........#.......
|
||||
................................................##.......#.#....................................#.......##........................
|
||||
..........##...#.......................#....#..#....................#........................#....................................
|
||||
#......#.......................#............#.....................................................................#...............
|
||||
.......#.......#...#..#..........#.......................................#.............#......#...................................
|
||||
...............#............#..................#.................................................................................#
|
||||
.......#...........#.......................##.....#.........#...........#...................#......#.........#.............##....#
|
||||
...................#.........................#......#..........................................#..........#.........#......#......
|
||||
.....#............#..............#...#......#....................#.............#..................................................
|
||||
................................................#........#.....#...................#.....................................#.....#..
|
||||
......................#.#...##......................##...............................................#.................#..........
|
||||
#...................#.........................#...........#.....#................#.....................#...................#......
|
||||
....#................#.....#.............#.....................................#....#...#.................................#.......
|
||||
.........#.....................................................................................................#.#.......#........
|
||||
.........#..........##..............................#............................#.#.............................#................
|
||||
#....#.#..............................................##...#...#...............#.............#....................................
|
||||
........#..#.#...................#.......................................................................#.............#..#.#...#.
|
||||
.................................................................................................................#.......#........
|
||||
............................................#..#...............##........#..........#.......................................#....#
|
||||
........#...........................#............................#.....#........................#..........#...#..........#.......
|
||||
.#...........#...................................................#...........................................#................#.#.
|
||||
............#...............................#........#...........#..........#...........#.#..............#........................
|
||||
...............................................................................##.#................#..............................
|
||||
.#.......................#.#...........#..................................#.......................................................
|
||||
..#..............................................##................#.......#....#..............#.....................#...#........
|
||||
...................#.....#................................................#..........#.........#.........#.....................#..
|
||||
........#................#................................................................................#......#................
|
||||
...................#...#....#.........................#.........................#....................#..........................#.
|
||||
.................#.......................................................#................................................#.......
|
||||
..#...........................##.#.............#..#............................................#.......................#.#........
|
||||
..#......#.........................................................................#.......................#......................
|
||||
...........................................................................................................#............#......#..
|
||||
............................................................^..........................................#..........#...............
|
||||
..#.........#....................#..........................................#........#.........................................#..
|
||||
........#...............#....#.............#......#.........................................................................#.....
|
||||
.........#......#.....#..............#...........................................................#..............#.................
|
||||
.........#...................................................#...###...........#.......#.##.......................................
|
||||
.....................##.................#.........##.....................#................#................#.........#............
|
||||
.......................................................................#..............#..............#.................#..........
|
||||
.##.........#..........................................................................#....................................#.....
|
||||
.........................#.............................#........................................................................#.
|
||||
........#.............................................#......#....#.....................................#....................#....
|
||||
........#...#..............................................................................#.........#............................
|
||||
..............................#................................#..........#..............#..................................#.....
|
||||
........##..#...................................#................................#.................#.........#......#..#........#.
|
||||
..................#......#...................................................................#....................................
|
||||
..........#.............#..............#........#............#...............#..#..........#..............#.#...#............#....
|
||||
............................##....#..............#......................................................................#.........
|
||||
...............................................#.....#...........#.....##...............#..#......................................
|
||||
.........................#.......#...............................#...........#.........#...........#....#.........................
|
||||
.#............#...#...............#..............................................................#..........................#....#
|
||||
#...........#......................................................#.............................#......#.........................
|
||||
..................................................#....#...............#.........................#................................
|
||||
................................................#..........................#.......#..............................#....##.......#.
|
||||
........#......#..#............#................#............................#......#.##.........#....................#..#........
|
||||
.......................................................#..#.#....................#..#......................................#......
|
||||
.....................#.......................................................................#............#.......................
|
||||
.....................##........................#...................#.....................#........................................
|
||||
..........................#...........................................................................................#...........
|
||||
..#..........#...................#..............##..#.....................#...................#..............#...........#........
|
||||
#................................#....##......#.............#..............#.......................#.........#...........#........
|
||||
..................#................#...............................#.....#..........#................#..............#.............
|
||||
................#.#.........#.....##...............................................................#..............#...............
|
||||
..#...............................................................................................#...............................
|
||||
..........#.................#...........#.......#.........................#...#.......#...........................................
|
||||
..##....#......................................#.#.......................................#.................#......................
|
||||
.......................#..#...#.##......................................................................#.........#...#...........
|
||||
...............#.........#..............#.....................................................#...................#...............
|
||||
......#.................#............#......#...................#..#.........................#........................#........#..
|
||||
......................................................................#...........................#........#......................
|
||||
..........#..........#........................#.............##....................................................................
|
||||
....#................................................#.......................#................#...............#...................
|
||||
.................#....................................................#......#....................................................
|
||||
.#........#.......................................................................................................................
|
||||
......##..................#....#......#.................#....................#.....................#..#...........#...............
|
||||
#...#...#...#..............#........#.......................#.#..........#...............................#......#.................
|
||||
#...#...................#.............#........#..........#...............................................................#...#...
|
||||
..#................................#...#.........................#...................#......#.....................................
|
||||
...#...###..........#............#...............................................................#..........#.....................
|
||||
............#..............#.......#.....#..........#.....#.........................................................#............#
|
||||
..#......................#..#...#................................#......#.......#.....#..................#.........#..............
|
||||
....##......#.......................................................#..............................................#..............
|
||||
...............................#.....#....#.................................................#.......#............#................
|
||||
..........#....#......................#........#..........................#......#................................................
|
||||
......#.............................#...........#..................#...........................#................................#.
|
||||
...........................##..........................................#.....#.#.....................#................#...........
|
||||
..#..............#.........................................................#........................#.........#.................#.
|
||||
#.....#.....#......................#....................#........................................#...........#...........#......#.
|
||||
.......................................#..#................................#.........#.......#..#.....#..........................#
|
||||
..........#..............##...............#..........................................................#......#......#......#....#..
|
||||
.............#..............#..#......#........#..#......##.......................#...........#.......#...........................
|
||||
......................#.......................................#.......#..#.....................................#.........#...##...
|
||||
...........................#...........................#......#....#.............................#.............................#..
|
||||
..................#............................#....#........##.........................#..............#.............#............
|
||||
.......#....................#.....#........#.......#.#...#...............#.....#.#.........................#.......#.#............
|
||||
.....#.........#.......#..........#.................#..#...#..................................................##..................
|
||||
................#........................................................#........................................................
|
||||
....##......#........#..................#.........................#...................................#...#...................#...
|
||||
..............#....................#.......#.......................#.............#......#..............#..........................
|
||||
...........................#..............#.....#............#.....................#........#....#.......................#........
|
||||
........#..##................#.....#.#..............#..............................#........................#.........#...........
|
||||
.........................................................#...........................##..........#........#.##....................
|
||||
90
2024/gareth/day07/day07.go
Normal file
90
2024/gareth/day07/day07.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package day07
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
total := 0
|
||||
lines := strings.Split(strings.TrimSpace(input), "\n")
|
||||
|
||||
for i := 0; i < len(lines); i++ {
|
||||
target, numbers := parseLine(lines[i])
|
||||
if validLinePart1(numbers, 1, numbers[0], target) {
|
||||
total += target
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
total := 0
|
||||
lines := strings.Split(strings.TrimSpace(input), "\n")
|
||||
|
||||
for i := 0; i < len(lines); i++ {
|
||||
target, numbers := parseLine(lines[i])
|
||||
if validLinePart2(numbers, 1, numbers[0], target) {
|
||||
total += target
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func parseLine(line string) (int, []int) {
|
||||
parts := strings.Split(line, ":")
|
||||
target, _ := strconv.Atoi(strings.TrimSpace(parts[0]))
|
||||
numberStrings := strings.Fields(parts[1])
|
||||
|
||||
numbers := make([]int, len(numberStrings))
|
||||
for i := 0; i < len(numberStrings); i++ {
|
||||
numbers[i], _ = strconv.Atoi(strings.TrimSpace(numberStrings[i]))
|
||||
}
|
||||
|
||||
return target, numbers
|
||||
}
|
||||
|
||||
func validLinePart1(numbers []int, index int, currentValue int, target int) bool {
|
||||
if index == len(numbers) {
|
||||
return currentValue == target
|
||||
}
|
||||
|
||||
sum := currentValue + numbers[index]
|
||||
if validLinePart1(numbers, index+1, sum, target) {
|
||||
return true
|
||||
}
|
||||
|
||||
product := currentValue * numbers[index]
|
||||
if validLinePart1(numbers, index+1, product, target) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func validLinePart2(numbers []int, index int, currentValue int, target int) bool {
|
||||
if index == len(numbers) {
|
||||
return currentValue == target
|
||||
}
|
||||
|
||||
sum := currentValue + numbers[index]
|
||||
if validLinePart2(numbers, index+1, sum, target) {
|
||||
return true
|
||||
}
|
||||
|
||||
product := currentValue * numbers[index]
|
||||
if validLinePart2(numbers, index+1, product, target) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Turns 12 || 34 into 1234
|
||||
concatenated, _ := strconv.Atoi(strings.TrimSpace(fmt.Sprintf("%d%d", currentValue, numbers[index])))
|
||||
if validLinePart2(numbers, index+1, concatenated, target) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
33
2024/gareth/day07/day07_test.go
Normal file
33
2024/gareth/day07/day07_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package day07
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`190: 10 19
|
||||
3267: 81 40 27
|
||||
83: 17 5
|
||||
156: 15 6
|
||||
7290: 6 8 6 15
|
||||
161011: 16 10 13
|
||||
192: 17 8 14
|
||||
21037: 9 7 18 13
|
||||
292: 11 6 16 20`)
|
||||
assert.Equal(t, 3749, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`190: 10 19
|
||||
3267: 81 40 27
|
||||
83: 17 5
|
||||
156: 15 6
|
||||
7290: 6 8 6 15
|
||||
161011: 16 10 13
|
||||
192: 17 8 14
|
||||
21037: 9 7 18 13
|
||||
292: 11 6 16 20`)
|
||||
assert.Equal(t, 11387, r)
|
||||
}
|
||||
850
2024/gareth/day07/input.txt
Normal file
850
2024/gareth/day07/input.txt
Normal file
@@ -0,0 +1,850 @@
|
||||
31084: 8 67 8 735 38
|
||||
40541461584: 5 81 9 4 32 43 283 228
|
||||
6208: 915 6 2 539 148 29
|
||||
306501986: 6 3 630 45 536 64 6
|
||||
21276000: 8 5 5 91 6 5 8 6 8 985 2 8
|
||||
1432991: 3 403 4 821 591 2 236
|
||||
17115994: 69 321 254 764 3 99
|
||||
19961295: 5 311 84 6 63
|
||||
22953531: 22 95 35 2 8
|
||||
18894343830: 90 5 3 2 65 7 159 2 91 1
|
||||
4312695565: 158 8 716 615 95 59
|
||||
391: 1 326 64
|
||||
25202: 8 5 62 1 401
|
||||
5324514: 6 8 466 59 169
|
||||
658234: 3 83 592 97 57 4
|
||||
26804472776473: 7 61 1 447 29 496 71 9
|
||||
1503368: 653 23 18 824 625
|
||||
24803314445: 5 2 4 4 417 1 987 4 447
|
||||
1021069871: 7 3 2 7 9 37 2 2 8 5 58
|
||||
1614: 63 645 4 3 31 868
|
||||
4258805: 68 532 78 91 5
|
||||
4495130022: 583 78 275 37 77
|
||||
45111648: 47 98 45 855 998 46 6
|
||||
2964501691711: 9 672 76 9 754 7 4 65
|
||||
90685578359: 906 855 782 33 126
|
||||
13608006: 3 5 7 7 3 602 7 4 7 720 6
|
||||
4645623: 66 863 5 615 8
|
||||
2569495: 443 74 7 71 5
|
||||
134484: 68 55 4 77 9 2 327 4
|
||||
1143450000: 24 750 35 264 5 1
|
||||
5449: 4 2 907 7
|
||||
23061783: 854 9 5 6 1 1 7 3 2 76 5
|
||||
2930: 18 6 7 555 5
|
||||
2115475: 9 194 8 54 42 5 31
|
||||
19449: 6 1 9 4 4 769 8 1 79 905
|
||||
4595553: 298 3 4 257 5 3 345 45
|
||||
208314087: 7 3 877 815 9 9 3 2 6 51
|
||||
2905504: 46 58 514 626 763
|
||||
963368: 48 425 484 6 370
|
||||
9980664: 1 98 80 5 98 68
|
||||
652568: 7 197 871 290 68
|
||||
45827: 15 3 665 9 154
|
||||
722: 2 21 337 5 357
|
||||
27652464029930: 7 829 9 700 7 9 3 7 4 1 8
|
||||
6868809: 45 2 9 848 9
|
||||
1175: 7 5 98
|
||||
2133: 17 2 5 36 5
|
||||
528: 55 1 5 8 9 31
|
||||
8206806: 1 4 9 4 99 6 24 97 2 5 6 5
|
||||
37530658373: 1 2 8 5 8 4 5 7 3 946 373
|
||||
65484738025: 47 5 4 43 8 6 43 7 7 26 5
|
||||
2157: 8 2 1 93 8 568
|
||||
23082508: 7 5 3 3 2 5 8 477 2 3 1 1
|
||||
29090880: 45 28 37 8 78
|
||||
1262763: 1 1 27 729 93 16 2 75
|
||||
1409848204234: 7 87 622 84 820 42 34
|
||||
3304: 6 55 4
|
||||
1196013120: 8 340 179 35 192
|
||||
124278235: 4 4 69 225 78 235
|
||||
2735190615: 273 2 3 1 906 1 5
|
||||
52192: 104 89 6 45 10 72
|
||||
573777850: 680 31 807 8 50
|
||||
35694425: 82 38 921 61 871 84 2
|
||||
658877085778: 7 86 55 156 10 977 8
|
||||
20860682976: 546 3 7 930 7 954 42 6
|
||||
224616: 441 46 8 36 73 8 3 45 7
|
||||
358087: 7 236 9 45 2 9 3 9 6 4 2 5
|
||||
6354432: 55 792 7 153 639 7
|
||||
1923524: 177 175 9 3 3 528 21
|
||||
117340: 9 82 159
|
||||
1234059: 64 357 9 45 6
|
||||
2651349895: 8 526 4 7 9 1 6 42 9 89 5
|
||||
3884759: 737 251 3 5 7
|
||||
633925731: 346 4 3 5 472 9 7 9 4 8 9
|
||||
43555: 37 4 60 25 53 77
|
||||
4230519: 2 2 12 8 9 9 91 41 2 5 2 3
|
||||
5489: 69 8 9 515 6
|
||||
82630872: 33 1 2 19 81 9 4 5 6 6 33
|
||||
203340489: 181 55 1 4 112 9
|
||||
72068: 7 197 4 5 9
|
||||
168389664: 1 683 84 5 667
|
||||
30367442: 2 657 6 4 384 5 673 49
|
||||
2846739576: 4 8 743 9 3 9 829 719 6
|
||||
78401: 77 4 9 93 5
|
||||
627886555182: 1 61 78 8 65 4 57 94 82
|
||||
53361: 85 3 592 1 63
|
||||
154268: 48 43 3 892 4 8 3 8 1
|
||||
525075263: 656 34 4 8 6 6
|
||||
248294606: 6 896 24 1 83 9 4 1 7 75
|
||||
9082152: 182 66 9 8 6 7 7 2 195 2
|
||||
1657909631: 8 5 76 7 5 95 2 9 22 544
|
||||
484430: 2 5 64 7 49 961 83 3
|
||||
11192683920: 6 26 7 8 5 8 6 3 8 372 1 1
|
||||
52887178: 4 863 61 118 60
|
||||
896861: 88 9 7 671 4 187
|
||||
721710054179: 135 891 60 541 81
|
||||
12403134: 92 6 34 58 6 5 7 9 6 6
|
||||
33615296: 312 44 55 9 3 1 572
|
||||
183192: 35 8 5 5 612 28 71 3 4 8
|
||||
1244794661146: 6 4 9 6 1 6 4 57 7 685 8 6
|
||||
362827266: 86 643 395 8 738 813
|
||||
1477891785: 86 6 2 8 13 2 91 7 1 8 8
|
||||
5983: 3 888 5 291 2 57 6
|
||||
73739569: 668 6 687 89 6 69
|
||||
902757501: 855 24 627 1 63 26 9
|
||||
177442819: 6 9 401 2 4 52 256 4 3
|
||||
87403263: 95 920 3 191 7 65
|
||||
223398085: 57 3 1 8 11 50 45 8 9 85
|
||||
76471: 81 472 2 1 6
|
||||
102739: 1 284 1 8 9 1
|
||||
98723250300: 79 119 1 1 2 143 5 7 21
|
||||
37813543: 28 4 5 813 540
|
||||
21449386021: 185 4 9 9 3 6 4 46 7 1 3 8
|
||||
355140846: 39 4 6 90 845
|
||||
25511824797: 3 7 4 746 48 55 3 15
|
||||
11681963: 5 76 9 67 1 35 3 8 50 3 2
|
||||
10812636790: 3 778 3 954 790
|
||||
144: 90 14 40
|
||||
2954988: 6 3 3 16 4 95 2 1 7 3 9 3
|
||||
1666626: 282 573 74 39 1 46
|
||||
380854191760: 2 7 24 5 54 177 5 5 664
|
||||
20485976: 47 155 643 323 3 8
|
||||
562264400: 8 1 3 1 5 74 3 67 309 88
|
||||
5054: 67 3 55 599 604
|
||||
5790: 8 6 4 3 7 43 1 9 8 4 17 6
|
||||
1423: 232 6 23 2 6
|
||||
2214885600: 1 5 2 1 3 50 183 41 82 3
|
||||
586061: 507 69 31 975 3
|
||||
68594249: 2 9 373 9 50 340 3 32 6
|
||||
380980: 95 4 980
|
||||
7510: 5 4 825 4 71 9
|
||||
451918: 90 50 18 11 106
|
||||
16294: 29 134 8 65 4 1 455 3
|
||||
10536237: 6 6 3 9 1 1 4 724 4 5 1 97
|
||||
24566372: 1 34 8 3 90 592 85 87
|
||||
284990: 5 5 5 91 7 5 88 5
|
||||
1108832032: 80 93 29 3 727 88
|
||||
215422984: 63 82 417 8 70 1
|
||||
37636247: 3 875 3 39 615 6 73 5 2
|
||||
511718662: 3 505 3 718 23 42 9
|
||||
172674894: 6 76 9 6 7 5 6 6 7 7 22 2
|
||||
2494298: 21 8 468 606 6
|
||||
1164891: 12 97 891
|
||||
1303421387: 8 604 17 5 6 48 95 87
|
||||
113169: 242 889 55 7 6
|
||||
28083319654: 7 1 6 2 780 4 8 9 9 3 8 7
|
||||
689769: 2 479 72 6
|
||||
664006: 603 60 997 9
|
||||
383810: 312 123 4 7
|
||||
278838736: 254 851 15 86 76
|
||||
35266920: 4 8 65 481 94
|
||||
2342060: 5 55 2 43 99 710
|
||||
61499384: 760 4 83 423 2 4
|
||||
1337677: 769 562 5 67 3 9 13
|
||||
20708670: 1 7 8 1 9 9 6 70 6 1 3 57
|
||||
22607703347: 23 6 7 6 7 67 80 39 44
|
||||
422584: 1 6 185 2 95 23 1 878
|
||||
16961283369: 7 614 720 9 609 1 9
|
||||
7743900: 12 80 8 38 33 75 525
|
||||
5198: 5 14 5 5 3
|
||||
7706: 5 765 6
|
||||
60799047884: 9 6 5 331 7 2 2 6 3 3 5 87
|
||||
373279812855: 74 65 5 946 16 571 5
|
||||
273426612: 519 24 87 2 656 3 958
|
||||
449: 250 94 8 9 88
|
||||
69949442: 8 92 4 1 15 33 8 3 1 2 2
|
||||
2540247614: 578 3 346 73 29 5 5 9 2
|
||||
72710790952: 99 4 87 255 85 7 4
|
||||
43727113667: 3 1 333 66 106 71 2 4 7
|
||||
74125836117: 4 5 52 6 25 35 9 3 521
|
||||
527906: 54 9 9 931 29
|
||||
139782: 11 33 6 526 918
|
||||
19218: 704 402 9 522 284 8
|
||||
8668810: 40 8 6 3 6 2 84 2 2 75 7 3
|
||||
1487663526: 9 9 517 70 2 6 2 5 94 8 4
|
||||
20610: 1 152 3 2 45
|
||||
359112: 323 5 47 54 7 6 3 8 4 2 4
|
||||
3198: 1 7 8 8 24 7 1 4 41 7 27
|
||||
41189: 13 9 3 624 5
|
||||
4720776758223: 47 20 776 758 222
|
||||
195264: 4 2 339 36 2
|
||||
16012371600: 6 9 6 3 6 3 95 3 76 4 185
|
||||
3864074: 3 4 426 84 73
|
||||
45674415: 42 4 9 7 82 410 5
|
||||
1175718380: 6 340 5 911 746
|
||||
51156: 3 4 4 540 87
|
||||
4831584: 2 43 8 2 55 5 7 5 69 96
|
||||
874516400: 874 5 16 368 32
|
||||
220190: 7 974 32 38 1 7 4 172 4
|
||||
429894584: 1 9 5 7 5 98 94 9 6 9 58 4
|
||||
114640: 3 7 31 52 7 6 1 772 299
|
||||
10759: 23 1 6 12 7 2 1 4 81 28 7
|
||||
360390945715: 2 431 696 27 213 20 5
|
||||
3140056: 783 9 5 1 43 9 8 864
|
||||
15606936: 96 6 40 639 172
|
||||
1134226: 9 824 46 152 2
|
||||
640: 5 32 2 2
|
||||
46339061240: 7 20 9 987 5 715 618
|
||||
35646030: 42 1 885 137 7
|
||||
271367519: 7 45 964 127 96 893
|
||||
495104: 1 960 8 56 64
|
||||
3480: 7 1 12 3 1 40
|
||||
2608290: 91 95 46 3 3 30
|
||||
55890251: 1 65 7 9 4 81 454 3 582
|
||||
541872: 774 7 46 2 27
|
||||
309960637: 8 43 4 90 640
|
||||
14270: 44 8 875 1 9 6 1 8 3 5 5
|
||||
2461824: 1 4 1 9 7 12 61 71 1 4 1 8
|
||||
53575: 6 73 9 7 118 3
|
||||
3128658: 93 9 2 2 20 8 94 331 7
|
||||
223592: 5 43 381 5 9 4 5 884 8
|
||||
12112807054: 870 119 7 61 15 274 4
|
||||
27775914: 6 1 781 1 9 18 4 3 5 889
|
||||
279477744: 33 3 9 411 87 763
|
||||
9896932013: 647 3 331 353 343 46
|
||||
8127207475: 8 1 2 720 3 4 29 9 4 91 3
|
||||
3683665: 981 751 5 5 8
|
||||
7203976: 3 51 7 5 629 3 5 9 9 8 5 4
|
||||
12182439609: 5 57 9 9 9 7 9 8 4 320 3 3
|
||||
6547981: 9 727 2 47 84
|
||||
269451007: 9 262 62 4 992
|
||||
1760418: 99 34 1 5 99 96 4 27 6
|
||||
4881246: 5 3 46 2 4 67 57 8
|
||||
104401: 68 69 8 72 1
|
||||
57612060: 6 270 53 61 11
|
||||
65336211: 92 71 912 169 540 1
|
||||
1056886344323: 8 990 3 9 1 6 18 695 64
|
||||
431112: 3 19 108 92 69
|
||||
1497953467: 1 640 5 8 6 9 38 65
|
||||
20122455: 24 76 903 9
|
||||
112719469: 32 80 7 13 6 456 4 6
|
||||
1178483161: 18 8 6 29 75 754 4 3 4
|
||||
119908723232: 48 39 7 5 3 73 8 64 30
|
||||
21106565: 350 1 37 4 966 2 1 7 2 2
|
||||
70193: 4 53 9 2 7 701 59 746 4
|
||||
3034: 21 45 68 816 3
|
||||
3005: 2 89 24 92 7 58
|
||||
81430304: 124 4 989 2 83
|
||||
22260548: 7 15 212 54 7
|
||||
494808: 87 6 665 6 8
|
||||
6723: 4 81 13 457 13
|
||||
463069864051: 995 8 4 91 7 465 10
|
||||
913887: 3 6 7 2 752 9 5 1 36 5 2 1
|
||||
824408862: 82 43 9 86 8 94 6 5
|
||||
3431928092169: 5 3 67 76 755 15 362 6
|
||||
502132176: 9 109 624 964 702
|
||||
83412526: 1 4 7 2 27 405 3 1 721 8
|
||||
407094: 27 7 60 433 7 5
|
||||
701412: 2 5 84 648 97 836 8
|
||||
25707842242: 311 3 2 3 711 8 8 2 2 42
|
||||
505119: 1 44 41 7 40
|
||||
295936440: 9 27 963 89 272 4 38
|
||||
59813: 595 97 657 457 984
|
||||
297534: 348 61 1 1 2 7 296 46
|
||||
143500: 618 32 8 31 19 1 82 7
|
||||
138312966147: 5 29 5 3 2 2 7 50 4 8 96 2
|
||||
311740: 5 76 5 37 1 1 597 3 20
|
||||
4908292: 9 785 31 59 5
|
||||
6141663: 204 7 25 3 5 1 7 2 9 6 2 2
|
||||
746258: 1 3 61 6 48 21 4 11 81 5
|
||||
310680: 6 7 59 782 9 45 8
|
||||
170615594: 447 3 7 74 35 7 7 6 6 6 2
|
||||
160656040: 75 78 105 603 7
|
||||
5577322182: 47 49 942 2 24 5 7 1 2 7
|
||||
48328: 3 7 4 7 9 149 9 456 7 3 7
|
||||
155259452737: 56 746 874 2 8 342
|
||||
35341: 5 76 93 1
|
||||
22236341: 3 381 88 641 5 1
|
||||
44989863673: 96 6 5 6 71 2 3 381 7 3 3
|
||||
606: 4 80 50 4 70
|
||||
12733: 65 9 2 86 5
|
||||
22463298: 24 88 3 5 80 1 4 89 8
|
||||
377019478: 6 748 5 1 3 4 1 9 7 2 3 8
|
||||
19642752: 696 5 7 544 51
|
||||
702511961: 887 792 1 7 961
|
||||
6024648: 8 86 75 47 168
|
||||
104509650: 5 1 482 62 72 597 7 70
|
||||
1135227: 2 218 25 27 45 5 5
|
||||
224: 2 4 6 2 86 100
|
||||
173902: 99 277 462 89 4 99
|
||||
823929: 9 9 8 5 929
|
||||
25781529: 60 9 8 4 7 65 9 2 4 213 9
|
||||
15984006: 38 6 5 9 727 7 6 4 96 1 5
|
||||
911: 7 6 1 868 1
|
||||
1319338035: 7 6 1 7 6 438 1 448 5 87
|
||||
281978: 561 4 9 5 5 56 1 4 1 9 5 3
|
||||
26739745316256: 3 772 8 21 75 45 5 75 5
|
||||
804636: 50 6 26 542 927
|
||||
4368: 9 87 1 8 42
|
||||
1339970241787: 2 6 8 17 4 82 9 29 4 95 2
|
||||
27896197888: 8 8 849 619 66 521
|
||||
1624907806241: 9 270 3 9 649 18 9 44 1
|
||||
804053256: 531 30 7 9 25 91 6
|
||||
19887: 394 48 682 27 264
|
||||
576579196: 34 7 5 75 6 8 1 5 5 5 91 9
|
||||
4075638918: 886 5 23 97 1 5 4 7 48
|
||||
1242184922: 7 4 5 7 88 9 393 4 925
|
||||
816: 5 2 5 6 45 6
|
||||
16640: 34 60 177
|
||||
55047199922: 5 674 9 97 58 8 985 7 1
|
||||
202: 1 57 3 8 1 4 28 2
|
||||
128584480: 34 6 835 650 94 8
|
||||
14447: 166 3 28 420 83
|
||||
302594: 5 6 2 511 83
|
||||
100153: 4 389 35 70 60 43 450
|
||||
2185551: 38 3 43 19 3
|
||||
6746: 4 6 583 93 784 39
|
||||
3486469538: 8 47 3 40 786 7 9 1 19
|
||||
2105210: 7 4 8 2 6 9 8 31 7 56 3 2
|
||||
47524069: 6 4 610 811 106 4 85 8
|
||||
24206: 25 599 13 2 19
|
||||
83444222: 309 3 9 96 1 8 38 21
|
||||
1157600: 383 930 42 92 800
|
||||
135424: 274 494 29 6 33
|
||||
41759168088: 63 4 91 3 77 2 33 9 94
|
||||
912: 6 1 9 58 1 838
|
||||
1483426560: 4 6 1 69 801 406 692 6
|
||||
1291767304: 41 475 889 4 88 65 8
|
||||
4740630: 941 32 56 2 87
|
||||
145255683: 6 928 2 270 96 3 3
|
||||
2804256: 2 563 36 41 6 91 8
|
||||
3662: 592 6 91 11 8
|
||||
2070609492: 9 460 7 1 66 352 9 8 5
|
||||
58896: 73 2 5 17 5 15 8
|
||||
161664199: 5 9 8 9 746 32 2 1 9 8
|
||||
28767133: 6 69 10 43 37 96
|
||||
321150750: 6 3 33 7 6 191 1 74 355
|
||||
32221373185: 931 4 3 78 56 33 8
|
||||
125188150: 1 84 8 299 7 6 3 623 38
|
||||
529: 1 2 63 54 350
|
||||
371329981: 53 730 8 78 760 4 57 1
|
||||
8636010413: 34 6 1 516 8 4 4 82 1 1 1
|
||||
16436: 8 8 36 7 70
|
||||
2610384: 6 74 93 329 8 42
|
||||
2511598: 21 497 80 7 10 12 5
|
||||
2051303: 68 6 53 523 6 91
|
||||
3583491: 58 3 3 8 852 79 4 5 5 46
|
||||
2567: 5 3 32 4 3
|
||||
37412197: 63 94 238 46 197
|
||||
660996: 61 61 7 43 18
|
||||
772595115: 1 7 2 25 4 2 314 72 5 8 6
|
||||
1125072: 6 82 64 2 3 7 444 2 3 48
|
||||
40030036: 9 68 7 66 646
|
||||
26483808: 5 6 9 862 16 33 96
|
||||
89503594: 2 91 80 112 72 61
|
||||
34849136: 7 14 6 1 9 857 68 88
|
||||
1052469452651: 5 94 9 5 5 5 9 870 8 8 3 8
|
||||
2333026: 2 9 1 8 36 9 5 5 75 1 7 9
|
||||
2142047: 55 2 6 1 60 3 9 40 6 5
|
||||
18329059: 1 7 398 2 523 11 1
|
||||
1515: 1 5 216 3 1 214
|
||||
636751072: 65 7 58 3 967 7 759 9 4
|
||||
65121: 3 648 21
|
||||
1203384: 855 2 9 12 7
|
||||
1231: 567 1 29 21 1 612
|
||||
5830477499: 416 2 925 357 7
|
||||
39904736: 2 2 987 58 51 2 1 8
|
||||
7192: 4 881 3 11 8
|
||||
984797352: 86 84 99 3 1 459
|
||||
4330380: 444 3 8 3 797 7 6 9 1 5 6
|
||||
174675: 8 41 206 75 824 530
|
||||
644000: 2 4 89 4 17 7 92 14 1 4
|
||||
275310: 6 11 31 58 888 4 2 9 2
|
||||
2980025: 29 72 7 96 4 61
|
||||
1100140: 3 8 9 91 3 9 466 5 6 8 3 9
|
||||
26416153: 5 3 64 9 4 764 7 7 5 4 6 7
|
||||
392307: 644 22 589 2 30
|
||||
1703108: 23 789 9 532 7 8
|
||||
84496967641: 9 8 7 71 696 158 605 9
|
||||
4926: 5 47 3 5 2 6 60
|
||||
1238: 7 20 5 8 75
|
||||
4166368: 4 8 393 74 22 7
|
||||
264286: 5 5 2 6 11 26 80 115 8 6
|
||||
5390070: 38 5 77 813 35 3 54 8 6
|
||||
7109213251: 798 2 5 88 89 50
|
||||
11479038526: 245 1 5 7 333 456 3 7 9
|
||||
35577532: 71 155 500 25 5
|
||||
516: 7 4 6 4 1 70 9 66 1 5 39 2
|
||||
12159: 9 6 1 225 9
|
||||
593081: 1 92 6 4 343 2 6 8 3 41
|
||||
52698: 89 592 7
|
||||
36739952992513: 9 4 779 4 627 92 4 8 3 7
|
||||
2006: 22 8 90 75 5 8
|
||||
83601: 68 30 8 5 1 56 3 1 3 7
|
||||
478266: 1 4 8 6 3 724 612 8 286
|
||||
297000: 49 50 820 9 90 6 88
|
||||
1229910807: 262 102 46 6 600 807
|
||||
185356128: 44 5 401 7 82 115 48
|
||||
246521: 787 6 4 6 307
|
||||
86285202: 25 96 42 856 402
|
||||
23586: 70 1 3 52 9 5
|
||||
18086584: 46 6 144 8 27 534 7
|
||||
33690: 4 69 4 56 89
|
||||
46311716: 12 3 41 18 619 6
|
||||
214023: 5 793 66 7 53 9
|
||||
6755: 270 2 799 12 5
|
||||
14223284: 9 9 7 5 7 8 2 111 1 45 4 8
|
||||
2291081: 3 2 632 725 81
|
||||
284789717303: 605 3 9 3 960 30 47 49
|
||||
17262: 105 4 3 1 3 9 3 240 2 7 1
|
||||
157051: 9 7 6 181 6 9 3 3 451 81
|
||||
1349805670: 59 4 874 26 71
|
||||
2361910101: 5 623 7 3 38 6 8 1 3 1 8 2
|
||||
45459840: 8 42 71 1 3 8 4 9 8 9 384
|
||||
644841302: 7 658 2 70 62 68 2
|
||||
196349: 69 6 192 81 2 4
|
||||
25233495: 14 6 1 3 34 83 14
|
||||
2502364627: 9 73 7 1 76 4 7 95 8 5 27
|
||||
891841251: 79 62 560 2 63 6 51
|
||||
526: 95 9 4 1 417
|
||||
46610701: 46 605 5 697 4
|
||||
101160: 5 5 6 5 9 4 873 8 4 3 3 63
|
||||
74700: 86 2 765 47 83
|
||||
487499: 9 52 6 6 85 502
|
||||
12930315: 4 77 3 9 48 9 1 5
|
||||
818480: 3 4 8 966 10 3 7 1 4 5 4 1
|
||||
8956575: 6 8 827 5 676 864 35
|
||||
6467920693: 5 8 5 48 652 1 8 8 1 3 8 5
|
||||
877: 71 10 689 32 75
|
||||
53325209060: 554 965 941 2 53
|
||||
23291024284082: 9 42 193 47 6 9 515 48
|
||||
929424926: 3 6 29 42 492 5
|
||||
17829266: 6 56 4 53 63
|
||||
12276: 2 5 55 3 66
|
||||
181712606: 595 74 75 412 6
|
||||
8831966: 2 56 30 2 2 39 65 2 9 8 7
|
||||
661454663997: 231 3 453 350 8 10 78
|
||||
237094: 3 3 311 50 646 12
|
||||
5707220457: 71 82 86 966 4 920 55
|
||||
152255376595: 76 17 40 820 65 163
|
||||
1347305: 9 4 8 65 664 3 4 3 701 9
|
||||
70155: 91 2 88 257 706 58 1
|
||||
60468016: 640 1 23 5 27 726 812
|
||||
408075824: 40 74 6 758 22
|
||||
149767280436: 1 221 860 788 436
|
||||
1581985302: 83 9 258 3 8 38 72 3 6
|
||||
157694208: 94 8 52 3 5 15 56 1 3 8
|
||||
3814512: 5 6 4 8 8 5 6 5 5 37 9
|
||||
4548610: 66 9 3 3 7 57 50 1 9
|
||||
21119484: 38 822 28 29 876
|
||||
5946398: 661 589 67 71 91 57
|
||||
151648362: 894 75 5 9 93 54 317
|
||||
10321152: 99 807 712 2 8
|
||||
114489: 6 5 4 8 31 84 37 9
|
||||
145909: 75 70 909
|
||||
106820010: 722 269 10 2 55
|
||||
1480075: 44 2 198 9 3 71 691 6 7
|
||||
28827: 19 1 5 7 6 9 78 1 8 849 3
|
||||
7566: 7 244 8 141 62 23 5 83
|
||||
5508361: 495 4 214 13 1
|
||||
4988516: 5 33 55 12 568 66 2 97
|
||||
184373: 1 9 7 9 5 1 1 33 9 11 20
|
||||
199283931852: 3 5 8 4 158 6 3 539 855
|
||||
1666857472580: 77 654 23 180 331
|
||||
14487733: 557 891 68 9 9 5 828
|
||||
1198391800: 231 965 8 84 2 93 1 4 2
|
||||
126143604: 86 2 6 463 88 55 5 3
|
||||
153392452209: 6 482 7 3 939 11 5 4 9 7
|
||||
12681: 5 7 2 9 4 7 44 2 5 65 4 9
|
||||
989: 1 9 99
|
||||
93840: 98 38 46 15
|
||||
217780: 419 3 516 23 5
|
||||
33264: 447 87 973 5 22
|
||||
7178025: 995 9 5 2 87 7 527 20 5
|
||||
9028: 3 83 7 5 3
|
||||
12935: 711 5 6 3 47
|
||||
3659499181: 365 925 6 229 9 5 181
|
||||
701521: 9 4 3 64 7 61 8 26 67 53
|
||||
340704429: 52 78 84 319 7 7 99
|
||||
62241150: 7 176 842 8 77 6
|
||||
112424: 5 1 8 936 82 8 183 92
|
||||
723672: 347 67 1 2 874
|
||||
3066: 51 5 8 8 8 898
|
||||
1274880: 23 52 542 9 87
|
||||
2517506958: 37 68 780 726 9 59
|
||||
110283391: 3 52 3 53 8 3 8 6 3 903 1
|
||||
4536: 83 5 81 9 747 2
|
||||
87466: 19 46 6 3
|
||||
605783111392: 404 91 601 37 741 4
|
||||
58853775: 4 485 79 4 384 399
|
||||
47889063: 516 64 89 984 999 29
|
||||
23241016: 7 3 5 5 6 1 3 819 27 9 9 1
|
||||
27260572330: 9 9 7 9 28 57 2 3 8 2 5 5
|
||||
233756964: 61 958 6 5 1 5 26 8 314
|
||||
781268: 376 6 743 4 692 1
|
||||
69945120: 7 4 539 5 113 5 6 4 7 73
|
||||
267715242: 92 8 663 9 4 3 632 3 1 2
|
||||
1896465174: 976 920 1 4 651 72
|
||||
2800123: 203 8 17 9 384 23
|
||||
206464: 3 7 3 186 1
|
||||
127766017: 74 12 9 35 714 1 24 1
|
||||
24: 7 5 1 9 3
|
||||
10510918116: 59 46 109 181 15
|
||||
3621981: 2 248 954 2 1 3 9 78
|
||||
7258534: 70 96 523 840 898
|
||||
12932425: 928 6 43 57 8 54 1 3 9 7
|
||||
40426441: 6 8 7 7 3 8 1 2 1 18 509 9
|
||||
258400: 70 120 34 40
|
||||
895: 81 303 38 2 51
|
||||
80809920: 932 69 727 47 995
|
||||
21779938: 9 411 92 64 226
|
||||
1613: 4 401 4 7
|
||||
43158803498: 36 222 9 7 26 39 6 9 9 1
|
||||
4366703135: 57 7 93 7 2 70 982 8 6
|
||||
167694750: 9 89 350 76 598
|
||||
1913663802: 64 299 63 6 2 10 2
|
||||
1444191: 556 9 11 4 6 5 1 41 83 7
|
||||
1003880435: 19 82 746 977 863
|
||||
4155: 72 810 13 4 575
|
||||
96614034: 15 6 361 72 6 2 3 6 59
|
||||
1688: 5 9 1 5 3 8 8
|
||||
41338714328: 41 338 639 75 328
|
||||
9197318140: 2 59 6 1 690 8 1 5 227 4
|
||||
46479360: 61 7 4 2 9 7 39 272 6 5 8
|
||||
404048233: 951 7 8 576 2 4 235
|
||||
11494468882: 3 187 5 9 1 3 24 2 6 7 5 7
|
||||
1922: 6 233 457 6 61
|
||||
6955: 9 7 8 4 5 7 4 2 4 5 202 5
|
||||
31285182: 23 136 506 7 63 52
|
||||
8117862: 437 1 6 921 2 381 46 6
|
||||
47589: 9 94 374 39 7
|
||||
2256037: 60 376 39
|
||||
2527024499: 4 3 1 7 8 10 3 1 6 51 91
|
||||
37690: 3 720 52 6 1 88 1
|
||||
4175256007: 4 8 5 39 20 2 34 2 23
|
||||
380247474471: 2 4 2 45 497 88 5 7 2 7 1
|
||||
21474: 9 9 9 1 17 4 784 8 4 39 9
|
||||
3277745: 18 2 5 4 414 89 271
|
||||
20611117618: 3 3 2 4 8 1 4 9 39 76 19
|
||||
6706090709: 799 2 3 1 8 9 8 4 7 872
|
||||
5792: 618 29 68 8 3 69
|
||||
410827821: 4 927 73 453 16 409
|
||||
233173828: 3 74 634 6 896 3 4 7 5 6
|
||||
187959: 119 32 2 556 23
|
||||
486043544: 3 230 57 52 54 74 62 7
|
||||
2347696: 4 1 35 40 19 769 8
|
||||
4278588041013: 44 7 29 4 7 456 7 4 684
|
||||
5637600: 58 9 54 25 8
|
||||
4977330: 9 7 6 79 3 9 8 838 3 4 7 6
|
||||
22497: 82 79 983 1 1 3 9 102
|
||||
35382699154: 77 617 2 14 2 46 554
|
||||
16502056: 8 6 58 319 488 5 819
|
||||
756793: 88 3 3 944 192 3 1 72
|
||||
4214: 6 697 1 5 27
|
||||
12450094: 2 2 2 6 3 629 9 857 5 9 4
|
||||
1618088: 76 4 6 1 7 7 62 90 5 1 8
|
||||
1060491: 3 361 14 906 66 1
|
||||
266689086: 3 2 17 83 5 6 8 42 6 5 3 3
|
||||
68560832: 3 1 82 6 8 5 3 308 2 1 2
|
||||
1326: 423 846 4 1 8 44
|
||||
68085: 674 6 78 7
|
||||
1840707: 85 9 62 6 804 4 3
|
||||
13403416: 2 1 3 5 4 65 7 8 7 3 933
|
||||
2093: 56 6 868 26 614 9 8
|
||||
12213922: 73 703 14 1 17
|
||||
224283: 640 7 4 5 8 4
|
||||
97770: 1 214 7 27 1 8 378
|
||||
25990: 6 5 5 87 2 7 767 6 92 4
|
||||
299184551: 325 2 92 544 7
|
||||
63062194: 70 9 605 7 46 123 825
|
||||
68322843482: 28 244 28 434 82
|
||||
37380255: 80 1 935 87 493 4 5
|
||||
305472677: 509 6 7 267 7
|
||||
46: 1 45 2
|
||||
2250: 29 1 75 6 69
|
||||
191773: 19 176 5 8
|
||||
91083792: 4 7 236 878 7 5 6 4 3 1 1
|
||||
335524376: 8 53 51 68 668 158
|
||||
29640281671: 7 8 4 6 3 5 7 44 7 8 8 90
|
||||
497340: 9 3 762 7 3 6 3 5 6
|
||||
279527: 402 67 149 4 1 3
|
||||
279694: 1 935 96 765 97
|
||||
224785469: 2 1 9 5 68 10 2 3 9 3 7 23
|
||||
10732502: 15 5 477 5 60
|
||||
7497250: 8 936 1 9 249
|
||||
56971: 4 76 9 79 91
|
||||
41393070: 2 53 5 781 70
|
||||
12168228431496: 64 3 8 2 161 9 7 831 3
|
||||
117142318737: 3 6 6 9 2 60 436 3 9 6 9 3
|
||||
158260: 9 45 5 4 78
|
||||
2363212870: 2 363 212 4 52 420
|
||||
447325: 463 2 795 355 25
|
||||
4751: 11 48 9
|
||||
841: 81 9 97 2 13
|
||||
3346211520: 3 9 858 11 522
|
||||
697352492: 67 1 4 4 18 3 455 69 9 5
|
||||
7319280640: 61 45 7 709 7 656 80
|
||||
27260: 7 9 344 79 5
|
||||
10737320581: 7 8 5 5 55 7 8 6 294 70
|
||||
17943: 9 839 921 18 6 9 4
|
||||
35412: 6 724 1 9 8 580
|
||||
6453: 161 1 475 81 9
|
||||
840798: 975 287 52 3 647 517
|
||||
17854: 3 32 69 42 7 655
|
||||
1735468803: 3 86 8 5 9 91 68 3 26 80
|
||||
1955340326: 54 8 292 2 54 5 327
|
||||
7614444: 86 7 718 824 7 88 7 19
|
||||
108369902185: 3 9 115 814 7 9 5 7 1 8 6
|
||||
139223: 8 3 53 2 77 38 6 3 2 7 4
|
||||
2142640: 49 43 35 566 72
|
||||
266228026: 3 80 51 8 597 5 62 24
|
||||
68870224: 6 62 870 22 4
|
||||
393281: 5 4 109 9 32 77 2 22 9
|
||||
22257035: 29 25 685 5 6 3 597 3 5
|
||||
1480: 679 67 130 537 9 58
|
||||
11720991: 1 8 23 7 364 5 5 5 59 7
|
||||
156699: 663 9 301 5 5
|
||||
1292069: 17 760 21 42 6
|
||||
83229203: 100 1 4 7 1 808 321 9 2
|
||||
15899250: 986 375 43
|
||||
80808: 40 4 521 212 104
|
||||
10465625002: 9 77 71 47 50 1 425 2
|
||||
819408192: 31 68 991 7 3 87
|
||||
667: 8 8 2 7
|
||||
26860: 200 45 23 56 4
|
||||
49480468: 43 29 90 127
|
||||
5186813940000: 504 967 5 825 5 86 2 3
|
||||
19174057: 6 7 652 7 51 7
|
||||
72691616664: 991 7 733 662 6 38
|
||||
18573243: 343 360 489 9 900 6
|
||||
3883810560: 6 88 2 8 4 438 8 980 6
|
||||
19738: 5 2 508 38 54
|
||||
703764: 13 8 48 495 20 77 23 6
|
||||
273920: 7 629 987 89 8 20
|
||||
911: 7 5 9 4 592
|
||||
33029: 50 644 822 7
|
||||
524702: 7 153 24 79 7 3 95 17
|
||||
109342: 84 130 3 3 2 2 80
|
||||
35742400: 8 1 706 7 51 174 6 6 9 7
|
||||
1483641: 2 64 70 737 153
|
||||
7397: 364 5 8 4 85
|
||||
10622451329: 5 80 3 7 1 4 7 879 3 1 2
|
||||
1513454743: 69 31 8 732 963 91
|
||||
87816030: 47 1 7 80 3 8 1 6 417 1
|
||||
2957777379: 30 265 7 777 379
|
||||
279602: 759 1 23 4 4 274 9 7
|
||||
2793723: 2 10 66 1 6 24 2 723
|
||||
13426560: 36 37 180 8 7
|
||||
72281484: 8 25 758 6 17 9 36
|
||||
15157818475: 26 124 1 5 7 818 475
|
||||
1726473: 857 5 41 9 819 2
|
||||
69102877793: 9 997 2 91 7 17 711 7 5
|
||||
1182849: 2 249 31 38 4 129 8
|
||||
81125766: 7 2 670 17 308 3 789
|
||||
20198: 8 6 3 396 2
|
||||
130416799: 10 27 483 6 7 9 6 4
|
||||
29969: 7 62 38 7 91 5 4 907
|
||||
4071: 3 10 4 7 23
|
||||
3447616557: 858 111 362 9 54
|
||||
31720: 38 59 43 63 4 2
|
||||
10386966: 1 3 8 612 2 96 5 7 8 4 6 3
|
||||
2515969: 2 768 9 906 8
|
||||
2085272: 18 65 114 297 25
|
||||
245966149: 96 3 146 5 6 4 2 2 3 731
|
||||
936628: 57 38 19 887 90 88
|
||||
434515299: 905 64 9 8 56 99
|
||||
7751781085279: 8 7 900 819 9 389 11
|
||||
6523: 4 61 26 151 28
|
||||
507242778: 6 822 69 44 4 459 1 6 7
|
||||
4557: 2 48 3 9 169 3
|
||||
6172533: 37 9 207 43 7 9 7 7 12 9
|
||||
4528512: 7 27 871 689 5 6 63
|
||||
35178: 1 682 81 46 80
|
||||
40198: 67 4 25 6
|
||||
12418780: 54 7 6 8 351 6 164 11
|
||||
37440: 24 9 8 12 870 247 32
|
||||
7303307255: 35 695 324 6 64 8 52
|
||||
42929: 9 124 38 5 516
|
||||
101311: 2 99 31 1 3
|
||||
3786723: 1 685 92 6 3 3
|
||||
757762: 76 997 1 3 38
|
||||
728: 567 6 23 42 90
|
||||
19126995: 593 1 70 65 59 58 458
|
||||
83647: 8 828 47
|
||||
1250549: 24 939 1 71 50
|
||||
9778: 9 173 39 15 5 3 39 262
|
||||
18714: 89 265 5 13 4 43 1 3
|
||||
10446534727248: 61 465 74 62 990 8 6
|
||||
4136: 12 289 668
|
||||
986: 919 65 2
|
||||
382284584: 655 1 7 1 144 578 7 1
|
||||
2087668: 521 7 75 94 48 4
|
||||
13551: 62 69 8 36 9
|
||||
54736659: 504 52 8 38 17 261
|
||||
46609728: 5 9 6 5 78 8 818 9 3 1 5 6
|
||||
8001: 55 7 6 9 7 3
|
||||
2164: 20 62 3 7 8 8 76
|
||||
34288954: 174 227 512 141 854
|
||||
149143039: 568 157 839 4 4 8 745
|
||||
858002: 715 600 1 2 2
|
||||
355275: 3 550 5 22 6
|
||||
1161901609: 9 3 7 1 9 5 8 2 99 9 492 4
|
||||
14265505: 7 4 77 237 684
|
||||
93906: 1 23 457 4 78
|
||||
280258704: 396 16 217 528 81
|
||||
2447: 237 9 217 9 88
|
||||
21103892: 688 2 139 4 3 64 55 7
|
||||
572320: 571 889 7 8 7
|
||||
22940: 74 1 31 10
|
||||
453933144: 884 1 7 2 8 75 164 94 9
|
||||
9387402762: 447 7 134 3 70 3 57 2
|
||||
628: 2 96 5 6 10
|
||||
58729373: 53 4 53 29 373
|
||||
16162243: 2 3 90 75 92 139 927
|
||||
1806271: 4 319 283 5 13 718
|
||||
1908: 72 26 16 8 9
|
||||
87108518916: 8 349 61 129 729 4
|
||||
1120226562: 81 8 1 54 7 89 8 5 2 32
|
||||
5619463232: 7 860 2 3 9 3 24 29
|
||||
28275666: 4 35 65 440 227
|
||||
57418552: 8 96 4 18 9 6 4 142
|
||||
337848089754: 893 778 54 82 7 9 5
|
||||
101244761: 2 8 4 1 222 8 1 631 6 4 5
|
||||
31091: 2 94 6 323 9 4 4 53 8 3
|
||||
9551142: 2 7 4 4 92 9 87 2 54
|
||||
431798: 2 827 32 904 554 96
|
||||
368064: 62 5 31 10 568 6
|
||||
641856: 80 23 1 2 8
|
||||
356332: 848 13 8 38 853 4
|
||||
1530148: 107 13 11 13 33
|
||||
10595: 4 93 3 71 524
|
||||
13825: 37 88 128 73 4
|
||||
485809: 9 597 19 6 996 5
|
||||
6598799: 541 2 674 617 6 5 3 1 1
|
||||
15595884486: 6 36 560 69 8 961
|
||||
655845: 5 5 2 512 8 298 7 115
|
||||
167578404: 716 3 162 9 916 19
|
||||
539849: 3 7 1 594 25
|
||||
3430232: 9 15 29 9 2 700 7 56 4 8
|
||||
4196: 951 77 9 8 4 4
|
||||
24625387: 9 6 8 6 9 37 846 38 3 8 8
|
||||
4318272002: 10 7 2 3 80 6 5 2 7 306 2
|
||||
49392736: 80 63 4 72 34 2 944 2
|
||||
97244751876: 3 45 6 3 7 293 8 5 9 2 3 1
|
||||
2827209446: 384 6 35 4 9 6 7 3 441 5
|
||||
773376516: 7 73 37 651 5
|
||||
466781: 21 76 5 364 782
|
||||
314242938: 77 30 223 22 610 218
|
||||
654638167: 14 95 6 631 7 169
|
||||
11952: 76 23 69 7 50 439 18
|
||||
7579925: 860 37 435 47 5
|
||||
1618: 80 4 7 711 59
|
||||
33287: 1 822 40 354 48 2 3
|
||||
126232779: 6 3 841 9 5 4 77 8 34 9 3
|
||||
155627: 1 6 99 989 54 95 13 99
|
||||
713339897: 9 7 5 8 9 30 430
|
||||
131670050047: 231 19 75 12 5 1 4 8
|
||||
7727322: 2 795 9 753 513
|
||||
349733: 615 8 637 271 4 6 28
|
||||
2481710424: 1 58 9 49 1 3 96 5 9 3 8 3
|
||||
261963659: 9 7 4 7 2 308 655 650 9
|
||||
51571974: 7 5 579 7 848 1 1 3
|
||||
20290: 3 85 3 467 36 1 1 6 196
|
||||
2626: 2 6 96 545 2
|
||||
22878: 2 2 80 275 4 21 3 9
|
||||
575535: 54 4 14 18 10 8 73 6 3
|
||||
477517: 43 3 4 5 8 46 7 50
|
||||
1384703: 4 401 6 7 738 51
|
||||
891003337: 86 6 12 4 825 3 3 39
|
||||
90028742465: 608 3 1 37 4 3 4 2 4 6 2 1
|
||||
231588050: 35 3 1 586 1 2 8 1 3 65 5
|
||||
1072: 7 9 995 9 5
|
||||
11381395: 73 4 974 2 36 2 435 7
|
||||
3841: 847 4 87 358 8
|
||||
88734868: 3 6 9 8 9 2 7 5 4 838 725
|
||||
280240227: 2 981 23 1 48 94
|
||||
343965: 6 35 67 885 23
|
||||
14417393: 9 4 7 2 63 6 38 35 90
|
||||
227912: 8 183 31 19 3 72 9 8 1
|
||||
2511501082: 1 946 88 2 430 3 7 6 2 4
|
||||
9770975: 2 207 7 58 9 4 36 33 5
|
||||
181098129983: 36 3 6 1 3 399 7 9 8 1 8 6
|
||||
5511886: 749 92 63 2 9 4 104 94
|
||||
11912: 3 167 581 43 15
|
||||
54194003: 24 5 7 50 632
|
||||
40135618285: 5 5 5 4 8 7 7 38 182 8 3 5
|
||||
8817032: 460 2 2 6 4 4 7 2 57 728
|
||||
236071: 566 414 610 196 941
|
||||
1699: 874 26 799
|
||||
9082: 59 85 7 9 10
|
||||
14399715: 7 6 5 84 32 1 9 9 8 756 7
|
||||
957922: 5 76 282 265 853
|
||||
519850: 854 1 1 608 8
|
||||
494598: 8 8 8 9 1 2 4 1 3 4 17 78
|
||||
717301: 769 92 138 844 1
|
||||
79732051: 8 1 7 80 45 5 221 629 8
|
||||
193315: 5 329 577 536 60
|
||||
443120: 71 7 62 5 764 4
|
||||
799531202: 320 693 332 72 50 2
|
||||
25055194: 241 48 900 7 194
|
||||
148742749564: 341 93 73 435 240 65
|
||||
2975722: 802 811 6 919 2
|
||||
69614316: 3 9 65 34 9 9 6 3 1 96 59
|
||||
9211672: 92 116 51 20
|
||||
1384: 5 687 2
|
||||
2227754259: 312 1 75 78 952
|
||||
1980: 6 46 5 70 6
|
||||
1051: 74 41 921 7 8
|
||||
7224: 69 9 6 405 7
|
||||
100058717: 58 44 628 7 145 31 9 8
|
||||
13325842: 86 4 981 7 534 49 5 9
|
||||
135606016: 86 1 1 7 2 4 8 877 96 8
|
||||
188416: 4 8 735 32 8
|
||||
13081748: 306 58 2 737
|
||||
3408461: 654 396 4 34 348 94 9
|
||||
19518: 2 1 8 9 1 54 9 25 9 616 2
|
||||
31719: 65 6 9 78 597
|
||||
246572: 26 98 9 4 393 9 81 2 8
|
||||
127805458: 40 71 9 1 5 457
|
||||
7811: 198 16 5 7 31 1 4 794 6
|
||||
1168319105: 5 2 1 2 4 44 8 93 9 12 8 8
|
||||
7211685: 411 5 7 562 8 554 93 5
|
||||
4028985022: 77 86 48 505 604
|
||||
127755655140: 73 70 5 3 8 31 5 140
|
||||
208269903: 3 75 267 990 3
|
||||
956027222: 455 20 5 10 4 3 5 7
|
||||
332644: 63 1 8 660 4
|
||||
739903: 8 744 1 67 3 630 9 1 5
|
||||
449841: 8 6 3 1 9 9 4 9 608 73 88
|
||||
3162: 88 4 6 9 7 3 53 7 9 17
|
||||
123780: 961 528 514 51 9 60
|
||||
397: 88 299 1 1 9
|
||||
20327221321: 10 40 83 98 1 460 7 6
|
||||
22759444: 366 7 6 3 241 6
|
||||
1397068088398: 419 2 5 161 5 6 4 414 1
|
||||
5172: 6 431 2
|
||||
7637: 251 9 85 746 7
|
||||
1812: 908 35 789 3 77
|
||||
1120: 7 9 1 68 9 2 4
|
||||
770138283: 11 6 57 1 3 8 947 9 1 3 3
|
||||
163644: 610 32 344 63 156
|
||||
6168: 137 5 9
|
||||
507: 41 9 2 76 60
|
||||
593693: 77 77 16 765 9
|
||||
1214074355: 9 4 5 3 9 73 5 7 8 4 855 8
|
||||
607244471: 6 3 7 3 1 83 2 510 2 4 6 8
|
||||
275: 26 2 9 2 2
|
||||
250040507: 24 9 455 585 504
|
||||
5137920095731: 44 7 438 78 3 23 573 2
|
||||
282926819: 6 4 827 26 812 42 3 32
|
||||
80952: 37 2 6 948 2
|
||||
8890436: 635 2 7 43 8
|
||||
10600: 2 1 8 8 6 6 8 3 91 541 6 5
|
||||
23840: 5 86 1 9 4 1 7 511 57 5
|
||||
283368: 3 8 8 322 8
|
||||
1123947090: 49 3 877 8 1 323 9 342
|
||||
25775616: 8 8 6 97 692
|
||||
243687944: 650 5 815 32 92
|
||||
2855764: 2 1 912 730 1
|
||||
2736185924: 835 66 2 53 8 3 31 3 2 2
|
||||
80
2024/gareth/day08/day08.go
Normal file
80
2024/gareth/day08/day08.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Coordinate struct {
|
||||
Row int
|
||||
Col int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
grid, antennaMap := parseInput(input)
|
||||
result := findAntinodes(grid, antennaMap, true)
|
||||
return result
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid, antennaMap := parseInput(input)
|
||||
result := findAntinodes(grid, antennaMap, false)
|
||||
return result
|
||||
}
|
||||
|
||||
func parseInput(input string) ([][]rune, map[rune][]Coordinate) {
|
||||
lines := strings.Split(input, "\n")
|
||||
rowCount := len(lines)
|
||||
colCount := len(lines[0])
|
||||
grid := make([][]rune, rowCount)
|
||||
antennaMap := make(map[rune][]Coordinate)
|
||||
|
||||
for row := 0; row < rowCount; row++ {
|
||||
grid[row] = []rune(lines[row])
|
||||
for col := 0; col < colCount; col++ {
|
||||
frequency := grid[row][col]
|
||||
if frequency != '.' {
|
||||
antennaMap[frequency] = append(antennaMap[frequency], Coordinate{Row: row, Col: col})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return grid, antennaMap
|
||||
}
|
||||
|
||||
func findAntinodes(grid [][]rune, antennaMap map[rune][]Coordinate, onlySpecial bool) int {
|
||||
rowCount := len(grid)
|
||||
colCount := len(grid[0])
|
||||
uniqueAntinodes := make(map[Coordinate]struct{})
|
||||
|
||||
for row := 0; row < rowCount; row++ {
|
||||
for col := 0; col < colCount; col++ {
|
||||
for _, antennaPositions := range antennaMap {
|
||||
for i, firstAntenna := range antennaPositions {
|
||||
for j, secondAntenna := range antennaPositions {
|
||||
//I know I know thats too many for loops
|
||||
if i != j {
|
||||
distance1 := int(math.Abs(float64(row-firstAntenna.Row)) + math.Abs(float64(col-firstAntenna.Col)))
|
||||
distance2 := int(math.Abs(float64(row-secondAntenna.Row)) + math.Abs(float64(col-secondAntenna.Col)))
|
||||
|
||||
rowDiff1 := row - firstAntenna.Row
|
||||
rowDiff2 := row - secondAntenna.Row
|
||||
colDiff1 := col - firstAntenna.Col
|
||||
colDiff2 := col - secondAntenna.Col
|
||||
|
||||
if rowDiff1*colDiff2 == rowDiff2*colDiff1 {
|
||||
if (distance1 == 2*distance2 || distance1*2 == distance2) && onlySpecial {
|
||||
uniqueAntinodes[Coordinate{Row: row, Col: col}] = struct{}{}
|
||||
} else if !onlySpecial {
|
||||
uniqueAntinodes[Coordinate{Row: row, Col: col}] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return len(uniqueAntinodes)
|
||||
}
|
||||
39
2024/gareth/day08/day08_test.go
Normal file
39
2024/gareth/day08/day08_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package day08
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`............
|
||||
........0...
|
||||
.....0......
|
||||
.......0....
|
||||
....0.......
|
||||
......A.....
|
||||
............
|
||||
............
|
||||
........A...
|
||||
.........A..
|
||||
............
|
||||
............`)
|
||||
assert.Equal(t, 14, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`............
|
||||
........0...
|
||||
.....0......
|
||||
.......0....
|
||||
....0.......
|
||||
......A.....
|
||||
............
|
||||
............
|
||||
........A...
|
||||
.........A..
|
||||
............
|
||||
............`)
|
||||
assert.Equal(t, 11387, r)
|
||||
}
|
||||
50
2024/gareth/day08/input.txt
Normal file
50
2024/gareth/day08/input.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
........................E...j......W..........L...
|
||||
............................O........E.........L..
|
||||
..q......O...........l....................K.......
|
||||
............q...................HM......W.........
|
||||
................................1..H...........IW.
|
||||
....................5.............................
|
||||
..........k........M...wl............6............
|
||||
.....O.......w...k.....5.8..l......K.........o.6..
|
||||
.......k....w.........5.........R.....o........K..
|
||||
.....q..X..............j........E...I.........K...
|
||||
............O..........E........................H.
|
||||
................Mn.h2.w.p....................H....
|
||||
..................p.......a............j.....L....
|
||||
.....X...l.p.....................m.........W..6...
|
||||
..Xq................A..................R..m.......
|
||||
.........................i..........a..........R..
|
||||
...........u.....................a........I.....2.
|
||||
k..............A..n.........R.................o...
|
||||
................n.................Qo..............
|
||||
..........u.A.........h........2..................
|
||||
...5.......Y.....p...............iN...............
|
||||
1...x.....................i.......................
|
||||
........M..............2.....Qi...................
|
||||
...............................I..e...............
|
||||
......u......A...........m..........h.............
|
||||
.......1...........U.............Qm.......j.......
|
||||
.......X.......................................9..
|
||||
.....u........U.......Y...........................
|
||||
.............................h.e..................
|
||||
..................4....e......Q.....L....N........
|
||||
.1..................4.......................y8....
|
||||
.........Y................................8.N.....
|
||||
............P.0J...........3..........8y..........
|
||||
....V3P..........J................................
|
||||
............U..P...7x...........e.................
|
||||
....................J...............r...9.........
|
||||
.........0.V......Y...............................
|
||||
...............V.4................................
|
||||
..........V..........................n............
|
||||
..............v........7..........................
|
||||
...........U..........J.......7...................
|
||||
.....v........7..........................a........
|
||||
.......................................r..........
|
||||
...........0.......x................y.............
|
||||
............6..v.x.....................N..........
|
||||
...........P......................................
|
||||
........3.......................r......4..........
|
||||
..............3......................y............
|
||||
................................................9.
|
||||
.................................................9
|
||||
104
2024/gareth/day09/day09.go
Normal file
104
2024/gareth/day09/day09.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package day09
|
||||
|
||||
func Part1(input string) int {
|
||||
files, gaps, lengthOfFinalFile := parseInput(input)
|
||||
checksum := compactFiles(files, gaps, lengthOfFinalFile)
|
||||
return checksum
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
files, freeSpaces := parseInputPart2(input)
|
||||
checksum := calculateChecksum(files, freeSpaces)
|
||||
return checksum
|
||||
}
|
||||
|
||||
func parseInput(input string) ([]int, []int, int) {
|
||||
var files []int
|
||||
var gaps []int
|
||||
lengthOfFinalFile := 0
|
||||
for i, char := range input {
|
||||
if i%2 == 0 {
|
||||
files = append(files, int(char-'0'))
|
||||
lengthOfFinalFile += int(char - '0')
|
||||
} else {
|
||||
gaps = append(gaps, int(char-'0'))
|
||||
}
|
||||
}
|
||||
return files, gaps, lengthOfFinalFile
|
||||
}
|
||||
|
||||
func parseInputPart2(input string) ([][]int, [][]int) {
|
||||
files, freeSpaces, position := [][]int{}, [][]int{}, 0
|
||||
for index, char := range input {
|
||||
length := int(char - '0')
|
||||
if index%2 == 0 {
|
||||
files = append(files, generateRange(position, position+length))
|
||||
} else {
|
||||
freeSpaces = append(freeSpaces, generateRange(position, position+length))
|
||||
}
|
||||
position += length
|
||||
}
|
||||
return files, freeSpaces
|
||||
}
|
||||
|
||||
func compactFiles(files []int, gaps []int, lengthOfFinalFile int) int {
|
||||
fileIndex := len(files) - 1
|
||||
gapIndex := 0
|
||||
position := files[0]
|
||||
checksum := 0
|
||||
fileID := files[0]
|
||||
|
||||
for lengthOfFinalFile != position {
|
||||
// If there's a gap and a file to move then move the file
|
||||
if gaps[gapIndex] > 0 && files[fileIndex] > 0 {
|
||||
files[fileIndex]--
|
||||
gaps[gapIndex]--
|
||||
checksum += fileIndex * position
|
||||
position++
|
||||
}
|
||||
|
||||
// If this file is fully moved go to next file
|
||||
if files[fileIndex] == 0 {
|
||||
fileIndex--
|
||||
fileID++
|
||||
}
|
||||
|
||||
// Update gapIndex if this gap is filled
|
||||
if gaps[gapIndex] == 0 {
|
||||
gapIndex++
|
||||
for f := 0; f < files[gapIndex]; f++ {
|
||||
checksum += gapIndex * position
|
||||
position++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return checksum
|
||||
}
|
||||
|
||||
func generateRange(start, end int) []int {
|
||||
rangeList := make([]int, end-start)
|
||||
for i := range rangeList {
|
||||
rangeList[i] = start + i
|
||||
}
|
||||
return rangeList
|
||||
}
|
||||
|
||||
func calculateChecksum(files, freeSpaces [][]int) int {
|
||||
checksum := 0
|
||||
for fileIndex := len(files) - 1; fileIndex >= 0; fileIndex-- {
|
||||
for spaceIndex := 0; spaceIndex < len(freeSpaces); spaceIndex++ {
|
||||
if len(freeSpaces[spaceIndex]) >= len(files[fileIndex]) && files[fileIndex][0] > freeSpaces[spaceIndex][0] {
|
||||
files[fileIndex] = freeSpaces[spaceIndex][:len(files[fileIndex])]
|
||||
freeSpaces[spaceIndex] = freeSpaces[spaceIndex][len(files[fileIndex]):]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for fileID, file := range files {
|
||||
for _, block := range file {
|
||||
checksum += fileID * block
|
||||
}
|
||||
}
|
||||
return checksum
|
||||
}
|
||||
22
2024/gareth/day09/day09_test.go
Normal file
22
2024/gareth/day09/day09_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package day09
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`12345`)
|
||||
assert.Equal(t, 60, r)
|
||||
}
|
||||
|
||||
func TestPart1Long(t *testing.T) {
|
||||
r := Part1(`2333133121414131402`)
|
||||
assert.Equal(t, 1928, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`2333133121414131402`)
|
||||
assert.Equal(t, 2858, r)
|
||||
}
|
||||
1
2024/gareth/day09/input.txt
Normal file
1
2024/gareth/day09/input.txt
Normal file
File diff suppressed because one or more lines are too long
141
2024/gareth/day10/day10.go
Normal file
141
2024/gareth/day10/day10.go
Normal file
@@ -0,0 +1,141 @@
|
||||
package day10
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var directions = [][2]int{
|
||||
{-1, 0},
|
||||
{1, 0},
|
||||
{0, -1},
|
||||
{0, 1},
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
grid := ParseInput(input)
|
||||
return CalculateTotalTrailheadScore(grid)
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
grid := ParseInput(input)
|
||||
return CalculateTotalTrailheadRating(grid)
|
||||
}
|
||||
|
||||
func ParseInput(input string) [][]int {
|
||||
lines := strings.Split(strings.TrimSpace(input), "\n")
|
||||
grid := make([][]int, len(lines))
|
||||
for i, line := range lines {
|
||||
grid[i] = make([]int, len(line))
|
||||
for j, char := range line {
|
||||
grid[i][j] = int(char - '0')
|
||||
}
|
||||
}
|
||||
return grid
|
||||
}
|
||||
|
||||
func IsValidPosition(x, y, rows, cols int) bool {
|
||||
return x >= 0 && x < rows && y >= 0 && y < cols
|
||||
}
|
||||
|
||||
func DFS(grid [][]int, x, y, prevHeight int, visited [][]bool, reached9 map[[2]int]bool) {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
if !IsValidPosition(x, y, rows, cols) || visited[x][y] || grid[x][y] != prevHeight+1 {
|
||||
return
|
||||
}
|
||||
|
||||
if grid[x][y] == 9 {
|
||||
reached9[[2]int{x, y}] = true
|
||||
return
|
||||
}
|
||||
|
||||
visited[x][y] = true
|
||||
for _, dir := range directions {
|
||||
nx, ny := x+dir[0], y+dir[1]
|
||||
DFS(grid, nx, ny, grid[x][y], visited, reached9)
|
||||
}
|
||||
visited[x][y] = false
|
||||
}
|
||||
|
||||
func CalculateTrailheadScore(grid [][]int, x, y int) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
visited := make([][]bool, rows)
|
||||
for i := range visited {
|
||||
visited[i] = make([]bool, cols)
|
||||
}
|
||||
|
||||
reached9 := make(map[[2]int]bool)
|
||||
DFS(grid, x, y, -1, visited, reached9)
|
||||
return len(reached9)
|
||||
}
|
||||
|
||||
func DFSForRatings(grid [][]int, x, y, prevHeight int, visited [][]bool, trailCache map[[3]int]int) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
if !IsValidPosition(x, y, rows, cols) || visited[x][y] || grid[x][y] != prevHeight+1 {
|
||||
return 0
|
||||
}
|
||||
|
||||
if grid[x][y] == 9 {
|
||||
return 1
|
||||
}
|
||||
|
||||
cacheKey := [3]int{x, y, grid[x][y]}
|
||||
if count, exists := trailCache[cacheKey]; exists {
|
||||
return count
|
||||
}
|
||||
|
||||
visited[x][y] = true
|
||||
totalTrails := 0
|
||||
for _, dir := range directions {
|
||||
nx, ny := x+dir[0], y+dir[1]
|
||||
totalTrails += DFSForRatings(grid, nx, ny, grid[x][y], visited, trailCache)
|
||||
}
|
||||
visited[x][y] = false
|
||||
|
||||
trailCache[cacheKey] = totalTrails
|
||||
return totalTrails
|
||||
}
|
||||
|
||||
func CalculateTrailheadRating(grid [][]int, x, y int) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
visited := make([][]bool, rows)
|
||||
for i := range visited {
|
||||
visited[i] = make([]bool, cols)
|
||||
}
|
||||
|
||||
trailCache := make(map[[3]int]int)
|
||||
return DFSForRatings(grid, x, y, -1, visited, trailCache)
|
||||
}
|
||||
|
||||
func CalculateTotalTrailheadScore(grid [][]int) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
totalScore := 0
|
||||
for i := 0; i < rows; i++ {
|
||||
for j := 0; j < cols; j++ {
|
||||
if grid[i][j] == 0 {
|
||||
score := CalculateTrailheadScore(grid, i, j)
|
||||
totalScore += score
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalScore
|
||||
}
|
||||
|
||||
func CalculateTotalTrailheadRating(grid [][]int) int {
|
||||
rows := len(grid)
|
||||
cols := len(grid[0])
|
||||
totalRating := 0
|
||||
for i := 0; i < rows; i++ {
|
||||
for j := 0; j < cols; j++ {
|
||||
if grid[i][j] == 0 {
|
||||
rating := CalculateTrailheadRating(grid, i, j)
|
||||
totalRating += rating
|
||||
}
|
||||
}
|
||||
}
|
||||
return totalRating
|
||||
}
|
||||
31
2024/gareth/day10/day10_test.go
Normal file
31
2024/gareth/day10/day10_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package day10
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`89010123
|
||||
78121874
|
||||
87430965
|
||||
96549874
|
||||
45678903
|
||||
32019012
|
||||
01329801
|
||||
10456732`)
|
||||
assert.Equal(t, 36, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`89010123
|
||||
78121874
|
||||
87430965
|
||||
96549874
|
||||
45678903
|
||||
32019012
|
||||
01329801
|
||||
10456732`)
|
||||
assert.Equal(t, 81, r)
|
||||
}
|
||||
45
2024/gareth/day10/input.txt
Normal file
45
2024/gareth/day10/input.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
987123434330121232101001234730123456781067632
|
||||
876076576521010345692340349823212347892398701
|
||||
945087689432105676787659856714503210987445610
|
||||
332196576587654989801456787609654502376530923
|
||||
211543210298923215432321098128778901430121894
|
||||
300692340147210106523543210039569876589836765
|
||||
456781678236103267015693016543410231276745650
|
||||
576890549345234178106782187612320140345654321
|
||||
985098432100125089235493498109876056034765012
|
||||
834127102345456978340362569018765487123876678
|
||||
123236221976347869651251078729034398101985589
|
||||
014545340889298958707867897430120987012834432
|
||||
105965456770107843216950956541231276543124501
|
||||
896872378761016930345441019876501345678023670
|
||||
787901069654325321210332398545432330589012981
|
||||
107821543213034321089206787638901421432103210
|
||||
215430694102123475670115896129876548901210349
|
||||
126989780210014984308924925014578037654321458
|
||||
037878921001235675217833210123669123109452367
|
||||
549865438901045102346542106548754321278501476
|
||||
678954987432696201256430087239689870347699985
|
||||
230143006501787349961021298101236787656788014
|
||||
123272112981010458872787034010345691875107623
|
||||
054387623472129867763698125676210010961234510
|
||||
565694502561036789854567012980387121250129878
|
||||
676783411051045672343218763901296030343278569
|
||||
989872123432345891050109654812345145467303450
|
||||
012763094321056700891760345765432256958912341
|
||||
103450185789763211709851236876301967843211032
|
||||
814321276656854345612345654954101878701208983
|
||||
923434434565956745678036783063210989870345674
|
||||
874532345410345832989123192178981876781456564
|
||||
265101654323234901808765013265432185692387565
|
||||
103216765432101267814554323476501094501893474
|
||||
232109856321011876923601098789678923432102985
|
||||
343898707896540945498712367765672310567891078
|
||||
456789010987231234321203456894581455454986569
|
||||
556776125670102343100157654503490166303890432
|
||||
543895434894321765212348983212321876212761201
|
||||
432104898765010894301054581200110955211654300
|
||||
301256567656987105498765690341034567300563212
|
||||
434567430547896234787654785652123498456767843
|
||||
321798121032345375696543098743096567877854952
|
||||
210899021121036789781232143456787656928923761
|
||||
326765430110145678710123232109876543210010890
|
||||
89
2024/gareth/day11/day11.go
Normal file
89
2024/gareth/day11/day11.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package day11
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Part1(input string) int {
|
||||
stones := ParseInput(input)
|
||||
return len(blinkTimes(stones, 25))
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
stones := ParseInput(input)
|
||||
return getNumStones(stones, 75)
|
||||
}
|
||||
|
||||
func ParseInput(input string) []int {
|
||||
strStones := strings.Split(strings.TrimSpace(input), " ")
|
||||
stones := make([]int, 0, len(strStones))
|
||||
for _, s := range strStones {
|
||||
num, _ := strconv.Atoi(s)
|
||||
stones = append(stones, num)
|
||||
}
|
||||
return stones
|
||||
}
|
||||
|
||||
// Part 1 initial thought of recursion
|
||||
func blinkTimes(stones []int, times int) []int {
|
||||
if times <= 0 {
|
||||
return stones
|
||||
}
|
||||
result := blink(stones)
|
||||
return blinkTimes(result, times-1)
|
||||
}
|
||||
|
||||
func blink(stones []int) []int {
|
||||
result := make([]int, 0)
|
||||
for _, stone := range stones {
|
||||
strStone := strconv.Itoa(stone)
|
||||
if stone == 0 {
|
||||
result = append(result, 1)
|
||||
} else if len(strStone)%2 == 0 {
|
||||
mid := len(strStone) / 2
|
||||
firstHalf, _ := strconv.Atoi(strStone[:mid])
|
||||
secondHalf, _ := strconv.Atoi(strStone[mid:])
|
||||
result = append(result, firstHalf, secondHalf)
|
||||
} else {
|
||||
result = append(result, stone*2024)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Part 2 with maps since blinkTimes(75) would set my computer on fire
|
||||
func getNumStones(s []int, times int) int {
|
||||
stoneMap := make(map[int]int)
|
||||
for _, stone := range s {
|
||||
stoneMap[stone] = stoneMap[stone] + 1
|
||||
}
|
||||
|
||||
for i := 0; i < times; i++ {
|
||||
stoneMap2 := make(map[int]int)
|
||||
for stone, count := range stoneMap {
|
||||
stones := make([]int, 0)
|
||||
strStone := strconv.Itoa(stone)
|
||||
if stone == 0 {
|
||||
stones = append(stones, 1)
|
||||
} else if len(strStone)%2 == 0 {
|
||||
mid := len(strStone) / 2
|
||||
firstHalf, _ := strconv.Atoi(strStone[:mid])
|
||||
secondHalf, _ := strconv.Atoi(strStone[mid:])
|
||||
stones = append(stones, firstHalf, secondHalf)
|
||||
} else {
|
||||
stones = append(stones, stone*2024)
|
||||
}
|
||||
for _, newStone := range stones {
|
||||
stoneMap2[newStone] = stoneMap2[newStone] + count
|
||||
}
|
||||
}
|
||||
stoneMap = stoneMap2
|
||||
}
|
||||
|
||||
result := 0
|
||||
for _, count := range stoneMap {
|
||||
result += count
|
||||
}
|
||||
return result
|
||||
}
|
||||
12
2024/gareth/day11/day11_test.go
Normal file
12
2024/gareth/day11/day11_test.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package day11
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`125 17`)
|
||||
assert.Equal(t, 55312, r)
|
||||
}
|
||||
1
2024/gareth/day11/input.txt
Normal file
1
2024/gareth/day11/input.txt
Normal file
@@ -0,0 +1 @@
|
||||
965842 9159 3372473 311 0 6 86213 48
|
||||
76
2024/gareth/day13/day13.go
Normal file
76
2024/gareth/day13/day13.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ClawMachine struct {
|
||||
Ax, Ay int
|
||||
Bx, By int
|
||||
Px, Py int
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
clawMachines := parseInput(input)
|
||||
total := 0
|
||||
for _, c := range clawMachines {
|
||||
x, y := solveSimEquations(c.Ax, c.Bx, c.Px, c.Ay, c.By, c.Py)
|
||||
total += x*3 + y
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
clawMachines := parseInput(input)
|
||||
total := 0
|
||||
for _, c := range clawMachines {
|
||||
prizeX, prizeY := c.Px+10000000000000, c.Py+10000000000000
|
||||
det, x, y := c.Ax*c.By-c.Bx*c.Ay, prizeX*c.By-c.Bx*prizeY, c.Ax*prizeY-prizeX*c.Ay
|
||||
if det != 0 && x == (x/det)*det && y == (y/det)*det {
|
||||
total += (x/det)*3 + (y / det)
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func parseInput(input string) []ClawMachine {
|
||||
clawMachines := strings.Split(strings.TrimSpace(input), "\n\n")
|
||||
output := make([]ClawMachine, 0, len(clawMachines))
|
||||
for _, c := range clawMachines {
|
||||
var clawMachine ClawMachine
|
||||
line := strings.Split(strings.TrimSpace(c), "\n")
|
||||
|
||||
re := regexp.MustCompile(`X\+(\d+), Y\+(\d+)`)
|
||||
matches := re.FindStringSubmatch(line[0])
|
||||
clawMachine.Ax, _ = strconv.Atoi(matches[1])
|
||||
clawMachine.Ay, _ = strconv.Atoi(matches[2])
|
||||
|
||||
matches = re.FindStringSubmatch(line[1])
|
||||
clawMachine.Bx, _ = strconv.Atoi(matches[1])
|
||||
clawMachine.By, _ = strconv.Atoi(matches[2])
|
||||
|
||||
re = regexp.MustCompile(`X=(\d+), Y=(\d+)`)
|
||||
matches = re.FindStringSubmatch(line[2])
|
||||
clawMachine.Px, _ = strconv.Atoi(matches[1])
|
||||
clawMachine.Py, _ = strconv.Atoi(matches[2])
|
||||
|
||||
output = append(output, clawMachine)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
func solveSimEquations(a1, b1, c1, a2, b2, c2 int) (int, int) {
|
||||
det := a1*b2 - a2*b1
|
||||
if det == 0 || (c1*b2-c2*b1)%det != 0 || (a1*c2-a2*c1)%det != 0 {
|
||||
return 0, 0
|
||||
}
|
||||
x := (c1*b2 - c2*b1) / det
|
||||
y := (a1*c2 - a2*c1) / det
|
||||
if x < 0 || x > 100 || y < 0 || y > 100 {
|
||||
return 0, 0
|
||||
}
|
||||
return x, y
|
||||
}
|
||||
45
2024/gareth/day13/day13_test.go
Normal file
45
2024/gareth/day13/day13_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`Button A: X+94, Y+34
|
||||
Button B: X+22, Y+67
|
||||
Prize: X=8400, Y=5400
|
||||
|
||||
Button A: X+26, Y+66
|
||||
Button B: X+67, Y+21
|
||||
Prize: X=12748, Y=12176
|
||||
|
||||
Button A: X+17, Y+86
|
||||
Button B: X+84, Y+37
|
||||
Prize: X=7870, Y=6450
|
||||
|
||||
Button A: X+69, Y+23
|
||||
Button B: X+27, Y+71
|
||||
Prize: X=18641, Y=10279`)
|
||||
assert.Equal(t, 480, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
r := Part2(`Button A: X+94, Y+34
|
||||
Button B: X+22, Y+67
|
||||
Prize: X=8400, Y=5400
|
||||
|
||||
Button A: X+26, Y+66
|
||||
Button B: X+67, Y+21
|
||||
Prize: X=12748, Y=12176
|
||||
|
||||
Button A: X+17, Y+86
|
||||
Button B: X+84, Y+37
|
||||
Prize: X=7870, Y=6450
|
||||
|
||||
Button A: X+69, Y+23
|
||||
Button B: X+27, Y+71
|
||||
Prize: X=18641, Y=10279`)
|
||||
assert.Equal(t, 0, r)
|
||||
}
|
||||
1279
2024/gareth/day13/input.txt
Normal file
1279
2024/gareth/day13/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
172
2024/gareth/day14/day14.go
Normal file
172
2024/gareth/day14/day14.go
Normal file
@@ -0,0 +1,172 @@
|
||||
package day14
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Robot struct {
|
||||
px, py int // position
|
||||
vx, vy int // velocity
|
||||
}
|
||||
|
||||
func Part1(input string) int {
|
||||
// Parse the input
|
||||
lines := strings.Split(input, "\n")
|
||||
var robots []Robot
|
||||
for _, line := range lines {
|
||||
robot := ParseRobot(line)
|
||||
robots = append(robots, robot)
|
||||
}
|
||||
|
||||
// Define grid size
|
||||
gridWidth := 101
|
||||
gridHeight := 103
|
||||
|
||||
// Update robot positions for 100 seconds
|
||||
for i := 0; i < 100; i++ {
|
||||
for j := range robots {
|
||||
robots[j].UpdatePosition(gridWidth, gridHeight)
|
||||
}
|
||||
}
|
||||
|
||||
// Count the robots in each quadrant
|
||||
q1, q2, q3, q4 := CountRobotsInQuadrants(robots, gridWidth, gridHeight)
|
||||
fmt.Printf("Quadrant counts: Q1=%d, Q2=%d, Q3=%d, Q4=%d\n", q1, q2, q3, q4)
|
||||
|
||||
// Calculate the safety factor
|
||||
safetyFactor := CalculateSafetyFactor(q1, q2, q3, q4)
|
||||
fmt.Printf("Safety Factor: %d\n", safetyFactor)
|
||||
return safetyFactor
|
||||
}
|
||||
|
||||
func Part2(input string) int {
|
||||
// Parse the input
|
||||
lines := strings.Split(input, "\n")
|
||||
var robots []Robot
|
||||
for _, line := range lines {
|
||||
robot := ParseRobot(line)
|
||||
robots = append(robots, robot)
|
||||
}
|
||||
|
||||
// Define grid size
|
||||
gridWidth := 101
|
||||
gridHeight := 103
|
||||
|
||||
// Update robot positions for 100 seconds
|
||||
for i := 0; i < 6285; i++ {
|
||||
for j := range robots {
|
||||
robots[j].UpdatePosition(gridWidth, gridHeight)
|
||||
}
|
||||
}
|
||||
|
||||
DisplayGrid(robots, gridWidth, gridHeight)
|
||||
return 2
|
||||
}
|
||||
|
||||
// ParseRobot takes a line of input and converts it to a Robot struct
|
||||
func ParseRobot(line string) Robot {
|
||||
parts := strings.Split(line, " ")
|
||||
posParts := strings.Split(parts[0][2:], ",") // Extract p=x,y and split
|
||||
velParts := strings.Split(parts[1][2:], ",") // Extract v=x,y and split
|
||||
|
||||
px, _ := strconv.Atoi(posParts[0])
|
||||
py, _ := strconv.Atoi(posParts[1])
|
||||
vx, _ := strconv.Atoi(velParts[0])
|
||||
vy, _ := strconv.Atoi(velParts[1])
|
||||
|
||||
return Robot{px, py, vx, vy}
|
||||
}
|
||||
|
||||
// UpdatePosition updates the position of a robot, considering the wrap-around
|
||||
func (r *Robot) UpdatePosition(gridWidth, gridHeight int) {
|
||||
r.px = (r.px + r.vx + gridWidth) % gridWidth
|
||||
r.py = (r.py + r.vy + gridHeight) % gridHeight
|
||||
}
|
||||
|
||||
// CountRobotsInQuadrants counts the number of robots in each of the four quadrants
|
||||
func CountRobotsInQuadrants(robots []Robot, width, height int) (int, int, int, int) {
|
||||
midX := width / 2
|
||||
midY := height / 2
|
||||
|
||||
q1, q2, q3, q4 := 0, 0, 0, 0
|
||||
|
||||
for _, r := range robots {
|
||||
if r.px == midX || r.py == midY {
|
||||
// Skip robots on the middle line
|
||||
continue
|
||||
}
|
||||
if r.px < midX && r.py < midY {
|
||||
q1++ // Top-left quadrant
|
||||
} else if r.px > midX && r.py < midY {
|
||||
q2++ // Top-right quadrant
|
||||
} else if r.px < midX && r.py > midY {
|
||||
q3++ // Bottom-left quadrant
|
||||
} else if r.px > midX && r.py > midY {
|
||||
q4++ // Bottom-right quadrant
|
||||
}
|
||||
}
|
||||
|
||||
return q1, q2, q3, q4
|
||||
}
|
||||
|
||||
// CalculateSafetyFactor multiplies the number of robots in each quadrant
|
||||
func CalculateSafetyFactor(q1, q2, q3, q4 int) int {
|
||||
return q1 * q2 * q3 * q4
|
||||
}
|
||||
|
||||
// DisplayGrid displays the current state of the grid
|
||||
func DisplayGrid(robots []Robot, width, height int) {
|
||||
grid := make([][]rune, height)
|
||||
for i := range grid {
|
||||
grid[i] = make([]rune, width)
|
||||
for j := range grid[i] {
|
||||
grid[i][j] = '.'
|
||||
}
|
||||
}
|
||||
for _, r := range robots {
|
||||
grid[r.py][r.px] = '#'
|
||||
}
|
||||
for _, row := range grid {
|
||||
fmt.Println(string(row))
|
||||
}
|
||||
}
|
||||
|
||||
// FindEasterEgg determines the fewest number of seconds that must elapse for the robots to display the Easter egg
|
||||
func FindEasterEgg(robots []Robot, width, height int) int {
|
||||
smallestArea := width * height
|
||||
bestTime := 0
|
||||
for t := 6285; t < 6286; t++ { // Large upper limit to search
|
||||
// Update robot positions
|
||||
for i := range robots {
|
||||
robots[i].UpdatePosition(width, height)
|
||||
}
|
||||
// Calculate the bounding box of all robot positions
|
||||
minX, minY := width, height
|
||||
maxX, maxY := 0, 0
|
||||
for _, r := range robots {
|
||||
if r.px < minX {
|
||||
minX = r.px
|
||||
}
|
||||
if r.px > maxX {
|
||||
maxX = r.px
|
||||
}
|
||||
if r.py < minY {
|
||||
minY = r.py
|
||||
}
|
||||
if r.py > maxY {
|
||||
maxY = r.py
|
||||
}
|
||||
}
|
||||
|
||||
area := (maxX - minX + 1) * (maxY - minY + 1)
|
||||
if area < smallestArea {
|
||||
smallestArea = area
|
||||
bestTime = t + 1
|
||||
fmt.Printf("Time: %d\n", bestTime)
|
||||
DisplayGrid(robots, width, height)
|
||||
}
|
||||
}
|
||||
return bestTime
|
||||
}
|
||||
23
2024/gareth/day14/day14_test.go
Normal file
23
2024/gareth/day14/day14_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package day14
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
r := Part1(`p=0,4 v=3,-3
|
||||
p=6,3 v=-1,-3
|
||||
p=10,3 v=-1,2
|
||||
p=2,0 v=2,-1
|
||||
p=0,0 v=1,3
|
||||
p=3,0 v=-2,-2
|
||||
p=7,6 v=-1,-3
|
||||
p=3,0 v=-1,-2
|
||||
p=9,3 v=2,3
|
||||
p=7,3 v=-1,2
|
||||
p=2,4 v=2,-3
|
||||
p=9,5 v=-3,-3`)
|
||||
assert.Equal(t, 12, r)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user