Compare commits

...

6 Commits
day23 ... main

Author SHA1 Message Date
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
128 changed files with 3335 additions and 56 deletions

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

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
aoc2024/day01/input.txt Normal file
View File

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

@ -0,0 +1,30 @@
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) {
for scan.Scan() {
_ = scan.Text()
}
return &result{}, nil
}

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, 0)
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)
}

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