45 Commits

Author SHA1 Message Date
aa84e3974b feat: add day 6 2024
Some checks failed
Go Test / build (pull_request) Failing after 1m31s
2025-07-06 16:09:34 -06:00
xuu
aa0a2b7b7d feat: add day 5 2024
Some checks failed
Go Bump / bump (push) Failing after 44s
Go Test / build (push) Failing after 14m5s
2024-12-06 13:47:49 -07:00
xuu
77a0669f45 feat: add day 4 2024
Some checks failed
Go Bump / bump (push) Failing after 9s
Go Test / build (push) Failing after 54s
2024-12-06 11:28:30 -07:00
xuu
c077b91c41 fix(aoc2024): clean up day 3
Some checks failed
Go Bump / bump (push) Failing after 9s
Go Test / build (push) Failing after 52s
2024-12-04 08:24:59 -07:00
xuu
b3c36c1af1 Merge pull request 'AOC 2024 Day 3' (#23) from working2024D3 into main
Some checks failed
Go Bump / bump (push) Failing after 10s
Go Test / build (push) Failing after 57s
Reviewed-on: #23
2024-12-03 16:16:23 -07:00
xuu
6a17669107 feat(aoc2024): complete day 3 part 2
Some checks failed
Go Test / build (pull_request) Failing after 57s
2024-12-03 16:15:53 -07:00
xuu
127257c494 chore: state after where broken 2024-12-03 15:12:39 -07:00
xuu
7b9a71f84c chore: state before changes that were working 2024-12-03 15:11:33 -07:00
xuu
669e2cfb2c feat: add day 3 2024 (iter crashes on solution 2) 2024-12-03 14:51:54 -07:00
xuu
2274eca981 feat: add day 2 2024
Some checks failed
Go Bump / bump (push) Failing after 6s
Go Test / build (push) Failing after 44s
2024-12-02 10:24:38 -07:00
xuu
b1e4c4d634 feat: add day 1 2024
Some checks failed
Go Bump / bump (push) Failing after 8s
Go Test / build (push) Failing after 45s
2024-12-01 11:38:06 -07:00
xuu
4b3fc7eb73 chore: make reduce more iter.Seq 2024-12-01 11:37:27 -07:00
xuu
0d652660f1 chore: add day25 part 1
Some checks failed
Go Bump / bump (push) Failing after 6s
Go Test / build (push) Failing after 45s
2024-11-20 09:07:01 -07:00
xuu
e046a6c06d chore: cleanup and add tools 2024-10-30 13:32:44 -06:00
xuu
04bbac8559 chore: add hackerrank solutions
Some checks failed
Go Bump / bump (push) Failing after 6s
Go Test / build (push) Successful in 47s
2024-10-26 12:03:06 -06:00
xuu
3c9af95ec4 chore: setup folders for aoc 2024
Some checks failed
Go Bump / bump (push) Failing after 9s
Go Test / build (push) Successful in 38s
2024-10-26 11:38:44 -06:00
xuu
50af2114d4 add ranger
Some checks failed
Go Bump / bump (push) Failing after 6s
Go Test / build (push) Failing after 21s
2024-04-05 16:27:02 -06:00
xuu
f8fa61672f chore: fixes
All checks were successful
Go Bump / bump (push) Successful in 7s
Go Test / build (push) Successful in 35s
2024-01-22 16:07:16 -07:00
xuu
951c2c298a chore(aos): add compress graph
Some checks failed
Go Bump / bump (push) Successful in 9s
Go Test / build (push) Failing after 24s
2024-01-12 12:09:44 -07:00
xuu
328a0f3eb3 chore(aoc): add FibHeap DecreaseKey
All checks were successful
Go Bump / bump (push) Successful in 8s
Go Test / build (push) Successful in 40s
2024-01-09 20:41:23 -07:00
xuu
7d7402f054 chore(day17): implement fibHeap for faster priority queue
All checks were successful
Go Test / build (pull_request) Successful in 37s
Go Bump / bump (push) Successful in 7s
Go Test / build (push) Successful in 39s
2024-01-09 13:53:30 -07:00
xuu
7585526634 chore(day17): simplify FindPath. A* is still slower :|
Some checks failed
Go Test / build (pull_request) Failing after 4m27s
2024-01-04 17:15:44 -07:00
xuu
924c8d74f3 chore(day17): disable heuristic. runs faster!? 2024-01-02 20:57:02 -07:00
xuu
22184ed9c7 chore(aoc): initial graph attempt 2024-01-02 17:02:12 -07:00
xuu
74a952e82b chore(day19): add part 2
All checks were successful
Go Bump / bump (push) Successful in 6s
Go Test / build (push) Successful in 1m30s
2024-01-01 19:15:36 -07:00
xuu
62f8338227 chore: organization day19 2024-01-01 19:15:36 -07:00
xuu
39c6f8ed4d chore: add day 19 pt 1 2024-01-01 19:15:36 -07:00
xuu
2c959c109b tests(day17): disable solution
All checks were successful
Go Bump / bump (push) Successful in 7s
Go Test / build (push) Successful in 49s
2024-01-01 14:19:00 -07:00
xuu
eb1eaaab43 chore(day17): add open list for A*
Some checks failed
Go Bump / bump (push) Successful in 8s
Go Test / build (push) Failing after 4m29s
2024-01-01 14:12:53 -07:00
xuu
adc01f4df9 chore(day17): log output
All checks were successful
Go Bump / bump (push) Successful in 6s
Go Test / build (push) Successful in 40s
2024-01-01 12:44:08 -07:00
xuu
fd85530d88 chore(day17): simplify interfaces. add docs
All checks were successful
Go Bump / bump (push) Successful in 12s
Go Test / build (push) Successful in 46s
2024-01-01 10:59:40 -07:00
xuu
0d78959bea chore(day17): fix missing changes
All checks were successful
Go Test / build (pull_request) Successful in 37s
Go Bump / bump (push) Successful in 7s
Go Test / build (push) Successful in 34s
2024-01-01 09:57:08 -07:00
xuu
86f2f7a6f2 chore(day17): implent A* path finder
All checks were successful
Go Bump / bump (push) Successful in 8s
Go Test / build (pull_request) Successful in 51s
Go Test / build (push) Successful in 35s
2024-01-01 09:29:25 -07:00
xuu
378e403c1c Merge pull request 'chore: fix uncertanty on day17' (#18) from day17-enhance into main
All checks were successful
Go Bump / bump (push) Successful in 8s
Go Test / build (push) Successful in 34s
Reviewed-on: #18
2023-12-29 21:12:11 -07:00
xuu
06a22511b5 Merge branch 'main' into day17-enhance
All checks were successful
Go Test / build (pull_request) Successful in 36s
2023-12-29 21:11:24 -07:00
xuu
a2563b9d31 chore: fix uncertanty on day17
All checks were successful
Go Test / build (pull_request) Successful in 36s
2023-12-29 21:10:59 -07:00
xuu
3c2ea4ed9e Merge pull request 'chore: fix dijkstra' (#17) from day17-enhance into main
Some checks failed
Go Bump / bump (push) Failing after 8s
Go Test / build (push) Failing after 1m30s
Reviewed-on: #17
2023-12-28 19:01:39 -07:00
xuu
1fac5f7b4d chore: fix dijkstra
Some checks failed
Go Test / build (pull_request) Failing after 2m39s
2023-12-28 18:59:46 -07:00
xuu
1a3374a557 chore: save day18 (#12)
Some checks failed
Go Bump / bump (push) Successful in 7s
Go Test / build (push) Failing after 10m26s
Reviewed-on: #12
2023-12-27 14:07:32 -07:00
xuu
170fecc9f6 Merge pull request 'chore: add day 17 pt 2' (#16) from day17 into main
Some checks failed
Go Bump / bump (push) Successful in 21s
Go Test / build (push) Failing after 10m27s
Reviewed-on: #16
2023-12-26 13:30:31 -07:00
xuu
58e482b125 Merge branch 'main' into day17
Some checks failed
Go Test / build (pull_request) Failing after 10m28s
2023-12-26 13:30:25 -07:00
xuu
d21005c534 Merge pull request 'chore: cleanup day 7' (#10) from day07-enhance into main
All checks were successful
Go Bump / bump (push) Successful in 6s
Go Test / build (push) Successful in 34s
Reviewed-on: #10
2023-12-26 13:18:08 -07:00
xuu
3e0ed68db3 Merge branch 'main' into day07-enhance
All checks were successful
Go Test / build (pull_request) Successful in 37s
2023-12-26 13:17:18 -07:00
xuu
f1ac3ea35f chore: fix day 07 2023-12-26 13:17:07 -07:00
xuu
50f1016372 chore: cleanup 2023-12-08 12:11:44 -07:00
157 changed files with 12616 additions and 721 deletions

View File

@@ -28,6 +28,6 @@ jobs:
go-version: 1.21.3
- name: Test
run: go test --race -cover ./...
run: go test -timeout 240s -race -cover ./...
- run: echo "🍏 This job's status is ${{ job.status }}."

6
README.md.sig Normal file
View File

@@ -0,0 +1,6 @@
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgZ+OuJYdd3UiUbyBuO1RlsQR20a
Qm5mKneuMxRjGo3zkAAAAEZmlsZQAAAAAAAAAGc2hhNTEyAAAAUwAAAAtzc2gtZWQyNTUx
OQAAAED8T4C6WILXYZ1KxqDIlVhlrAEjr1Vc+tn8ypcVM3bN7iOexVvuUuvm90nr8eEwKU
acrdDxmq2S+oysQbK+pMUE
-----END SSH SIGNATURE-----

View File

@@ -30,7 +30,6 @@ func TestExample1(t *testing.T) {
is.Equal(result.sum, 142)
}
func TestExample2(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(example2))

1000
aoc2023/day07/input2.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@ import (
"bufio"
_ "embed"
"fmt"
"slices"
"strings"
aoc "go.sour.is/advent-of-code"
@@ -62,7 +63,7 @@ func run(scan *bufio.Scanner) (*result, error) {
func(i int, v int, counts [3]int) [3]int {
counts[v]++
return counts
}, [3]int{}, maps.Values(memo)...)
}, [3]int{}, slices.Values(maps.Values(memo)))
// fmt.Println(i, counts)
i = 1_000_000_000 - (1_000_000_000-counts[0]-counts[1])%counts[2]

View File

@@ -36,11 +36,10 @@ func TestSolution(t *testing.T) {
is.NoErr(err)
t.Log(result)
is.True(result.valuePT2 < 87286) // first submission
is.True(result.valuePT2 < 87292) // second submission
is.True(result.valuePT2 < 87287) // third submission
is.True(result.valuePT2 < 87286) // first submission
is.True(result.valuePT2 < 87292) // second submission
is.True(result.valuePT2 < 87287) // third submission
is.Equal(result.valuePT1, 110407)
is.Equal(result.valuePT2, 87273)
}

View File

@@ -32,14 +32,14 @@ func run(scan *bufio.Scanner) (*result, error) {
r.valuePT1 = aoc.Reduce(func(i int, t string, sum int) int {
sum += hash(t)
return sum
}, 0, ops...)
}, 0, slices.Values(ops))
}
var boxen boxes
boxen = aoc.Reduce(func(i int, op string, b boxes) boxes {
return b.Op(op)
}, boxen, ops...)
}, boxen, slices.Values(ops))
r.valuePT2 = boxen.Sum()

View File

@@ -32,15 +32,15 @@ func run(scan *bufio.Scanner) (*result, error) {
options := make([]int, 2*(rows+cols)+2)
i := 0
for j:=0; j<=rows-1; j++ {
for j := 0; j <= rows-1; j++ {
options[i+0] = runCycle(m, ray{[2]int{j, -1}, RT})
options[i+1] = runCycle(m, ray{[2]int{j, cols}, LF})
i+=2
i += 2
}
for j:=0; j<=cols-1; j++ {
for j := 0; j <= cols-1; j++ {
options[i+0] = runCycle(m, ray{[2]int{-1, j}, DN})
options[i+1] = runCycle(m, ray{[2]int{rows, j}, UP})
i+=2
i += 2
}
// fmt.Println(options)
@@ -96,7 +96,6 @@ func (m *Map) Get(p [2]int) rune {
return (*m)[p[0]][p[1]]
}
func runCycle(m Map, r ray) int {
current := r
@@ -186,4 +185,4 @@ func runCycle(m Map, r ray) int {
// }
return len(energized)
}
}

View File

@@ -47,4 +47,4 @@ func TestStack(t *testing.T) {
s := stack[int]{}
s.Push(5)
is.Equal(s.Pop(), 5)
}
}

225
aoc2023/day17/main.go Normal file
View File

@@ -0,0 +1,225 @@
package main
import (
"bufio"
_ "embed"
"fmt"
aoc "go.sour.is/advent-of-code"
)
var log = aoc.Log
func main() { aoc.MustResult(aoc.Runner(run)) }
type result struct {
valuePT1 int
valuePT2 int
}
func (r result) String() string { return fmt.Sprintf("%#v", r) }
func run(scan *bufio.Scanner) (*result, error) {
var m aoc.Map[int16, rune]
for scan.Scan() {
text := scan.Text()
m = append(m, []rune(text))
}
log("start day 17")
result := result{}
result.valuePT1 = search(m, 1, 3, seenFn)
log("result from part 1 = ", result.valuePT1)
result.valuePT2 = search(m, 4, 10, nil)
log("result from part 2 = ", result.valuePT2)
return &result, nil
}
type Point = aoc.Point[int16]
type Map = aoc.Map[int16, rune]
// rotate for changing direction
type rotate int8
const (
CW rotate = 1
CCW rotate = -1
)
// diretion of path steps
type direction int8
var (
U = Point{-1, 0}
R = Point{0, 1}
D = Point{1, 0}
L = Point{0, -1}
)
var directions = []Point{U, R, D, L}
var directionIDX = func() map[Point]direction {
m := make(map[Point]direction, len(directions))
for k, v := range directions {
m[v] = direction(k)
}
return m
}()
// position on the map
type position struct {
loc Point
direction Point
steps int8
}
func (p position) step() position {
return position{p.loc.Add(p.direction), p.direction, p.steps + 1}
}
func (p position) rotateAndStep(towards rotate) position {
d := directions[(int8(directionIDX[p.direction])+int8(towards)+4)%4]
return position{p.loc.Add(d), d, 1}
}
// implements FindPath graph interface
type graph struct {
min, max int8
m Map
target Point
reads int
seenFn func(a position) position
}
// Neighbors returns valid steps from given position. if at target returns none.
func (g *graph) Neighbors(current position) []position {
var nbs []position
if current.steps == 0 {
return []position{
{R, R, 1},
{D, D, 1},
}
}
if current.loc == g.target {
return nil
}
if left := current.rotateAndStep(CCW); current.steps >= g.min && g.m.Valid(left.loc) {
nbs = append(nbs, left)
}
if right := current.rotateAndStep(CW); current.steps >= g.min && g.m.Valid(right.loc) {
nbs = append(nbs, right)
}
if forward := current.step(); current.steps < g.max && g.m.Valid(forward.loc) {
nbs = append(nbs, forward)
}
return nbs
}
// Cost calculates heat cost to neighbor from map
func (g *graph) Cost(a, b position) int16 {
g.reads++
_, r, _ := g.m.Get(b.loc)
return int16(r - '0')
}
// Potential calculates distance to target
// func (g *graph) Potential(a position) int16 {
// return aoc.ManhattanDistance(a.loc, g.target)
// }
// Target returns true when target reached. receives node and cost.
func (g *graph) Target(a position, c int16) bool {
if a.loc == g.target && a.steps >= g.min && a.steps <= g.max {
return true
}
return false
}
// Seen attempt at simplifying the seen to use horizontal/vertical and no steps.
// It returns correct for part1 but not part 2..
func (g *graph) Seen(a position) position {
if g.seenFn != nil {
return g.seenFn(a)
}
return a
}
func seenFn(a position) position {
if a.direction == U {
a.direction = D
}
if a.direction == L {
a.direction = R
}
// a.steps = 0
return a
}
func search(m Map, minSteps, maxSteps int8, seenFn func(position) position) int {
rows, cols := m.Size()
start := Point{}
target := Point{rows - 1, cols - 1}
g := graph{min: minSteps, max: maxSteps, m: m, target: target, seenFn: seenFn}
cost, path, closed := aoc.FindPath[int16, position](&g, position{loc: start}, position{loc: target})
log("total map reads = ", g.reads, "cost = ", cost)
printGraph(m, path, closed, g.seenFn)
return int(cost)
}
// printGraph with the path/cost overlay
func printGraph(m Map, path []position, closed map[position]int16, seenFn func(a position) position) {
pts := make(map[Point]position, len(path))
for _, pt := range path {
pts[pt.loc] = pt
}
clpt := make(map[position]position, len(closed))
for pt := range closed {
clpt[position{loc: pt.loc, steps: pt.steps}] = pt
}
for r, row := range m {
// if r == 0 {
// for c := range row {
// if c == 0 {
// fmt.Print(" ")
// }
// fmt.Printf("% 5d", c)
// }
// fmt.Println("")
// }
for c := range row {
// if c == 0 {
// fmt.Printf("% 5d", r)
// }
if pt, ok := pts[Point{int16(r), int16(c)}]; ok {
if seenFn != nil {
pt = seenFn(pt)
}
_ = pt
// fmt.Printf("% 5d", closed[pt])
fmt.Print("*")
continue
}
// fmt.Print(" ....")
fmt.Print(" ")
}
fmt.Println("")
}
fmt.Println("")
}

14
aoc2023/day18/example.txt Normal file
View File

@@ -0,0 +1,14 @@
R 6 (#70c710)
D 5 (#0dc571)
L 2 (#5713f0)
D 2 (#d2c081)
R 2 (#59c680)
D 2 (#411b91)
L 5 (#8ceee2)
U 2 (#caa173)
L 1 (#1b58a2)
U 2 (#caa171)
R 2 (#7807d2)
U 3 (#a77fa3)
L 2 (#015232)
U 2 (#7a21e3)

766
aoc2023/day18/input.txt Normal file
View File

@@ -0,0 +1,766 @@
R 4 (#0a7a60)
U 8 (#4453b3)
R 6 (#8e4f70)
U 2 (#4453b1)
R 4 (#0feb00)
U 4 (#355591)
R 8 (#2a09c0)
U 4 (#544c71)
R 4 (#472930)
U 2 (#199e33)
R 3 (#3d8df0)
U 5 (#199e31)
R 7 (#45de50)
U 4 (#57a941)
L 7 (#671c70)
U 5 (#5e5e81)
R 4 (#2e9b60)
U 8 (#490881)
L 7 (#1846f0)
U 3 (#304101)
L 4 (#1846f2)
D 2 (#58f3f1)
L 9 (#2e9b62)
D 2 (#56dcd1)
L 2 (#671c72)
D 9 (#275fd1)
L 4 (#76b7b2)
U 9 (#5b9641)
L 4 (#1d3212)
U 10 (#3d1841)
L 3 (#5ad5e2)
D 6 (#010211)
L 5 (#13ec52)
D 8 (#166471)
L 3 (#53ebc0)
D 5 (#0fdba1)
L 4 (#54e450)
D 9 (#440a21)
L 3 (#49b242)
D 5 (#2f0171)
L 6 (#447332)
D 4 (#182561)
L 8 (#1aaaa2)
D 6 (#0996a1)
L 4 (#1c1212)
D 6 (#5780d1)
L 7 (#0fc1d2)
D 7 (#36cb41)
L 3 (#505552)
D 7 (#8d8b81)
R 4 (#2bf742)
D 7 (#152791)
R 5 (#760492)
D 3 (#11a991)
R 3 (#5debc0)
D 10 (#59f211)
L 4 (#66d342)
D 8 (#1fc6b1)
R 4 (#66d340)
D 6 (#72dff1)
L 2 (#3f1b10)
D 4 (#2fca13)
L 10 (#2d0162)
D 5 (#8b5e53)
L 6 (#2d0160)
U 2 (#317053)
L 2 (#650c20)
U 7 (#2bed01)
R 10 (#409ed0)
U 2 (#166713)
L 10 (#939350)
U 6 (#166711)
L 4 (#38a180)
D 3 (#1d95f1)
L 6 (#11ea60)
D 5 (#931dc1)
R 6 (#11bf70)
D 7 (#536051)
L 3 (#995b60)
D 2 (#254e91)
L 3 (#332fd2)
U 6 (#7669f1)
L 3 (#574642)
U 6 (#1778a1)
L 3 (#1a00c2)
U 5 (#2eaa81)
L 3 (#1cf8e2)
U 6 (#0c71a1)
L 6 (#868472)
U 3 (#0a9fd1)
R 9 (#104c02)
U 4 (#082451)
L 7 (#850d02)
U 6 (#082453)
L 7 (#322552)
U 3 (#1339d1)
L 6 (#8e11d2)
U 4 (#6c5691)
R 6 (#1dda10)
U 3 (#25e5c3)
R 7 (#370670)
U 4 (#9324f1)
L 3 (#451030)
U 7 (#1f1021)
L 7 (#0ba3c0)
U 5 (#8a10a3)
L 8 (#67db30)
U 5 (#282473)
L 4 (#0cd350)
U 4 (#25e5c1)
R 3 (#6b4ee0)
U 4 (#333cf1)
R 5 (#02b610)
D 4 (#4e7cc1)
R 3 (#92abb0)
U 5 (#2f6ff1)
R 5 (#483360)
U 5 (#7b1cd1)
L 8 (#3a5d50)
U 3 (#1d2461)
R 8 (#3b2fd0)
U 5 (#630763)
R 6 (#5033c0)
U 3 (#252523)
R 7 (#08eeb0)
U 8 (#516633)
L 7 (#156240)
U 4 (#2db063)
L 3 (#791070)
D 5 (#2920a3)
L 3 (#0dafe0)
U 5 (#4185b3)
L 5 (#7ac0e0)
U 2 (#5a6cd3)
L 2 (#3ca790)
U 7 (#755403)
L 4 (#3b0740)
U 5 (#2004a3)
L 3 (#2db4f0)
U 6 (#602a23)
R 5 (#32c1c0)
D 2 (#000f53)
R 5 (#388360)
D 7 (#24d9e3)
R 4 (#4703a0)
D 3 (#2f1133)
R 3 (#4703a2)
U 11 (#52e853)
R 5 (#278132)
D 11 (#0665e3)
R 3 (#239112)
U 6 (#8f0ad1)
R 5 (#447de2)
U 6 (#8f0ad3)
R 6 (#636122)
U 2 (#187283)
R 3 (#5aae62)
U 10 (#1d8833)
L 5 (#476db0)
U 5 (#136393)
L 7 (#29e6b0)
U 5 (#136391)
R 7 (#3ba060)
U 3 (#635e23)
L 5 (#2042f0)
U 3 (#181643)
L 6 (#5af952)
U 8 (#28d0b1)
L 2 (#4a98f2)
U 9 (#28d0b3)
L 6 (#27a572)
D 3 (#3d7213)
L 4 (#516842)
D 11 (#21ef63)
L 5 (#38e342)
D 2 (#1118b3)
L 3 (#560502)
D 9 (#1118b1)
R 2 (#1c39a2)
D 2 (#303ab3)
R 6 (#716ba0)
D 6 (#780a93)
L 8 (#77ec30)
U 2 (#780a91)
L 3 (#271100)
U 10 (#5882f3)
L 4 (#2050c2)
D 3 (#434843)
L 3 (#7d9572)
D 2 (#3129b3)
L 5 (#21fb12)
D 5 (#8c2c33)
L 4 (#57bf92)
D 6 (#2730b3)
L 4 (#6a3902)
D 8 (#4656a3)
L 5 (#60ac80)
D 4 (#43b863)
R 9 (#3d69a0)
D 8 (#3ca913)
L 2 (#411d80)
D 3 (#725383)
L 8 (#4a98d0)
D 9 (#274553)
L 5 (#580d60)
U 5 (#568223)
L 6 (#473af0)
U 5 (#827593)
L 7 (#251dc2)
U 5 (#0fcea3)
L 8 (#5ae3d2)
U 3 (#4efa11)
R 9 (#389852)
U 2 (#7f7f91)
R 6 (#618342)
U 3 (#441143)
L 7 (#886df2)
U 3 (#26a093)
L 8 (#886df0)
U 4 (#63c7d3)
L 3 (#04f842)
D 10 (#0fcea1)
L 6 (#388e62)
U 10 (#3ae7f3)
L 3 (#2a6880)
U 6 (#3bfd53)
L 6 (#73a0c0)
U 5 (#3bfd51)
L 4 (#0d18a0)
U 2 (#19da93)
L 6 (#120600)
U 8 (#233b53)
L 6 (#2e1050)
U 3 (#4b2aa3)
L 4 (#5f9930)
U 10 (#6e65f1)
R 6 (#1eefa0)
U 9 (#50b9d3)
R 2 (#548ed0)
U 9 (#50b9d1)
R 7 (#8bd9f0)
U 4 (#5ae473)
R 6 (#0b0490)
U 10 (#186891)
R 4 (#764830)
U 7 (#33b0e1)
R 5 (#363c90)
U 8 (#7bd631)
R 7 (#031e30)
U 7 (#095881)
R 3 (#640e50)
D 5 (#02e7f3)
R 7 (#0922f0)
D 7 (#6b7af3)
R 9 (#0922f2)
D 3 (#62e543)
R 3 (#21e320)
U 9 (#5ead81)
R 7 (#01fd70)
D 9 (#3b0cf1)
R 2 (#2758a0)
D 5 (#7279b1)
R 8 (#5c7dc0)
D 7 (#3c8db1)
R 4 (#3c3740)
U 2 (#26b151)
R 6 (#11eb12)
U 4 (#587921)
R 6 (#11eb10)
U 4 (#320051)
R 4 (#038630)
U 3 (#6a2e61)
R 2 (#4ff680)
U 5 (#3c57f1)
R 9 (#0b2440)
U 8 (#497533)
L 6 (#704680)
U 11 (#549113)
R 6 (#23b470)
U 4 (#9e0641)
R 7 (#1aeec0)
D 7 (#4a6331)
R 2 (#547d80)
D 5 (#457a71)
R 9 (#7daa90)
D 4 (#16d7b1)
L 6 (#266810)
D 3 (#363561)
L 5 (#5312b2)
D 4 (#42c301)
R 5 (#9a0952)
D 7 (#42c303)
R 7 (#7d1df2)
D 4 (#51e321)
R 5 (#609422)
D 4 (#3b8f01)
R 6 (#644792)
U 4 (#2d8b11)
R 7 (#22bbc2)
D 7 (#6b39b1)
R 5 (#680e72)
U 2 (#7f9f31)
R 3 (#0e9b52)
U 3 (#3086c1)
R 3 (#5a60c0)
U 6 (#53b6e3)
R 7 (#8117d0)
U 7 (#53b6e1)
R 3 (#2cb930)
U 3 (#1bffd1)
R 6 (#4539f0)
U 8 (#680411)
R 4 (#6032c0)
U 6 (#255061)
R 3 (#5562a0)
U 6 (#088071)
R 3 (#3bf2f0)
U 5 (#52bdb1)
L 6 (#070500)
U 5 (#69e001)
R 6 (#070502)
U 3 (#071051)
R 2 (#036000)
U 4 (#0ea8a1)
R 5 (#05e4d0)
U 3 (#674de1)
R 3 (#804250)
D 6 (#3ffca1)
R 4 (#23dcb2)
D 6 (#9f9841)
L 5 (#45f210)
D 9 (#15efc1)
R 5 (#45f212)
D 4 (#969551)
L 9 (#23dcb0)
D 2 (#41bea1)
L 4 (#2f2a32)
D 4 (#71ffd1)
R 3 (#5c0bb2)
D 7 (#6f3501)
R 4 (#2b0a72)
D 4 (#7b3571)
R 3 (#1c67d2)
U 11 (#42f011)
R 3 (#51ae62)
D 3 (#75fcf1)
R 3 (#1f4742)
D 4 (#2813f1)
R 4 (#3d1812)
D 2 (#2b1d01)
R 11 (#1eb302)
U 3 (#27b0a1)
R 4 (#227b20)
U 5 (#34b7e1)
R 10 (#201220)
U 7 (#0502f3)
R 4 (#5ab7f0)
U 4 (#0502f1)
R 4 (#5d09b0)
U 7 (#504a81)
R 7 (#1e8250)
U 3 (#715aa1)
R 6 (#26d290)
U 6 (#9a12f1)
L 3 (#18be90)
U 8 (#037d11)
L 5 (#647600)
U 3 (#40b983)
L 5 (#04e450)
U 3 (#9a9a43)
L 8 (#04e452)
U 6 (#8af153)
R 8 (#6cbc90)
U 4 (#04d121)
L 4 (#285292)
U 3 (#688d51)
L 6 (#176332)
U 4 (#400a91)
L 5 (#176330)
U 5 (#43def1)
R 2 (#285290)
U 2 (#3e0711)
R 3 (#7eb9c0)
U 7 (#36f611)
R 7 (#666af0)
D 7 (#381b31)
R 3 (#298922)
U 3 (#475671)
R 6 (#977c12)
D 4 (#602d01)
R 6 (#25b0c2)
D 6 (#7ede81)
R 3 (#1d58c2)
D 8 (#873523)
L 9 (#265ae2)
D 3 (#57d663)
R 7 (#1565c2)
D 8 (#06ed11)
R 4 (#a348c2)
D 2 (#06ed13)
R 8 (#12d052)
D 4 (#2d3741)
L 7 (#0ccfd2)
D 3 (#1fcd61)
R 4 (#39a4c2)
D 3 (#44f7f1)
R 6 (#5c3202)
D 8 (#2625c1)
L 8 (#2b08c2)
D 2 (#20d7e1)
L 2 (#67b892)
D 10 (#546471)
R 7 (#484ef2)
D 7 (#49bc91)
R 4 (#91aa72)
U 11 (#499591)
R 3 (#0048b2)
U 7 (#34a7a1)
R 7 (#514600)
U 8 (#1cdc43)
L 7 (#471470)
U 3 (#8c8393)
R 3 (#18a780)
U 5 (#8c8391)
R 3 (#4e6f80)
U 3 (#1cdc41)
R 8 (#428930)
U 5 (#5dcb51)
R 3 (#4b21e2)
U 4 (#0464b1)
R 9 (#850552)
D 8 (#464881)
R 7 (#543852)
D 3 (#2d3a11)
R 3 (#081b22)
D 5 (#0cc731)
R 7 (#6990e0)
D 3 (#79d7b1)
R 3 (#509520)
D 5 (#438571)
R 3 (#27d510)
D 3 (#30d2d3)
L 8 (#1b7a00)
D 5 (#8a0da3)
L 8 (#1b7a02)
U 5 (#027cb3)
L 7 (#350130)
D 8 (#2ff771)
R 7 (#16dc02)
D 2 (#68f1c1)
R 5 (#02f782)
D 6 (#4e2a41)
R 11 (#448e32)
D 5 (#2cfac1)
L 11 (#417502)
D 5 (#2cfac3)
L 4 (#22f022)
U 9 (#1e9f01)
L 5 (#543572)
U 3 (#076e31)
L 6 (#081b20)
U 5 (#1ae851)
L 3 (#823132)
U 9 (#2d7993)
L 4 (#5738f2)
D 8 (#79e273)
L 4 (#5c9ad2)
D 8 (#4ed1b3)
L 3 (#311722)
D 4 (#0d5493)
L 6 (#5d63e0)
D 6 (#178cf3)
L 5 (#75b1b0)
D 5 (#178cf1)
L 6 (#11d550)
D 6 (#44ed03)
L 3 (#76a842)
U 6 (#3b6993)
L 5 (#184892)
D 4 (#5c8163)
L 3 (#14d872)
U 2 (#261a01)
L 5 (#2d01e2)
U 9 (#326ca3)
L 4 (#59ad32)
U 8 (#326ca1)
R 4 (#389ab2)
U 9 (#261a03)
L 4 (#50cb42)
D 4 (#2f8263)
L 5 (#9f3752)
D 6 (#4bb383)
L 4 (#2693f2)
D 4 (#19dca3)
R 4 (#475bc2)
D 6 (#960e13)
L 7 (#0c90a2)
D 8 (#3463d3)
L 6 (#5a82e2)
D 3 (#5a5c43)
R 7 (#120bf2)
D 3 (#5069e3)
R 3 (#4b47a2)
D 6 (#635b63)
R 4 (#66ca10)
U 4 (#1418f1)
R 7 (#1d5470)
D 4 (#1418f3)
R 8 (#66d4f0)
D 5 (#3c5533)
R 4 (#2f6e02)
D 3 (#2cf5e3)
R 4 (#633ec2)
D 7 (#2cf5e1)
R 7 (#5846b2)
D 3 (#4f9d63)
R 4 (#533380)
D 11 (#13c7e3)
R 2 (#222b62)
D 3 (#928ab3)
R 5 (#222b60)
U 5 (#0a4793)
R 5 (#15d3b0)
U 8 (#363fe1)
R 4 (#2feb30)
U 5 (#05d8b1)
R 3 (#39e030)
U 3 (#05d8b3)
R 2 (#3cd780)
U 8 (#02c781)
R 5 (#186452)
D 3 (#37bba1)
R 5 (#9e1232)
D 5 (#58e6f1)
R 5 (#182c30)
D 5 (#072db1)
R 5 (#85e600)
D 4 (#607651)
R 5 (#186450)
D 3 (#0aca91)
L 5 (#0ceb10)
D 5 (#860001)
L 6 (#54c8b0)
U 5 (#393971)
L 4 (#37c390)
D 3 (#1f1433)
L 5 (#3d8790)
D 6 (#353623)
R 4 (#78c830)
D 4 (#6fafa3)
R 6 (#2b0612)
D 5 (#31fff3)
R 7 (#8b49b2)
D 9 (#6f0ee3)
R 5 (#4212e0)
D 6 (#5d11f3)
R 6 (#648340)
D 8 (#393743)
R 6 (#34ddd0)
U 8 (#346fb3)
R 5 (#34fc22)
D 4 (#71c453)
R 6 (#5048f2)
D 4 (#0bb993)
R 4 (#42b9f0)
D 9 (#5cdf83)
R 5 (#42b9f2)
D 3 (#6f3f93)
R 3 (#3dbae2)
D 8 (#495363)
R 9 (#328ba2)
D 3 (#77afa1)
R 5 (#575710)
D 2 (#10d861)
R 4 (#257822)
D 4 (#6efe61)
R 9 (#257820)
D 5 (#521d01)
R 5 (#575712)
D 6 (#494cf1)
L 5 (#683ab2)
D 4 (#5e79c3)
L 3 (#4242a2)
D 4 (#5e79c1)
L 7 (#2c3442)
D 8 (#2fbd23)
L 5 (#636fb2)
D 5 (#63bd53)
L 2 (#299960)
D 6 (#31ea33)
R 3 (#51dfb0)
D 7 (#4e4ec3)
R 4 (#7b7912)
D 5 (#4b4bf3)
R 4 (#54e882)
D 5 (#7d2193)
R 3 (#3b77d2)
D 3 (#826973)
R 8 (#646ec2)
D 4 (#076c63)
L 10 (#674052)
D 6 (#3676b1)
L 9 (#3bd890)
D 4 (#7feb71)
L 3 (#3bd892)
D 3 (#27fc21)
R 8 (#66bba2)
D 8 (#645c73)
R 5 (#43e132)
D 5 (#51d9e3)
R 8 (#43e130)
D 6 (#2827f3)
R 4 (#412c92)
D 5 (#7e7f63)
L 4 (#218122)
D 4 (#546e83)
L 9 (#82f672)
D 8 (#6ed383)
L 3 (#701412)
D 7 (#47de23)
L 5 (#46f912)
D 7 (#0d9ec3)
L 4 (#515142)
D 3 (#4699e3)
L 9 (#2ed562)
U 6 (#00a273)
L 9 (#8d7d12)
U 2 (#6c3a83)
L 7 (#318fa2)
U 7 (#0bd473)
L 2 (#6d5050)
U 10 (#415673)
R 3 (#9e8420)
U 6 (#1ff213)
R 5 (#0c8bf0)
U 2 (#479a11)
R 6 (#977360)
U 5 (#479a13)
L 8 (#250680)
U 2 (#1ff211)
L 3 (#216630)
U 3 (#22d143)
L 3 (#3b4342)
U 7 (#9d4ff3)
L 5 (#43aca2)
U 6 (#29efd3)
L 3 (#5c6a12)
D 11 (#134a73)
L 6 (#2a0982)
U 11 (#444723)
L 4 (#47e2e2)
U 4 (#6855c3)
L 4 (#06a382)
U 4 (#2222e3)
R 3 (#4edc62)
U 6 (#9a2683)
R 6 (#131872)
U 10 (#4f5a23)
R 4 (#858f70)
U 5 (#4d4823)
L 9 (#3f73f0)
U 3 (#46f5a3)
L 4 (#935370)
U 4 (#46f5a1)
L 5 (#3ca140)
U 6 (#07b1e3)
L 5 (#61ecd0)
U 5 (#654743)
L 5 (#3cec42)
U 6 (#30bb83)
R 3 (#920782)
U 6 (#1f9323)
R 8 (#3d8aa2)
U 8 (#7492c3)
R 3 (#301cd2)
U 3 (#32e2f1)
R 4 (#6936f2)
U 6 (#32e2f3)
R 6 (#5112c2)
U 7 (#535b53)
L 10 (#61f4d0)
U 3 (#915863)
L 2 (#51d540)
U 5 (#32dee1)
L 10 (#4ec320)
U 5 (#406bc1)
L 2 (#1b3890)
U 3 (#681181)
L 6 (#35ed60)
D 9 (#153fd3)
L 5 (#323e30)
U 5 (#381ad3)
L 3 (#69a550)
U 3 (#310f63)
L 4 (#2cbb80)
U 5 (#3448a3)
R 6 (#206282)
U 5 (#202ab1)
L 6 (#83af82)
U 4 (#202ab3)
L 4 (#248d02)
D 9 (#28a983)
L 4 (#32cf10)
D 7 (#249d73)
R 4 (#2f5c70)
D 6 (#021c93)
L 7 (#957782)
D 6 (#550e53)
R 5 (#957780)
D 6 (#50bb13)
R 9 (#49b7f2)
U 6 (#096e93)
R 4 (#769452)
D 3 (#6dc543)
R 5 (#2ad352)
D 7 (#167963)
L 10 (#673682)
D 5 (#152883)
L 10 (#13f332)
D 3 (#996721)
L 4 (#4be2a2)
D 4 (#9c2443)
L 4 (#2b83b0)
D 3 (#5d63b3)
L 9 (#9cfd40)
D 7 (#49e793)
L 7 (#0b5422)
D 8 (#5c51b3)
L 2 (#6db152)
D 4 (#215b53)
L 3 (#38dc12)
D 8 (#7dad01)
L 6 (#559e22)
D 3 (#929d23)
L 2 (#0f7560)
D 6 (#448d13)
L 7 (#73a972)
D 2 (#2221c3)
L 3 (#73a970)
D 5 (#53b553)
R 10 (#513590)
D 3 (#293c83)
L 10 (#58e2e0)
D 4 (#54dd21)
L 5 (#1bcdf2)
D 5 (#4b0b71)
L 5 (#1bcdf0)
U 6 (#43b811)
L 5 (#4df1d0)
U 6 (#36d6a3)
R 5 (#3bfb20)
U 5 (#75de61)
L 5 (#1e0ec2)
U 4 (#30b571)
L 7 (#2dfd20)
D 5 (#49ad61)
L 2 (#2dfd22)
D 11 (#715d41)
L 3 (#1e0ec0)
U 4 (#0f2091)
L 4 (#9d29c0)
U 9 (#475a73)
L 2 (#108610)
U 3 (#1e5423)
L 8 (#394192)
U 3 (#0274b3)

89
aoc2023/day18/main.go Normal file
View File

@@ -0,0 +1,89 @@
package main
import (
"bufio"
_ "embed"
"fmt"
"strconv"
"strings"
aoc "go.sour.is/advent-of-code"
"golang.org/x/exp/maps"
)
// var log = aoc.Log
func main() { aoc.MustResult(aoc.Runner(run)) }
type result struct {
valuePT1 int
valuePT2 int
}
func (r result) String() string { return fmt.Sprintf("%#v", r) }
func run(scan *bufio.Scanner) (*result, error) {
var vecsPT1 []aoc.Vector
var vecsPT2 []aoc.Vector
for scan.Scan() {
text := scan.Text()
if len(text) == 0 {
continue
}
v, color := fromLine(text)
vecsPT1 = append(vecsPT1, v)
vecsPT2 = append(vecsPT2, fromColor(color))
}
return &result{
valuePT1: findArea(vecsPT1),
valuePT2: findArea(vecsPT2),
}, nil
}
var OFFSET = map[string]aoc.Point[int]{
"R": {0, 1},
"D": {1, 0},
"L": {0, -1},
"U": {-1, 0},
}
var OFFSET_INDEXES = maps.Values(OFFSET)
func fromLine(text string) (aoc.Vector, string) {
v := aoc.Vector{}
s, text, _ := strings.Cut(text, " ")
v.Offset = OFFSET[s]
s, text, _ = strings.Cut(text, " ")
v.Scale = aoc.Atoi(s)
_, text, _ = strings.Cut(text, "(#")
s, _, _ = strings.Cut(text, ")")
return v, s
}
func fromColor(c string) aoc.Vector {
scale, _ := strconv.ParseInt(c[:5], 16, 64)
offset := OFFSET_INDEXES[c[5]-'0']
return aoc.Vector{
Offset: offset,
Scale: int(scale),
}
}
func findArea(vecs []aoc.Vector) int {
shoelace := []aoc.Point[int]{{0, 0}}
borderLength := 0
for _, vec := range vecs {
shoelace = append(shoelace, shoelace[len(shoelace)-1].Add(vec.Point()))
borderLength += vec.Scale
}
return aoc.NumPoints(shoelace, borderLength)
}

View File

@@ -0,0 +1,42 @@
package main
import (
"bufio"
"bytes"
"testing"
_ "embed"
"github.com/matryer/is"
)
//go:embed example.txt
var example []byte
//go:embed input.txt
var input []byte
func TestExample(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(example))
result, err := run(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 62)
is.Equal(result.valuePT2, 952408144115)
}
func TestSolution(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(input))
result, err := run(scan)
is.NoErr(err)
t.Log(result)
is.True(result.valuePT1 < 68834) // first attempt too high.
is.Equal(result.valuePT1, 46334)
is.Equal(result.valuePT2, 102000662718092)
}

17
aoc2023/day19/example.txt Normal file
View File

@@ -0,0 +1,17 @@
px{a<2006:qkq,m>2090:A,rfg}
pv{a>1716:R,A}
lnx{m>1548:A,A}
rfg{s<537:gd,x>2440:R,A}
qs{s>3448:A,lnx}
qkq{x<1416:A,crn}
crn{x>2662:A,R}
in{s<1351:px,qqz}
qqz{s>2770:qs,m<1801:hdj,R}
gd{a>3333:R,R}
hdj{m>838:A,pv}
{x=787,m=2655,a=1222,s=2876}
{x=1679,m=44,a=2067,s=496}
{x=2036,m=264,a=79,s=2244}
{x=2461,m=1339,a=466,s=291}
{x=2127,m=1623,a=2188,s=1013}

780
aoc2023/day19/input.txt Normal file
View File

@@ -0,0 +1,780 @@
ztj{s<2703:A,m<1025:vk,ztl}
nqt{a>3513:R,s>2424:R,m>929:R,A}
mr{s>2281:R,A}
gf{x>2746:R,a<3379:jcl,R}
gkv{x>2579:qlx,s>322:rxv,R}
gdl{x<2917:A,s>82:A,s<54:R,R}
hzc{m<1277:R,m>1355:A,x>953:A,R}
xs{x>2337:ft,m>1444:A,R}
hs{m<235:A,a<2424:A,x<3026:pvh,hqk}
cls{a<1361:zch,s<3630:tnh,a<2359:px,spb}
gq{m<1157:A,R}
hc{m<2726:A,s>1302:A,R}
lt{x>3157:A,a<3669:R,R}
sf{x<3199:R,s>2680:jrl,x>3718:jh,R}
hr{m>1737:A,A}
bgg{x<171:A,x<283:R,R}
pgb{m<1624:ksc,x>2675:bzc,bzn}
zm{m<2599:sjc,m>3497:A,m<2946:A,A}
gbb{x>860:bxv,a<2306:br,msc}
gsl{x>53:A,A}
zs{x<1669:kp,x<2690:ns,s>2951:cls,tvv}
qhq{x<1264:A,m<1728:A,R}
gg{s<239:A,s>340:R,x>3642:A,R}
ktx{m>2620:R,m>2073:R,a<3539:R,R}
xg{x<3497:fp,sgc}
pms{m<3366:R,x>3570:A,R}
gsb{x>2077:A,A}
xf{s>3779:A,R}
tfs{s>3844:rb,s<3703:scg,bk}
bgb{a>2837:R,a>2812:A,A}
nvk{s<2358:mr,x>2818:nqt,x<2757:lf,R}
fg{a>1961:A,x<68:R,R}
cfz{x>1567:A,m>951:A,a<2959:R,A}
ljt{m>950:A,m<557:R,m<745:A,R}
zcq{m>1403:th,fd}
tbv{a>1532:R,R}
dq{m>960:R,csz}
tvv{a<2619:zh,m>1623:kb,vh}
dzz{s>3136:R,s<2702:A,a>2889:R,R}
lg{a<66:A,s>784:A,s>263:A,A}
zfk{s<463:R,x>3180:A,R}
bdh{s>356:A,s>193:A,m>482:R,R}
tc{m>3454:R,x>3211:A,A}
tz{x>3191:R,a<1319:R,R}
cpn{m<2478:A,a<2228:A,a>3262:A,A}
qmt{x<2144:R,flt}
nsp{m<379:R,R}
sxt{s<1011:A,a>1135:A,rl}
bjg{m>973:lz,x>243:hh,a>1789:xl,xmg}
cj{x>2137:nst,m<3002:A,s>3193:jc,pfr}
lmc{a>2967:A,A}
tv{m>1493:A,m<769:A,R}
khc{m>2346:mbr,s>596:kvr,a<274:fzh,tb}
zbk{s>1140:qrt,x>1818:pv,a>540:gt,gxc}
kk{s>3728:R,s>3683:R,m<562:A,A}
jv{m<848:zpq,a>1225:fsv,ztj}
shb{a<242:A,m>2625:R,R}
fhg{m>1372:R,A}
dg{x>1246:qd,s<3289:lbf,a<1032:zzp,ks}
cfq{s>2689:A,s>2613:R,A}
gl{m>2798:cqm,s>3029:cnl,m>2233:A,qc}
tkv{m<1884:A,A}
fdm{m<1549:tgt,x<2498:kdf,s>528:jz,lt}
vx{x<2948:xc,mgp}
bs{m<687:A,R}
kp{x>609:dkr,tqc}
xpj{x<934:A,a>1772:A,A}
rhd{x>956:A,a<2471:A,a<3414:A,A}
srg{m>1381:A,s<264:A,A}
szv{s>453:mff,nzj}
ldl{a>3906:A,A}
rxv{m<1632:R,m>1700:R,R}
ch{s<3588:A,a<639:A,R}
sc{s>2789:A,a<1419:R,R}
gk{m>415:R,x>508:A,a<3053:R,R}
rs{s<1893:R,m>2997:R,x<2049:R,R}
ncn{s<722:R,m>3562:A,s>773:jm,vr}
kz{x>3160:A,A}
xxt{s>1035:R,a<942:R,R}
pfr{m<3520:A,A}
nh{a<638:mv,s>865:vm,nrf}
sg{s>3051:vps,m>2918:A,zhs}
xnj{x>3494:A,m>584:A,a<1897:A,R}
jg{s<2380:R,a<2211:A,A}
cqm{s<3107:R,a>3295:R,m>3224:R,A}
hgv{m<203:A,s>107:R,A}
vqt{x<2609:xkn,bnt}
ft{s>3154:A,m>1087:R,A}
qv{a>621:A,a>259:xp,m<2439:fbv,kpq}
lzv{x<2186:gpt,lsb}
lx{x>3655:A,s>2359:A,s>2271:R,R}
xfj{s<407:sxx,R}
tnh{x<3164:vx,js}
mbr{s<671:A,R}
tbn{m<2151:A,x<3001:R,R}
zhp{m<3768:fgp,x>3307:rv,kj}
qd{s<3201:A,s>3491:hgt,x>1468:A,R}
qdk{s<1950:R,R}
vn{s>2814:A,m>386:A,A}
lv{x>3090:A,s>2406:znh,R}
km{m>2029:A,m>1871:A,s<2456:A,R}
ppc{m>2718:R,x<2889:A,x>3361:A,R}
bk{a<3189:A,m>846:R,R}
ht{s>2582:jts,x<3333:hx,rgx}
bb{x<3122:A,x>3258:R,m>3625:A,A}
fd{m>650:R,x<450:A,a<2254:gb,gk}
dcf{s>1084:tzp,gbb}
pm{x>3659:A,m<3539:R,A}
hj{a>3260:hrn,A}
ds{m>767:A,m>718:A,R}
ccv{a<2781:R,a<2905:hd,s<1781:A,qdk}
vh{s<2473:lpg,m>643:cmn,s>2647:vkk,ht}
zld{x<3737:A,xst}
djf{x<748:R,R}
jfx{m>1768:gz,m>802:jfs,m<437:cl,snl}
vft{x<2121:dn,m<2486:kf,x<2180:qmt,vsj}
bc{m<369:hs,a<2050:dfd,m>584:mx,vqt}
dn{a<799:vbr,m<1868:A,s<1387:skb,rs}
kxl{a<1795:A,s>3664:A,s<3514:R,R}
bh{x>3971:A,R}
pv{x>1877:R,s<517:R,m>2313:R,A}
vzj{s<1879:cth,vc}
fc{a<2156:ths,zbc}
cs{a>2745:A,x>2067:A,s>2357:R,A}
nsj{a>2800:A,m<2010:R,R}
lsb{a>2810:R,x>2463:A,m>2877:R,bz}
nl{x<2336:A,x>2529:A,A}
pk{m<2800:A,s>3027:R,x<487:A,A}
bzn{m<1838:R,A}
qrt{s>1765:R,s>1529:A,s>1302:zdc,kzp}
srn{m<3131:zbr,a>3269:phc,x<2610:R,xd}
lz{m<1282:pzk,s>1085:gld,A}
spb{x<3144:krj,sx}
mqz{m>467:sm,m<282:R,s<969:hhs,jfp}
mff{s<632:A,x>625:R,dzt}
hgt{m<2577:A,s<3667:A,s>3805:R,R}
xpv{a<3077:R,R}
rf{m>3497:gv,a>334:vhk,A}
rsc{s>1811:A,jk}
vkl{a>1095:A,a<912:R,R}
mpn{a>3161:pdk,x>3461:zld,ff}
pzk{s>1180:R,m>1114:R,x>299:A,R}
vf{x<492:R,s<3334:R,R}
kjv{m<719:bc,vhc}
ks{m>2088:kxl,a>1906:ll,gq}
vm{m>1632:vb,qcr}
ph{a<2292:qzf,A}
xn{x<2461:qln,R}
px{a<1762:xg,x>3186:jfx,fc}
fzz{x<3174:mq,a>1103:nn,m<533:bgn,mdq}
xl{x>116:lmr,m<712:nvq,a>2807:jmf,R}
br{s>958:xxt,x<537:bnn,a<1228:R,ssr}
mcl{x>3441:R,s<2530:R,R}
gn{a<3598:R,a>3777:A,x>861:A,R}
scg{a>3029:A,s>3661:A,R}
kr{m<471:R,hz}
xfc{s>3354:R,R}
th{a>1860:vf,a>789:pk,mt}
nm{s<2242:A,x>3062:kz,R}
xp{m<2732:R,a<441:R,A}
fzh{a>101:A,x>3191:R,A}
bn{x<3725:R,a>499:R,R}
kmh{s>1727:A,a>1678:A,a<1550:A,A}
dj{m<2927:R,m>3578:A,x>1056:R,A}
jz{x>3123:A,a>3678:A,x>2902:R,R}
qq{m<3557:A,m>3852:A,a<1950:R,A}
nrv{m>1238:qcd,mqz}
pmd{x>3502:R,gdl}
ll{s>3570:A,s<3419:R,x>946:A,R}
td{x<1875:A,a>1161:A,A}
jt{m>1937:A,s<430:tkv,R}
pp{s<1233:mzr,m>2932:vsl,ccv}
ssr{s<903:R,R}
qcd{m>1677:R,R}
sv{x<3042:fv,s<3775:tc,m<3706:ct,dm}
qsg{x>3287:vvt,dbq}
cdt{x<3342:kx,a>1677:btj,nth}
jrl{m>1242:A,m>940:R,m<793:R,R}
dzt{s<732:A,A}
dk{m>1342:rmq,hdt}
rn{x<3645:A,R}
fx{s>1211:jpn,s>785:nrv,m<1357:pd,dcg}
nvh{a<2086:kmh,x<2940:A,m<2730:R,pms}
cb{x<581:sd,psf}
mq{m>678:A,x>2970:qf,a<881:A,ck}
qfn{s>298:A,R}
rss{s>1618:rsl,frj}
sp{x<3759:R,a>512:A,m>3807:R,R}
dns{m>270:A,x<2335:R,s>3567:R,R}
dsr{x<2503:R,m>969:A,x>3358:R,A}
jfs{s>3760:R,R}
zpq{x<2139:td,s>2466:nl,A}
vk{s<2893:A,a<803:A,s>2986:R,A}
rbn{a>3902:zp,m>472:A,R}
tvn{m<2544:R,A}
lqf{a<3601:rnx,a<3691:A,fz}
ls{m<1384:A,R}
rnk{a>3786:R,m<2367:A,zl}
pdk{x>3398:R,s>2636:tnq,a>3510:xt,km}
gm{x>1475:sg,zdv}
ps{s>2886:A,A}
ndh{a<979:fkj,a>1636:A,s>2743:tz,nf}
zhs{s>2501:R,a<3309:A,s>2306:A,R}
zht{a>1418:A,A}
fn{x>3198:A,a>3957:R,m>3278:A,A}
xc{m>1714:xfc,a>2574:cmr,A}
gld{m<1414:R,x<381:A,m<1444:A,R}
pz{m>3006:R,A}
fkp{a>3424:R,m<3526:A,A}
fqc{a<2473:tv,m>2350:cj,a<2565:xs,vv}
bnt{s>1011:R,x>3453:A,R}
xzq{a<3766:lqf,a<3888:kgd,s<1399:zmt,lp}
clh{a<1003:A,s>3818:A,ntv}
rq{s>2799:R,m<1088:A,A}
jfp{s<1113:A,R}
hh{x<466:A,R}
md{s>1194:R,R}
hm{a>1759:gsb,R}
vb{s>1454:A,s<1082:kxs,a>1134:A,hc}
rsl{a<3803:gh,st}
tjb{x>2545:A,x>1949:A,R}
zsp{s<3356:R,A}
bg{x>1362:A,R}
lbf{m>1460:A,mnr}
bt{s<856:R,s>1189:ppc,x>2845:R,R}
ct{a<1119:A,x>3291:A,m<3487:A,A}
drn{s>2455:R,x>3658:A,x>3401:R,A}
xst{m>2109:R,a>2952:A,a<2839:R,R}
pr{a>3195:xxm,R}
rnx{s<926:A,a>3544:R,A}
ngl{a<2849:kzb,x>1007:R,vq}
fhq{m<1694:R,m>3210:A,a>1513:A,A}
ttd{x>952:R,m>216:R,m>132:R,A}
tg{a>447:R,m<3009:R,s<3685:R,A}
cgl{x>2271:A,s>3239:R,s<2541:cs,A}
jh{a>3871:R,s<2611:A,R}
vlx{m>2576:A,a<3152:R,m>1231:A,R}
fh{s>1137:R,s<937:R,djf}
xz{x<2419:sl,x<3456:rt,m>3040:fs,crn}
pj{a<887:sq,s<3315:A,R}
kjt{m<990:hqc,nkr}
tb{m>1009:A,A}
ppm{a<1310:R,a<1850:R,a<2261:R,R}
jm{x<1054:R,a<579:R,A}
fsf{x<3020:R,R}
xxm{a<3299:R,R}
pvh{s>929:A,R}
bfx{a<3017:A,a>3351:gn,grz}
fp{x<2966:tbv,x<3308:R,R}
krr{x<677:tvn,A}
vdz{m<3388:R,x<844:A,R}
hzf{s>385:R,s<196:A,A}
jjf{x>3217:A,m<616:qfn,dr}
nq{x>2432:lg,m<1705:A,R}
cmn{a<3539:rtg,a>3754:sf,dv}
sq{a>365:R,m>2615:A,s>3324:A,A}
xqf{x<554:A,m>1924:A,x>1244:A,R}
gxc{a<350:A,s>506:fhg,vl}
qx{a<3727:A,R}
nzq{m<1027:R,s>1843:R,A}
rv{a<3212:R,x>3734:R,m>3888:tq,tn}
lrn{m>1353:kq,s<3039:jv,gx}
nf{m>2662:A,x<3529:A,m>2179:A,R}
zlz{a<750:mc,clh}
kf{a>756:A,R}
gj{m<1030:A,a>1937:R,R}
gb{s<3174:A,s<3470:A,A}
tnq{x>3001:A,R}
zqv{m>691:A,R}
kj{x<2954:psp,x>3147:mg,a>3127:mjb,A}
tgn{a>1711:lkc,s>541:qt,R}
npt{x<772:R,x>900:R,s<1084:R,A}
cx{x>3400:lxp,lbv}
vvt{s>278:R,A}
vqq{x<3192:R,A}
tq{s>2456:R,s<2301:R,x>3451:A,A}
xxx{m<2342:R,A}
dkr{a<2409:dg,m<1437:lvf,x>1274:gm,qdc}
fs{s>1657:pbv,m<3482:A,m>3677:R,R}
tpg{m<1159:A,x>3135:R,gmf}
qln{a<2906:A,a>2928:R,a<2918:R,A}
lvf{x<1270:bfx,x<1455:bzz,qk}
xlq{m<334:A,s>1515:A,A}
sx{m<1833:tfs,hf}
gpt{a>2836:zxd,a>2730:R,A}
krn{x>1155:ckd,s<1260:A,m>2770:A,zht}
sk{m>348:R,x>1377:A,m>153:A,R}
rl{a<984:R,R}
ntd{a<819:dns,qnm}
grz{x>890:A,a<3172:A,A}
kt{x>967:A,R}
qs{m<1546:A,R}
js{x>3672:qmv,a>2929:hdn,hcs}
bzz{m<647:sk,bg}
vv{s>2934:sj,R}
lbp{s>2775:R,R}
zxd{x>1854:A,R}
crn{s>1724:R,rn}
jc{x>1851:R,s<3672:A,m<3477:A,R}
xxh{m>1324:qqn,qm}
pn{s<976:A,m<2297:R,A}
fv{s>3818:A,s<3658:R,s<3743:R,A}
ck{x>2824:R,m<316:R,A}
vdp{x<3490:A,A}
xq{m>184:A,x>3334:A,A}
fz{m>3339:R,m>2690:R,x>2493:R,R}
jf{m<1773:R,x>659:R,A}
xd{a<3143:A,R}
svq{a<3528:A,R}
cl{x>3473:A,R}
qf{x>3076:A,R}
ktb{m<3197:A,s<704:R,s>1154:A,A}
gbj{m<158:R,m<302:R,m>336:R,R}
ff{s<2459:lmc,s>2743:R,nsj}
rcn{s>3821:R,x>2847:A,a<2261:R,A}
xkn{x>2134:R,x>1785:A,A}
pf{a>3576:A,s>3815:A,s>3737:R,R}
ntv{s<3659:R,A}
psf{m>575:R,a<2611:A,m>319:R,R}
fqz{a>3321:bx,vdp}
tzp{x<554:ph,a>2615:lm,krn}
pht{s>625:fh,x>606:ffn,sxb}
zz{m<1836:ql,s>1299:hp,m<3200:shb,A}
snl{s>3863:R,a<2001:xnj,kk}
qdc{a<3128:ngl,a>3442:rnk,x<874:zm,gl}
rsz{m>1017:R,x<2038:A,m<443:R,dzz}
frj{m>1063:md,a>3826:rbn,s>1317:lb,zkk}
bbt{a>3364:A,a<3152:R,R}
lpg{x>3231:fqz,x<2909:nvk,s<2283:nm,lv}
sd{s<1984:R,a>1624:A,m<729:A,A}
spq{x<3000:A,s>148:A,R}
fsv{s<2728:gj,m<1078:fpf,s>2917:R,R}
rmq{s<3098:A,x<182:fg,cpn}
msc{x>326:A,xxx}
drg{a>1618:hzf,s>486:zjl,a>619:hzc,A}
hx{x>3100:R,m<249:hnq,R}
ksc{a>3214:A,x>2913:R,R}
kxs{x<3497:R,s>949:A,A}
xv{s>311:A,R}
kd{x<3492:A,ppm}
st{s<1839:R,m>810:R,pgj}
ntb{m>3358:spq,m>2731:zhg,s<116:R,A}
lqz{a>3814:A,A}
fb{x>2177:tg,bjd}
dcg{a<3359:pgb,rch}
khp{a<2918:A,x>3796:R,m>378:R,A}
hhs{x<3165:A,R}
bnn{a<1158:R,x<228:A,A}
nx{m>469:R,x>3876:R,x<3760:A,A}
vl{m>1539:A,a>468:A,s>326:R,A}
qmv{s<3328:R,A}
rt{m<2818:fbx,R}
hcs{x<3425:zsp,mk}
mn{m<2363:A,R}
sm{m<839:A,x>2835:A,s>1035:A,A}
zn{x<2270:R,a>798:R,s>3678:R,A}
qqn{m>1794:jt,a<3748:fdm,gkv}
hdn{s>3198:A,s>3046:R,ngq}
mg{x>3205:R,s<2688:R,A}
sgc{x<3807:fhq,x<3919:A,bh}
qhl{m>2988:A,x>3259:drn,xpv}
zbr{x<2841:R,m>2724:R,R}
rjb{x>2706:R,R}
qp{m>1140:drg,tgn}
kkk{s>1408:vzj,m<1501:dnp,s<833:dmc,dcf}
cmr{a>3290:R,m>1084:R,m>506:R,A}
lbv{m<3300:R,a<923:A,s<2435:bb,qq}
mjb{m<3900:R,a>3686:A,R}
clg{s>1434:nvh,m>3229:rsh,bt}
hrn{a>3478:R,a>3380:R,m>1194:R,A}
zhd{s>1275:R,m>3076:R,m<2721:A,R}
hnq{x>2834:A,R}
tbt{x>3131:A,m<3435:R,A}
phc{a>3375:A,a<3306:R,A}
vq{x<800:R,s>2917:R,x<922:R,R}
kq{s<3392:sc,a>1260:hm,m>2319:fb,htk}
fbx{a>3317:A,m<2345:A,R}
cm{m<2219:R,m>2264:R,R}
csz{s>3528:R,A}
nst{x>2459:A,A}
lf{a<3121:R,x<2716:R,m<818:R,A}
xsp{x<2980:R,a>2817:A,A}
qm{x<2949:kr,x<3428:jjf,s<456:jtt,jqn}
qt{s<744:A,x<1059:R,s>816:R,A}
zc{x>3545:qx,a>3625:vn,A}
cxk{a>1449:ntt,s>1617:xbr,s>1504:R,xqf}
cg{x>2245:zx,x<1956:zbk,vft}
zkk{m<649:A,a>3680:R,R}
bx{a<3661:A,x<3529:A,a>3778:R,R}
mv{s>1300:rsc,khc}
qjt{x<3376:A,R}
mgp{x>3029:zq,A}
fpf{a>1769:R,x>2049:A,s<2923:A,R}
lhc{s>1662:A,m>1543:A,a<3599:tl,vfn}
mzr{a<2819:R,R}
psp{s<2611:A,a>3354:A,a>3056:A,A}
vc{m<1333:cb,mp}
bzc{m<1850:R,m<1953:A,R}
kb{m<2614:mpn,m>3380:zhp,gqd}
dv{a<3677:cfq,x<3383:R,s<2710:R,rq}
xh{s<2524:A,R}
vr{s>754:A,x<643:A,A}
sj{s<3498:R,s<3711:R,m<1518:A,R}
bq{a<1413:R,m>3189:A,a<1750:R,R}
bgn{m<197:A,m<353:gbq,xh}
jl{x>2858:R,m<476:R,R}
vbr{x<2055:R,m>2096:A,R}
ngq{a>3426:R,s<3009:A,a<3210:A,R}
krj{x>2852:pjd,gf}
dp{m>1430:A,A}
xkm{m<1913:kjv,vz}
vg{x>224:R,a>1513:A,m<323:A,R}
jmf{s<1182:A,a>3547:A,A}
vqr{a>3441:ljt,A}
ckd{m>3131:R,a<1567:R,m>2271:R,A}
bp{s>3270:A,s>3133:R,R}
pc{x>3663:A,m<491:R,A}
mx{m>663:bs,m<622:tjb,gkn}
qhh{x<1947:A,m>3589:A,R}
ths{a>2010:dp,R}
znh{m>662:A,x>2990:R,R}
fph{a>2941:R,s<1649:R,R}
nkr{x<1012:npt,m>1326:A,s>1224:R,R}
zbc{x>2881:R,x>2784:rcn,x>2722:xf,rjb}
hp{s>1600:R,s>1465:R,a>263:R,R}
kdf{s>420:R,m>1639:R,x>2176:A,R}
hkl{s<3823:bn,m>3668:sp,s>3936:A,A}
lp{m>3026:tbt,s>1876:R,bj}
zmt{a>3930:fn,a<3915:bcz,ktb}
jqn{a<3862:pc,m<761:R,a<3938:ldl,A}
hms{x>3072:A,s<1921:R,A}
sn{s>774:A,s>753:R,x>547:A,A}
kx{m>1998:tbn,A}
mqc{m<2308:A,m>3052:A,m>2635:R,A}
qdj{a>2946:zgm,a<2669:fqc,m>2271:lzv,ndr}
xt{a>3826:A,x<3063:A,A}
kvr{m>1390:R,x>3294:A,R}
hz{x>2278:A,x<1949:A,A}
fkj{x<3168:A,s<2741:R,R}
tn{m<3831:R,s>2560:R,A}
zjl{s>694:R,R}
ndr{a<2827:cgl,x<2240:rsz,xn}
btj{m<1813:qs,m<2042:jg,cm}
bjd{x<1891:A,s>3600:A,A}
gjg{m>2075:rjd,a<3588:fx,s<809:xxh,rss}
zch{s<3538:hl,m<2003:zlz,dz}
nrf{s>428:vkl,s>146:qsg,a>957:pmd,dxn}
vhc{s>1085:tpg,jxf}
lb{m<643:xlq,a>3717:svn,m>911:dsr,ds}
zdc{x>1803:R,A}
bzj{s>3689:A,m<2560:R,R}
flt{s>1360:A,x>2163:A,A}
qg{s>1039:A,A}
dm{m<3816:A,s<3853:R,A}
xmg{m>752:A,x>137:jzj,gsl}
bcz{a<3903:R,R}
lkc{a>3188:A,m<900:A,m>1018:A,R}
jxf{s<527:srg,A}
gx{m>486:dq,ntd}
bd{s>2400:A,x>3671:A,s>2281:R,A}
qc{s<2673:R,A}
lm{a<3182:dj,a>3635:lqz,a>3407:R,R}
qnm{m<247:R,a>1687:R,m>389:A,A}
zq{s>3263:R,s>3111:R,R}
mk{s>3246:A,m>2016:R,s<3088:A,R}
rql{a<3077:xsp,s>2761:jl,s>2722:R,A}
vj{s<2785:ndh,kd}
in{s>2178:zs,skv}
xrc{s>712:sn,A}
jp{a<2589:R,A}
pgj{a>3929:R,x>2479:A,A}
jts{x>3530:R,A}
gv{s>3739:A,R}
mnr{s>2737:R,A}
tgt{m>1439:R,s>292:R,A}
xvs{a<2848:A,A}
vps{a>3227:A,x<1588:R,A}
jzj{m<672:A,s<1122:R,R}
zzp{x<901:ch,R}
sl{s>1542:A,s>1296:R,x>1931:A,zxz}
rjd{a>3500:xzq,s<1086:qj,xz}
kgd{s>1426:A,a>3812:A,R}
dmc{m<2947:szv,kqx}
hbk{m<3419:A,R}
htk{a<729:R,a>1042:A,a>861:R,zn}
zp{s<1255:A,A}
qlx{m>1631:R,x>3329:R,R}
skv{x<1606:kkk,a<1440:ggv,a<3018:xkm,gjg}
zl{m>3149:A,a>3596:A,R}
sjc{m>2149:A,A}
ggv{x>2600:nh,cg}
pd{a<3356:pr,x<2700:xfj,a<3465:zbd,xv}
vhk{a<614:A,a>735:A,m>3340:A,R}
bz{x<2317:R,s<3304:A,A}
zbd{m>889:zfk,bdh}
vsj{a<598:zhd,R}
qzf{a>1455:R,x>340:A,s<1196:R,R}
dz{m<3157:qv,x>3473:hkl,a>877:sv,rf}
rtg{a>2957:R,A}
qk{a>3252:svq,s>3213:R,m>548:cfz,R}
zx{a>871:sxt,a>314:mn,a>186:zz,nq}
kcd{x<2880:R,s>94:R,R}
hqc{m<796:R,m>890:rhd,a<2192:A,xvs}
ffn{m>350:jp,a<2088:ttd,a>2817:R,R}
sz{m<1599:R,x>2121:ktx,m<3075:bbt,qhh}
jtt{a<3836:zqv,m<876:gg,A}
lmr{a<2718:A,a<3149:R,R}
zdv{s>3010:R,lr}
jcl{m<1659:A,R}
mdq{a<479:R,A}
dnp{m<537:pht,s<885:qp,x<582:bjg,kjt}
lxp{m>2932:A,lx}
kqx{s<513:hbk,a<1592:ncn,a>3119:xrc,kt}
cnl{x<1035:R,m<2338:A,R}
mp{m<2347:xpj,a>2221:vdz,bq}
rgx{s<2542:R,R}
rb{s<3903:A,A}
jk{m>2376:R,x>3391:R,m<1198:R,R}
zgm{s>3092:bzj,sz}
gt{a>1014:R,m<2365:ls,R}
jpn{s>1819:hj,a>3326:vqr,ljm}
nzj{s>254:R,m>2156:R,x<991:jf,qhq}
gh{m>856:A,nsp}
kpq{a<110:A,x>3312:R,x<3090:R,R}
hl{x<3177:pj,bp}
gs{a<180:R,s>3703:R,R}
gz{m>3188:R,R}
lft{s>2829:ps,gbj}
kzb{m>2754:A,a<2674:A,A}
vz{a>2453:pp,clg}
tqc{x<360:dk,zcq}
bxv{a<2317:A,m<2884:pn,fkp}
ztl{a<590:R,x<2295:R,x>2529:R,R}
vkk{a>3382:zc,x>3140:xrl,m<384:lft,rql}
fbv{s<3805:R,s>3881:R,a>172:R,R}
gbq{m>279:A,x<3717:R,x<3898:A,R}
svn{s<1485:R,A}
skb{s>589:R,s>295:R,x>2063:A,A}
mc{a>272:A,x>3488:gs,s>3786:A,fsf}
pbv{x<3811:R,a>3290:A,m<3444:R,A}
gkn{s<1377:A,A}
nth{a<1084:bd,A}
vsl{a<2799:A,a<2901:bgb,fph}
lr{x<1407:A,s>2654:R,s<2373:A,R}
dbq{m<1824:R,s>291:R,A}
hdt{s>3011:R,s>2681:A,bgg}
nvq{m>597:R,x>47:R,A}
qj{s>674:pz,s>313:srn,ntb}
fgp{a>3257:R,mcl}
pjd{s<3848:vlx,A}
gmf{s<1729:A,A}
kzp{x>1746:A,x>1670:A,m>2460:A,A}
tl{m<888:A,m<1289:A,R}
zh{m<1334:fzz,s>2674:vj,m<2347:cdt,cx}
ql{s<1432:A,a>258:R,A}
rch{s<485:R,vqq}
hf{a<3208:R,pf}
bj{x<2870:R,m<2489:A,R}
zhg{x>3190:A,s>144:R,m<2941:A,R}
rsh{x<3060:R,a<1833:pm,R}
ntt{a>1930:R,a<1611:A,A}
hd{s>1811:A,R}
dfd{x<2726:A,qg}
gqd{a>3471:qjt,qhl}
xrl{x>3598:khp,m>284:lbp,m<100:R,xq}
zxz{m<2818:A,R}
vfn{s>1502:R,x>955:R,s>1440:A,R}
dr{s<370:A,x>3070:R,R}
cth{a<2210:cxk,a>3174:lhc,krr}
xbr{m<1775:R,m>3200:A,A}
nn{m>718:R,x>3641:nx,A}
dxn{s<55:hr,x>3309:A,a<824:kcd,mqc}
mt{a<423:R,a>555:R,R}
hqk{a>2663:A,s<888:R,a<2564:R,A}
ns{a<2307:lrn,qdj}
sxb{s>318:vg,hgv}
ljm{s<1457:A,m>763:A,s>1648:R,A}
qcr{s<1460:R,m<548:hms,a>1054:A,nzq}
sxx{a>3455:A,R}
{x=378,m=450,a=211,s=36}
{x=220,m=1090,a=338,s=879}
{x=117,m=124,a=2136,s=128}
{x=1392,m=1408,a=126,s=16}
{x=2038,m=278,a=901,s=1801}
{x=323,m=1703,a=964,s=571}
{x=265,m=358,a=456,s=34}
{x=1513,m=144,a=525,s=1341}
{x=355,m=2036,a=814,s=1179}
{x=937,m=701,a=2026,s=1349}
{x=1292,m=766,a=2805,s=16}
{x=319,m=26,a=83,s=1193}
{x=600,m=5,a=242,s=76}
{x=117,m=1415,a=1636,s=1057}
{x=87,m=1530,a=1686,s=386}
{x=36,m=957,a=1712,s=300}
{x=2570,m=49,a=661,s=442}
{x=643,m=698,a=1593,s=854}
{x=1450,m=1410,a=289,s=1342}
{x=1690,m=376,a=584,s=3715}
{x=1942,m=570,a=1726,s=1192}
{x=420,m=475,a=1410,s=863}
{x=550,m=662,a=2140,s=105}
{x=241,m=2370,a=756,s=26}
{x=705,m=425,a=1000,s=160}
{x=1763,m=914,a=197,s=555}
{x=2267,m=323,a=70,s=147}
{x=497,m=392,a=1959,s=360}
{x=428,m=1375,a=415,s=236}
{x=1800,m=96,a=403,s=1227}
{x=216,m=381,a=1217,s=1031}
{x=3129,m=304,a=811,s=1753}
{x=555,m=59,a=3254,s=2896}
{x=397,m=1518,a=740,s=496}
{x=905,m=217,a=1234,s=2319}
{x=283,m=2490,a=309,s=1156}
{x=1777,m=624,a=96,s=2053}
{x=1031,m=481,a=1014,s=198}
{x=155,m=205,a=2460,s=832}
{x=123,m=25,a=3962,s=3662}
{x=3242,m=396,a=519,s=150}
{x=2632,m=1307,a=3594,s=1714}
{x=147,m=285,a=1020,s=40}
{x=1498,m=1133,a=241,s=1263}
{x=1977,m=323,a=1594,s=241}
{x=807,m=1042,a=702,s=295}
{x=70,m=455,a=1328,s=108}
{x=2392,m=27,a=158,s=44}
{x=528,m=671,a=2003,s=935}
{x=1539,m=2002,a=168,s=479}
{x=2121,m=195,a=901,s=1116}
{x=251,m=51,a=380,s=745}
{x=793,m=1959,a=598,s=605}
{x=137,m=261,a=714,s=1548}
{x=2783,m=486,a=2065,s=914}
{x=574,m=387,a=250,s=28}
{x=3,m=829,a=1862,s=2}
{x=846,m=2476,a=841,s=1810}
{x=1020,m=114,a=463,s=323}
{x=4,m=970,a=192,s=142}
{x=942,m=2297,a=125,s=1638}
{x=1664,m=2275,a=2086,s=290}
{x=682,m=93,a=143,s=2033}
{x=1613,m=356,a=463,s=632}
{x=633,m=268,a=150,s=798}
{x=1743,m=1455,a=56,s=487}
{x=2774,m=103,a=739,s=77}
{x=1760,m=2631,a=81,s=138}
{x=461,m=1688,a=1543,s=1712}
{x=1182,m=14,a=566,s=3270}
{x=680,m=467,a=1920,s=297}
{x=1281,m=2355,a=704,s=1340}
{x=142,m=65,a=589,s=20}
{x=1412,m=559,a=677,s=2106}
{x=905,m=2761,a=1526,s=648}
{x=399,m=667,a=1901,s=27}
{x=2241,m=3411,a=1786,s=321}
{x=1395,m=1278,a=508,s=1112}
{x=363,m=35,a=218,s=1280}
{x=829,m=115,a=304,s=192}
{x=1397,m=599,a=861,s=838}
{x=824,m=2140,a=88,s=1736}
{x=661,m=276,a=502,s=731}
{x=585,m=14,a=705,s=473}
{x=747,m=95,a=829,s=805}
{x=2006,m=323,a=982,s=168}
{x=795,m=193,a=473,s=1531}
{x=687,m=428,a=972,s=1154}
{x=254,m=426,a=281,s=552}
{x=171,m=369,a=382,s=1369}
{x=964,m=10,a=322,s=2007}
{x=1960,m=183,a=2153,s=1967}
{x=2315,m=170,a=41,s=727}
{x=189,m=901,a=307,s=3026}
{x=757,m=1235,a=1316,s=335}
{x=836,m=3023,a=453,s=2355}
{x=2187,m=2140,a=683,s=2560}
{x=1772,m=468,a=1812,s=1329}
{x=783,m=601,a=1339,s=3291}
{x=570,m=172,a=1794,s=120}
{x=1207,m=1572,a=700,s=758}
{x=1961,m=3652,a=702,s=153}
{x=1094,m=435,a=19,s=938}
{x=3328,m=166,a=247,s=216}
{x=1500,m=2012,a=1561,s=59}
{x=12,m=2269,a=8,s=796}
{x=193,m=1137,a=328,s=13}
{x=120,m=1179,a=59,s=1829}
{x=499,m=650,a=1049,s=1803}
{x=2761,m=1431,a=389,s=1322}
{x=456,m=2766,a=2165,s=348}
{x=2387,m=12,a=2140,s=556}
{x=387,m=7,a=1514,s=1137}
{x=1111,m=608,a=581,s=965}
{x=1055,m=181,a=754,s=67}
{x=74,m=2582,a=66,s=546}
{x=5,m=956,a=1013,s=657}
{x=262,m=189,a=2496,s=233}
{x=518,m=2821,a=851,s=825}
{x=351,m=1981,a=221,s=34}
{x=995,m=165,a=36,s=2286}
{x=1636,m=335,a=936,s=447}
{x=763,m=692,a=1527,s=210}
{x=301,m=559,a=1815,s=2640}
{x=959,m=2852,a=232,s=53}
{x=136,m=153,a=206,s=11}
{x=1533,m=42,a=2014,s=136}
{x=341,m=378,a=37,s=577}
{x=220,m=1451,a=185,s=421}
{x=1086,m=3265,a=1184,s=2960}
{x=143,m=2701,a=602,s=173}
{x=628,m=1016,a=1642,s=223}
{x=597,m=641,a=1331,s=651}
{x=809,m=1843,a=1111,s=2189}
{x=1385,m=1352,a=238,s=1969}
{x=515,m=1374,a=125,s=913}
{x=798,m=2743,a=1798,s=1045}
{x=2999,m=1787,a=1168,s=188}
{x=57,m=77,a=2652,s=56}
{x=1231,m=304,a=1288,s=523}
{x=1031,m=381,a=558,s=267}
{x=721,m=883,a=2995,s=22}
{x=304,m=846,a=1525,s=30}
{x=446,m=2969,a=412,s=674}
{x=187,m=418,a=1187,s=571}
{x=810,m=515,a=819,s=1393}
{x=740,m=3392,a=1128,s=1114}
{x=137,m=631,a=1208,s=1707}
{x=653,m=2468,a=952,s=811}
{x=33,m=70,a=518,s=464}
{x=3318,m=2,a=3661,s=64}
{x=50,m=548,a=1657,s=704}
{x=2272,m=2684,a=1597,s=2220}
{x=185,m=339,a=460,s=517}
{x=8,m=1651,a=1810,s=354}
{x=548,m=833,a=1703,s=759}
{x=551,m=358,a=390,s=468}
{x=202,m=2260,a=597,s=632}
{x=453,m=1811,a=754,s=2449}
{x=353,m=101,a=1835,s=72}
{x=1451,m=453,a=162,s=13}
{x=125,m=2120,a=627,s=981}
{x=5,m=283,a=1755,s=194}
{x=973,m=835,a=62,s=1184}
{x=346,m=1348,a=442,s=210}
{x=4,m=1242,a=136,s=196}
{x=2388,m=1336,a=1991,s=2873}
{x=561,m=2335,a=1059,s=627}
{x=838,m=3226,a=159,s=1053}
{x=2578,m=49,a=1920,s=2432}
{x=710,m=342,a=182,s=534}
{x=1997,m=1509,a=946,s=1849}
{x=810,m=249,a=495,s=257}
{x=363,m=274,a=2742,s=25}
{x=506,m=565,a=2584,s=731}
{x=508,m=2073,a=21,s=1826}
{x=1413,m=780,a=779,s=378}
{x=1097,m=47,a=98,s=402}
{x=536,m=2,a=2710,s=1499}
{x=548,m=2845,a=2095,s=555}
{x=2963,m=2206,a=1920,s=875}
{x=1783,m=367,a=1245,s=594}
{x=409,m=18,a=408,s=119}
{x=1554,m=3613,a=3002,s=87}
{x=232,m=197,a=63,s=1372}
{x=412,m=1355,a=1673,s=1667}
{x=261,m=142,a=123,s=1187}
{x=1396,m=779,a=287,s=60}
{x=28,m=1350,a=585,s=861}
{x=1123,m=329,a=1166,s=62}
{x=2292,m=73,a=123,s=596}
{x=2400,m=1430,a=390,s=1313}
{x=638,m=2856,a=44,s=488}
{x=294,m=1534,a=1075,s=1914}
{x=1233,m=71,a=253,s=3058}
{x=1536,m=805,a=158,s=738}
{x=2903,m=119,a=2344,s=2387}
{x=142,m=1768,a=940,s=881}
{x=301,m=2748,a=739,s=766}
{x=127,m=18,a=141,s=1398}

255
aoc2023/day19/main.go Normal file
View File

@@ -0,0 +1,255 @@
package main
import (
"bufio"
_ "embed"
"fmt"
"strings"
aoc "go.sour.is/advent-of-code"
)
// var log = aoc.Log
func main() { aoc.MustResult(aoc.Runner(run)) }
type result struct {
valuePT1 int
valuePT2 uint
}
func (r result) String() string { return fmt.Sprintf("%#v", r) }
func run(scan *bufio.Scanner) (*result, error) {
var workflows = make(map[string][]rule)
var parts []part
for scan.Scan() {
text := strings.TrimSuffix(scan.Text(), "}")
if len(text) == 0 {
continue
}
// Is Part
if p, ok := scanPart(text); ok {
parts = append(parts, p)
continue
}
if name, r, ok := scanRule(text); ok {
workflows[name] = r
}
}
var result result
result.valuePT1 = solveWorkflow(parts, workflows)
result.valuePT2 = solveRanges(workflows)
return &result, nil
}
type part struct {
x, m, a, s int
}
func (p part) String() string {
return fmt.Sprintf("{x:%v m:%v a:%v s:%v}", p.x, p.m, p.a, p.s)
}
func scanPart(text string) (part, bool) {
var p part
// Is Part
if text[0] == '{' {
for _, s := range strings.Split(text[1:], ",") {
a, b, _ := strings.Cut(s, "=")
i := aoc.Atoi(b)
switch a {
case "x":
p.x = i
case "m":
p.m = i
case "a":
p.a = i
case "s":
p.s = i
}
}
return p, true
}
return p, false
}
type rule struct {
match string
op string
value int
queue string
}
func scanRule(text string) (string, []rule, bool) {
name, text, _ := strings.Cut(text, "{")
var r []rule
for _, s := range strings.Split(text, ",") {
if a, b, ok := strings.Cut(s, "<"); ok {
b, c, _ := strings.Cut(b, ":")
r = append(r, rule{
match: a,
op: "<",
value: aoc.Atoi(b),
queue: c,
})
continue
}
if a, b, ok := strings.Cut(s, ">"); ok {
b, c, _ := strings.Cut(b, ":")
r = append(r, rule{
match: a,
op: ">",
value: aoc.Atoi(b),
queue: c,
})
continue
}
// default queue comes last
r = append(r, rule{queue: s})
break
}
return name, r, len(r) > 0
}
func (r rule) Match(p part) bool {
var value int
switch r.match {
case "x":
value = p.x
case "m":
value = p.m
case "a":
value = p.a
case "s":
value = p.s
default:
return true // default to new queue
}
if r.op == ">" && value > r.value {
return true
} else if r.op == "<" && value < r.value {
return true
}
return false // no match
}
func solveWorkflow(parts []part, workflows map[string][]rule) int {
// var rejected []part
var accepted []part
for _, p := range parts {
workflow := "in"
nextStep:
for workflow != "" {
for _, r := range workflows[workflow] {
if !r.Match(p) {
continue
}
workflow = r.queue
if workflow == "A" {
accepted = append(accepted, p)
workflow = ""
break nextStep
}
if workflow == "R" {
// rejected = append(rejected, p)
workflow = ""
break nextStep
}
continue nextStep
}
}
}
sum := 0
for _, p := range accepted {
sum += p.x
sum += p.m
sum += p.a
sum += p.s
}
return sum
}
func solveRanges(workflows map[string][]rule) uint {
pq := aoc.PriorityQueue(func(a, b *queue) bool { return false })
pq.Insert(&queue{
"in",
block{
ranger{1, 4000},
ranger{1, 4000},
ranger{1, 4000},
ranger{1, 4000},
}})
var accepted []block
// var rejected []block
for !pq.IsEmpty() {
current := pq.ExtractMin()
for _, rule := range workflows[current.name] {
next := &queue{name: rule.queue, block: current.block}
switch rule.match {
case "x":
current.x, next.x = split(current.x, rule.value, rule.op == ">")
case "m":
current.m, next.m = split(current.m, rule.value, rule.op == ">")
case "a":
current.a, next.a = split(current.a, rule.value, rule.op == ">")
case "s":
current.s, next.s = split(current.s, rule.value, rule.op == ">")
}
switch next.name {
case "R":
// rejected = append(rejected, next.block)
case "A":
accepted = append(accepted, next.block)
default:
pq.Insert(next)
}
}
}
var sum uint
for _, a := range accepted {
sum += uint((a.x[1] - a.x[0] + 1) * (a.m[1] - a.m[0] + 1) * (a.a[1] - a.a[0] + 1) * (a.s[1] - a.s[0] + 1))
}
return sum
}
type ranger [2]int
type block struct {
x, m, a, s ranger
}
type queue struct {
name string
block
}
func split(a ranger, n int, gt bool) (current ranger, next ranger) {
if gt { // x > N => [0,N] [N++,inf]
return ranger{a[0], n}, ranger{n + 1, a[1]}
}
// x < N => [N,inf] [0,N--]
return ranger{n, a[1]}, ranger{a[0], n - 1}
}

View File

@@ -0,0 +1,41 @@
package main
import (
"bufio"
"bytes"
"testing"
_ "embed"
"github.com/matryer/is"
)
//go:embed example.txt
var example []byte
//go:embed input.txt
var input []byte
func TestExample(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(example))
result, err := run(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 19114)
is.Equal(result.valuePT2, uint(167409079868000))
}
func TestSolution(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(input))
result, err := run(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 377025)
is.Equal(result.valuePT2, uint(135506683246673))
}

11
aoc2023/day21/example.txt Normal file
View File

@@ -0,0 +1,11 @@
...........
.....###.#.
.###.##..#.
..#.#...#..
....#.#....
.##..S####.
.##..#...#.
.......##..
.##.#.####.
.##..##.##.
...........

131
aoc2023/day21/input.txt Normal file
View File

@@ -0,0 +1,131 @@
...................................................................................................................................
.#.......#..#...#.......#......#....#..#...#...#....#.#..........................................#...............#..........#......
.............##..................#......#.#....#.......................##..#........................#......#..........#............
......#..........................#....#.....#.............#................##....#.#.............#.........#.##...........#........
.#................#............................#...........................#..##.....#..................#..##..#.#.........##......
.....#.............#.....##.............##..........#...........#.............#.....#...........#.#.......#....#......#..........#.
........#....................#....#.#.#......##........#...........#...........#..........#...#..........#......................#..
.........#.#...#.......#........#........##...#...#..##........................................##...#.#........................#...
......#.....#..#..#.#..#..............#...#..#.....#...........#.....#........#.#...........#...........#.#...............#.....#..
...........#.......####..#.#..............##................#.#.#.....................##.....................#...#..............#..
......###...#......#................##...#...#....#...........#...#..............#.........#..#..................................#.
...............#..##..........#...........................##......#.##.........................#..#.#...........#.#...........#....
...##........#...#...#...##...##...........#..#...................#...................#.#..#.........#.......#..#...........##...#.
................#.....#..##......#.....#.....##............#..#..........##...........................#.#.......##.....#.....#.....
.#..#.......#.#...#..##.....#............................#......#...#....#................#.#..#.....#.......##................#...
...............#.....#........................#..........#.....#..............................................#..................#.
.....#......#..........................................#....................................#..#.......#.#..#......#.#....#..##....
............##............#.......###.......................#..#....#......................................#..#.........#..........
..#...............#.....#...#...#......................#...#.#..............................#.#..#.#.....#.#.#..#....#.....#...##..
.#.............................##.................#.......#.......##....#....................#.....#.#........#.....#........#.....
.#....##...................##.....#.#..............#.#....#....#..#....#......#..........#.....##............#....#.............##.
.........#....#.....#..#.........#....#.#..........#...#...#.......#....#..##.......................#.#..#........#..#....#..#.#...
..#..................#.......#..#.#..............##.......#........#..............#.........#..#....#......#..#..........#.........
........#.....#......#.....#......#...#.......#....#.......#.#..#................#....................##.............#.......#.....
..#.................#..............#...........................................#.....#..................#...#.#..................#.
.......#......#.....#...........................#.....#..................#.....................#.....#.#......#........#.#.......#.
..#.#.#...................#...#..#................#....#.......#......................#...............#.........##...#.#.....###...
.....#...#....##....#........####...........#.................#...#...........................................#..............##....
..##.#..#.#..........#.#.#..#................................#..#.............#..#......#...........................#.##...........
..............#.............................##........#..##........................#.............................#........#........
........#.........#........#..#........#..#........#...#.#........#...........#.........................#.#..........#...#......#..
.........##.....#........#.....................#..#.............#.....#........#....................#....#.#.#......#.....#........
......................#...................####..#.........#....#.........#...........#..................#..#.................#.....
..#.........#...#.....##................##.##....#.....#....#..............................#..#.............#..#...................
..........##......#..#..............#.#....#......#................#.....#....#..............#..................#..................
.#.#..####...#....................#.#.#.....#...#...................#....#.#.....#.#.......#.#...........#......#.#................
.......#.........#..#.#..............###.......#....#.........................#.......#.###...#............#....#.#..#....###.#....
........#....#...#......#.................#..........................#.........................#...........##.............#.#......
.#..............#.....................#......#.............##............#..#..........#...................#...#....#..............
......#..#..#.#...............#........###.......#.#...........#...........#.#.........#..#.....................#......#..#.#......
.....#...............#.........#....#..........#.......#.......#......#...#..##.....#.....#........#.#.......#.......#..#...#......
..#............#.....................#...#.......#....###...........#.....#.#.................#................#.........#..##.#...
..............................#.....#..................................#.....##...............#.......#.........#.....#....##......
..#...##...#...#..............#.................##..#......#.................#....#......#...#...#......#..........................
.........#....#..............#........#..#...............#....#...#.....#..#......#.........#.......#.#..#........#...........#....
........#..#....................#.........#...##.#.#..............#......#.#..........##...##....#......................#..........
.##..#....#....#.......##......#............#..#......#.....##..................#####..#...#......#.#...#..........#.#.....#..#....
..#...........#....................#.......#......#.........#...............#......#........##........#.................#.....#.#..
..#....#.#...............#.#.........................#.............####..............................##................###.........
.....#.......................................#....#...##...#.......#.......#.....#.##..##.................#.....................##.
.........#...........#..#..##.#..........#..#.........#..#.....#...................................##....#...............#..#.#....
.....#..#...........##............#........#..................#............#..........#..........#..#...........#..................
............................#.........#...............#..................#.#....#.#..#........#.....#...........#...........#......
................#...##.#....#..##..........#.#........##.#..#..#.....................#....#.................#.#...............#....
.#.....#..............#.#..........#..#........#...............#..#.#..##..#.#.#.........................#.................#.......
....#..............#................#.....#..#.......#..#.#.........#..........#..........#.....#..........##.....#............#...
..............##...........#.......#......#..................#.......#.....#.#...#...............#.#........#......#............#..
................#.....#....#........#....#.......#.#.##.....#...#..#.##...#................#.#.....#....#.............#............
...........#.#.##..####.....#....#.#...#.#...........#...#.......................#.#....#.....#..#................###..............
...................#....#..........#.#..##.....#..#..#......###............#..#...........#....#......#............................
...........................................#.......#..............#.##.......##.......#...#.....#.#..#.....#..###..................
............###........#.......#.#....#.....#....#..#........#.........##....#.....#..........#......#............#..#.#...........
............#..........#................##.#..............#.....#................#....................................#..#.........
...........#.....#.....................#...#.....#.......#..........#....#.....###.....##.#.##.#.....#......#......#.......#.......
.....................#..#.....#...##.....#..#...........#....#....##............##.................##............##................
.................................................................S.................................................................
........#.#........#..........#.....#......#........#.#............#.#.........##...#............#...#.....#...........#.....#.....
..................##.......#......#..#..................#..##......#.........#...#.........#............#....#...........##........
..................#...........#.##.......#..............#....................#.#....#...##...#.....#.......#..#.....##.............
...........#....#....##...#................................#.........#.................#....#.......................#...#..........
.............#.#.#.....#.#...#.......#.#...........#....#.#.........#........##......#.......#.......##...#..........#.##..........
...........##.#....#....#..#.....#...............#......................#...........#.....#...........#.#.......#..................
.#.......................#.#...##.#....#.#...........#.#....##.##......#........................##....#.#....#.....................
...#..................#.#...........##....###.................#....................##......#.....#............#.##....#.......##...
.#..................####...#.#..#.##.#...####...#......#....................#..........................#....#......................
.....#..........#.....#.#...............#.........##...#......#.#.....#...........#.....#............##......#.....#...............
......#........#....#..#............................###.#...##........#........#.................#..#........#...............##....
......................#.........................##....#...#..............#..#............#.#....#......##.#......#.........##......
..................#....#...#.#.......#..............#..#..#...#.......#...#.....#.....#...............#.#.#...............#........
...#...##......................##..##...........#......#.............#............#...........##.......#....#......................
.............................##...........##...#...#.....#....#.......#.#..#.....##...............#..#.#......#..............##....
...#..#.#...#.......#..................#............#....#.#.##.#.........#......#........#..#..........#....##...........#....#...
.....#.............................#......#.#.....#.##.#.................#.........#..#..#.#.#........................#.#.......#..
....#........#........#....#.#.#.....#.##............###.#..........#...##......#........##...#.........#.............#........#...
..#..............................#.............................#......#...................#...#......#.............#...............
.......#...#...............#.................##....................#....##.......#....##....##...#..................#..............
.........................#...#..#.....##.............#...##.......#.....#...#..............#.....#.#.#..#........................#.
......#.......##.#.............#....................#...#...........#...#..##....#.....#............#...........#........#.........
...#....#...#......#........................#.....#.........#......#........#.....#.#...........#.#..............#......#....#.....
........#..........#...................#...........##.#..#...#................#....##.............#................#....#..........
........#.......#....#.............#..........#...................#.#....#.#........#..#..............................#..........#.
............#........#....................#.#.........#......#.............#................#...#.............#....#...............
..#..............................#..#....##.....#......................##...#..#.........#......#......................#...#...#.#.
.##....#.............#...........##..................#...#..............#.......#................................#.........#.......
.....#......#.#.....##...........#.....#.......#..........##..#.............#.#.........#.#.#.............##........#......#..#....
.......#.......#.#.#..#......................#....#............##....#...........#.........................#......#................
.........##.........#..............#.#.#....#...#.......#.................................#..##..................##.###.##...#.....
......................#...#.#.......#..#.#..........#........#.......#.................#..................................#........
....##........#.........#.........................#................#......#...#.....#..................................#..#.#......
...##..............#..................#...#......#........###..#.......#..........#..............................#......#..........
.#.#.#....#..........#......#.#.........#.....#...............................#.....#.#............#....#........#.............#...
........#.........#.........#......................#..#......##.....#..#..........................#......##....#......##.##.....#..
.##...#.......#.#....#..#.#...................#.........#....#...........#.....#.........#............##......#............#.......
.##..#.........#..........#.#.................................#.#.#...............................#............#......##...#.#.....
......#........#..#...#............#..............#............#......##.....#.................................#......#.#.....#....
..........#........#...........#....................................#.....#...............................#............##....#.##..
........#.............#..#......##..................#.............#..#...#.#.....#...#...............#........................#....
....#...............#..........#....#...........................#....##.##...................#.#.......#...#.##....#........##..#..
......#.....#..#..........###...#.................####.###..........#...........#..........#......#............................#...
.#...#......#........#..#............##...............#.##......#...#.....#....................#.........#............#...#........
................##...................#.##..............#...#..#.......#.......###........#..#..#........#...##.....................
..............#....#..#..#.............##..............#................................#.....#..#....###.##..............#........
..#..............#........................................#..........#.....#..................#............#..#....................
.........#...#.....#...#...##...........#.###............##...#........#......................##......#....#.......#...............
....#....#.....#.......#......................................#.#.#....#..#..#..........#...................#........#...#.........
..#..#..................#..............#...#..#.........#......#....#.#................##..........#..#................#...........
...#...................#...........#....#...#.............##...#.......#.#..........#..#...............#....#....#.............#...
.......................##.#.#..##........#....#.........#.#.#.....##..............#.......#.......##.#..........#.#................
.....#..#..................#..##....#.......#.............#...#.....#.............#.............#.#...............#.....##......##.
...#.#.....#..........#.#............#..#..........................##.............#....#.......#.#...#...#....................#.#..
............##.#............#....#....#....#..##...#...............................#...#...#.........#.......................##.##.
....#.#...............#...#.......#............#..#...........................#..............#..........#....#...#...#..#...#....#.
.......#..#..#.#..#......#..........................#...............#.........#...........#................#..#...#................
...#..#...#.....#.#.......#....................................................#........#..........#.#...#......#..........#.......
..#...#.......#..#..............#.#...#.....#...#....#............#..........##...#.........##.............#.......................
...#.............#...#....#...#.....#.#.#..............#..........#........#........##...........#..#.#......................#.....
.#.......#.................#...............#..........#.....................#.....#............#......##....#.....#...#....###.....
...##...........#..........#.#........#............#..#.#........................#.....##............#...##.#.......#.##....#......
...........#........#...........#.......#......#...#.....#............................#........#..#................#...#....##.....
...##.##.........#.####..#............#..#.....#.......................#......#..........#.#..#.#....##........#....#.....#..#..##.
...................................................................................................................................

99
aoc2023/day21/main.go Normal file
View File

@@ -0,0 +1,99 @@
package main
import (
"bufio"
_ "embed"
"fmt"
aoc "go.sour.is/advent-of-code"
)
// var log = aoc.Log
func main() { aoc.MustResult(aoc.Runner(runner(64))) }
type result struct {
valuePT1 int
valuePT2 int
}
func (r result) String() string { return fmt.Sprintf("%#v", r) }
func runner(rounds int) func(scan *bufio.Scanner) (*result, error) {
return func(scan *bufio.Scanner) (*result, error) {
var garden garden
for scan.Scan() {
txt := scan.Text()
garden.m = append(garden.m, []rune(txt))
for i, c := range txt {
if c == 'S' {
garden.start[0] = len(garden.m) - 1
garden.start[1] = i
}
}
}
garden.Step(rounds)
return &result{
valuePT1: len(garden.steps[len(garden.steps)-1]),
}, nil
}
}
type garden struct {
start aoc.Point[int]
m [][]rune
steps []aoc.Set[aoc.Point[int]]
}
func (g *garden) Neighbors(p aoc.Point[int]) []aoc.Point[int] {
var neighbors []aoc.Point[int]
for _, n := range []aoc.Point[int]{
{p[0] - 1, p[1]},
{p[0] + 1, p[1]},
{p[0], p[1] - 1},
{p[0], p[1] + 1},
} {
if n[0] >= 0 && n[0] < len(g.m) && n[1] >= 0 && n[1] < len(g.m[0]) && g.m[n[0]][n[1]] != '#' {
neighbors = append(neighbors, n)
}
}
return neighbors
}
func (g *garden) Step(n int) {
if len(g.steps) == 0 {
g.steps = append(g.steps, aoc.NewSet(g.start))
}
for step := range(n) {
g.steps = append(g.steps, aoc.NewSet[aoc.Point[int]]())
for p := range g.steps[step] {
for _, n := range g.Neighbors(p) {
g.steps[step+1].Add(n)
}
}
}
}
func (g garden) String() string {
var b []rune
for i, line := range g.m {
if i == g.start[0] {
line[g.start[1]] = 'X'
}
if steps := len(g.steps) - 1; steps > 0 {
for p := range g.steps[len(g.steps)-1] {
if p[0] == i {
line[p[1]] = 'O'
}
}
}
b = append(b, line...)
b = append(b, '\n')
}
return string(b)
}

View File

@@ -0,0 +1,41 @@
package main
import (
"bufio"
"bytes"
"testing"
_ "embed"
"github.com/matryer/is"
)
//go:embed example.txt
var example []byte
//go:embed input.txt
var input []byte
func TestExample(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(example))
result, err := runner(6)(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 16)
is.Equal(result.valuePT2, 0)
}
func TestSolution(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(input))
result, err := runner(64)(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 3709)
is.Equal(result.valuePT2, 0)
}

13
aoc2023/day25/example.txt Normal file
View File

@@ -0,0 +1,13 @@
jqt: rhn xhk nvd
rsh: frs pzl lsr
xhk: hfx
cmg: qnr nvd lhk bvb
rhn: xhk bvb hfx
bvb: xhk hfx
pzl: lsr hfx nvd
qnr: nvd
ntq: jqt hfx bvb xhk
nvd: lhk
lsr: lhk
rzs: qnr cmg lsr rsh
frs: qnr lhk lsr

1261
aoc2023/day25/input.txt Normal file

File diff suppressed because it is too large Load Diff

63
aoc2023/day25/main.go Normal file
View File

@@ -0,0 +1,63 @@
package main
import (
"bufio"
_ "embed"
"fmt"
"iter"
"strings"
aoc "go.sour.is/advent-of-code"
)
// var log = aoc.Log
func main() { aoc.MustResult(aoc.Runner(run)) }
type result struct {
valuePT1 int
valuePT2 int
}
func (r result) String() string { return fmt.Sprintf("%#v", r) }
func run(scan *bufio.Scanner) (*result, error) {
g := aoc.Graph[string, int]()
var root string
for scan.Scan() {
line := scan.Text()
v, lis, ok := strings.Cut(line, ": ")
if !ok {
continue
}
if root == "" {
root = v
}
for _, l := range strings.Split(lis, " ") {
g.AddEdge(v, l, 1)
g.AddEdge(l, v, 1)
}
}
for i, v := range enumerate(g.BFS(root)) {
fmt.Println(i, v)
}
return &result{}, nil
}
func enumerate[T any](vs iter.Seq[T]) iter.Seq2[int, T] {
i := 0
return func(yield func(int, T) bool) {
for v := range vs {
if !yield(i, v) {
return
}
i++
}
}
}

View File

@@ -0,0 +1,41 @@
package main
import (
"bufio"
"bytes"
"testing"
_ "embed"
"github.com/matryer/is"
)
//go:embed example.txt
var example []byte
//go:embed input.txt
var input []byte
func TestExample(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(example))
result, err := run(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 50)
is.Equal(result.valuePT2, 0)
}
func TestSolution(t *testing.T) {
is := is.New(t)
scan := bufio.NewScanner(bytes.NewReader(input))
result, err := run(scan)
is.NoErr(err)
t.Log(result)
is.Equal(result.valuePT1, 0)
is.Equal(result.valuePT2, 0)
}

View File

@@ -0,0 +1,6 @@
3 4
4 3
2 5
1 3
3 9
3 3

1000
aoc2024/day01/input.txt Normal file

File diff suppressed because it is too large Load Diff

86
aoc2024/day01/main.go Normal file
View File

@@ -0,0 +1,86 @@
package main
import (
"bufio"
_ "embed"
"fmt"
"iter"
"slices"
"sort"
aoc "go.sour.is/advent-of-code"
)
// var log = aoc.Log
func main() { aoc.MustResult(aoc.Runner(run)) }
type result struct {
valuePT1 int
valuePT2 int
}
func (r result) String() string { return fmt.Sprintf("%#v", r) }
func run(scan *bufio.Scanner) (*result, error) {
var (
left []int
right []int
)
for scan.Scan() {
txt := scan.Text()
var l, r int
_, err := fmt.Sscanf(txt, "%d %d", &l, &r)
if err != nil {
return nil, err
}
left = append(left, l)
right = append(right, r)
}
sort.Ints(left)
sort.Ints(right)
result := &result{}
result.valuePT1 = aoc.Reduce(func(i int, z pair[int, int], sum int) int {
return sum + aoc.ABS(z.L-z.R)
}, 0, zip(slices.Values(left), slices.Values(right)))
rmap := aoc.Reduce(func(i int, z int, m map[int]int) map[int]int {
m[z]++
return m
}, make(map[int]int), slices.Values(right))
for _, v := range left {
if r, ok := rmap[v]; ok {
result.valuePT2 += v*r
}
}
return result, nil
}
type pair[L, R any] struct {
L L
R R
}
func zip[L, R any](l iter.Seq[L], r iter.Seq[R]) iter.Seq[pair[L,R]] {
return func(yield func(pair[L, R]) bool) {
pullR, stop := iter.Pull(r)
defer stop()
for l := range l {
r, _ := pullR()
if !yield(pair[L, R]{L: l, R: r}) {
return
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More