This commit is contained in:
2022-12-23 19:45:56 -08:00
commit 8792e5275a
77 changed files with 31154 additions and 0 deletions

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module github.com/acw/advent2022
go 1.19
require golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4=
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=

14
inputs/example.1 Normal file
View File

@@ -0,0 +1,14 @@
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000

3
inputs/example.10a Normal file
View File

@@ -0,0 +1,3 @@
noop
addx 3
addx -5

146
inputs/example.10b Normal file
View File

@@ -0,0 +1,146 @@
addx 15
addx -11
addx 6
addx -3
addx 5
addx -1
addx -8
addx 13
addx 4
noop
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx -35
addx 1
addx 24
addx -19
addx 1
addx 16
addx -11
noop
noop
addx 21
addx -15
noop
noop
addx -3
addx 9
addx 1
addx -3
addx 8
addx 1
addx 5
noop
noop
noop
noop
noop
addx -36
noop
addx 1
addx 7
noop
noop
noop
addx 2
addx 6
noop
noop
noop
noop
noop
addx 1
noop
noop
addx 7
addx 1
noop
addx -13
addx 13
addx 7
noop
addx 1
addx -33
noop
noop
noop
addx 2
noop
noop
noop
addx 8
noop
addx -1
addx 2
addx 1
noop
addx 17
addx -9
addx 1
addx 1
addx -3
addx 11
noop
noop
addx 1
noop
addx 1
noop
noop
addx -13
addx -19
addx 1
addx 3
addx 26
addx -30
addx 12
addx -1
addx 3
addx 1
noop
noop
noop
addx -9
addx 18
addx 1
addx 2
noop
noop
addx 9
noop
noop
noop
addx -1
addx 2
addx -37
addx 1
addx 3
noop
addx 15
addx -21
addx 22
addx -6
addx 1
noop
addx 2
addx 1
noop
addx -10
noop
noop
addx 20
addx 1
addx 2
addx 2
addx -6
addx -11
noop
noop
noop

27
inputs/example.11 Normal file
View File

@@ -0,0 +1,27 @@
Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 54, 65, 75, 74
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 79, 60, 97
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 1
If false: throw to monkey 3
Monkey 3:
Starting items: 74
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 1

5
inputs/example.12 Normal file
View File

@@ -0,0 +1,5 @@
Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi

23
inputs/example.13 Normal file
View File

@@ -0,0 +1,23 @@
[1,1,3,1,1]
[1,1,5,1,1]
[[1],[2,3,4]]
[[1],4]
[9]
[[8,7,6]]
[[4,4],4,4]
[[4,4],4,4,4]
[7,7,7,7]
[7,7,7]
[]
[3]
[[[]]]
[[]]
[1,[2,[3,[4,[5,6,7]]]],8,9]
[1,[2,[3,[4,[5,6,0]]]],8,9]

2
inputs/example.14 Normal file
View File

@@ -0,0 +1,2 @@
498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9

14
inputs/example.15 Normal file
View File

@@ -0,0 +1,14 @@
Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10, y=16
Sensor at x=10, y=20: closest beacon is at x=10, y=16
Sensor at x=14, y=17: closest beacon is at x=10, y=16
Sensor at x=8, y=7: closest beacon is at x=2, y=10
Sensor at x=2, y=0: closest beacon is at x=2, y=10
Sensor at x=0, y=11: closest beacon is at x=2, y=10
Sensor at x=20, y=14: closest beacon is at x=25, y=17
Sensor at x=17, y=20: closest beacon is at x=21, y=22
Sensor at x=16, y=7: closest beacon is at x=15, y=3
Sensor at x=14, y=3: closest beacon is at x=15, y=3
Sensor at x=20, y=1: closest beacon is at x=15, y=3

10
inputs/example.16 Normal file
View File

@@ -0,0 +1,10 @@
Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II

1
inputs/example.17 Normal file
View File

@@ -0,0 +1 @@
>>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>

2
inputs/example.18a Normal file
View File

@@ -0,0 +1,2 @@
1,1,1
2,1,1

13
inputs/example.18b Normal file
View File

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

2
inputs/example.19 Normal file
View File

@@ -0,0 +1,2 @@
Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian.

3
inputs/example.2 Normal file
View File

@@ -0,0 +1,3 @@
A Y
B X
C Z

7
inputs/example.20 Normal file
View File

@@ -0,0 +1,7 @@
1
2
-3
3
-2
0
4

15
inputs/example.21 Normal file
View File

@@ -0,0 +1,15 @@
root: pppw + sjmn
dbpl: 5
cczh: sllz + lgvd
zczc: 2
ptdq: humn - dvpt
dvpt: 3
lfqf: 4
humn: 5
ljgn: 2
sjmn: drzm * dbpl
sllz: 4
pppw: cczh / lfqf
lgvd: ljgn * ptdq
drzm: hmdt - zczc
hmdt: 32

14
inputs/example.22 Normal file
View File

@@ -0,0 +1,14 @@
...#
.#..
#...
....
...#.......#
........#...
..#....#....
..........#.
...#....
.....#..
.#......
......#.
10R5L5R10L4R5L5

6
inputs/example.23a Normal file
View File

@@ -0,0 +1,6 @@
.....
..##.
..#..
.....
..##.
.....

12
inputs/example.23b Normal file
View File

@@ -0,0 +1,12 @@
..............
..............
.......#......
.....###.#....
...#...#.#....
....#...##....
...#.###......
...##.#.##....
....#..#......
..............
..............
..............

6
inputs/example.3 Normal file
View File

@@ -0,0 +1,6 @@
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw

6
inputs/example.4 Normal file
View File

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

10
inputs/example.5 Normal file
View File

@@ -0,0 +1,10 @@
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2

5
inputs/example.6 Normal file
View File

@@ -0,0 +1,5 @@
mjqjpqmgbljsphdztnvjfqwrcgsmlb
bvwbjplbgvbhsrlpgdmjqwftvncz
nppdvjthqldpwncqszvftbrmjlhg
nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg
zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw

23
inputs/example.7 Normal file
View File

@@ -0,0 +1,23 @@
$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
584 i
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.log
5626152 d.ext
7214296 k

5
inputs/example.8 Normal file
View File

@@ -0,0 +1,5 @@
30373
25512
65332
33549
35390

8
inputs/example.9 Normal file
View File

@@ -0,0 +1,8 @@
R 4
U 4
L 3
D 1
R 4
D 1
L 5
R 2

8
inputs/example.9b Normal file
View File

@@ -0,0 +1,8 @@
R 5
U 8
L 8
D 3
R 17
D 10
L 25
U 20

2249
inputs/input.1 Normal file

File diff suppressed because it is too large Load Diff

139
inputs/input.10 Normal file
View File

@@ -0,0 +1,139 @@
addx 1
noop
noop
noop
addx 5
addx 5
noop
noop
addx 9
addx -5
addx 1
addx 4
noop
noop
noop
addx 6
addx -1
noop
addx 5
addx -2
addx 7
noop
addx 3
addx -2
addx -38
noop
noop
addx 32
addx -22
noop
addx 2
addx 3
noop
addx 2
addx -2
addx 7
addx -2
noop
addx 3
addx 2
addx 5
addx 2
addx -5
addx 10
noop
addx 3
noop
addx -38
addx 1
addx 27
noop
addx -20
noop
addx 2
addx 27
noop
addx -22
noop
noop
noop
noop
addx 3
addx 5
addx 2
addx -11
addx 16
addx -2
addx -17
addx 24
noop
noop
addx 1
addx -38
addx 15
addx 10
addx -15
noop
addx 2
addx 26
noop
addx -21
addx 19
addx -33
addx 19
noop
addx -6
addx 9
addx 3
addx 4
addx -21
addx 4
addx 20
noop
addx 3
addx -38
addx 28
addx -21
addx 9
addx -8
addx 2
addx 5
addx 2
addx -9
addx 14
addx -2
addx -5
addx 12
addx 3
addx -2
addx 2
addx 7
noop
noop
addx -27
addx 28
addx -36
noop
addx 1
addx 5
addx -1
noop
addx 6
addx -1
addx 5
addx 5
noop
noop
addx -2
addx 20
addx -10
addx -3
addx 1
addx 3
addx 2
addx 4
addx 3
noop
addx -30
noop

55
inputs/input.11 Normal file
View File

@@ -0,0 +1,55 @@
Monkey 0:
Starting items: 66, 59, 64, 51
Operation: new = old * 3
Test: divisible by 2
If true: throw to monkey 1
If false: throw to monkey 4
Monkey 1:
Starting items: 67, 61
Operation: new = old * 19
Test: divisible by 7
If true: throw to monkey 3
If false: throw to monkey 5
Monkey 2:
Starting items: 86, 93, 80, 70, 71, 81, 56
Operation: new = old + 2
Test: divisible by 11
If true: throw to monkey 4
If false: throw to monkey 0
Monkey 3:
Starting items: 94
Operation: new = old * old
Test: divisible by 19
If true: throw to monkey 7
If false: throw to monkey 6
Monkey 4:
Starting items: 71, 92, 64
Operation: new = old + 8
Test: divisible by 3
If true: throw to monkey 5
If false: throw to monkey 1
Monkey 5:
Starting items: 58, 81, 92, 75, 56
Operation: new = old + 6
Test: divisible by 5
If true: throw to monkey 3
If false: throw to monkey 6
Monkey 6:
Starting items: 82, 98, 77, 94, 86, 81
Operation: new = old + 7
Test: divisible by 17
If true: throw to monkey 7
If false: throw to monkey 2
Monkey 7:
Starting items: 54, 95, 70, 93, 88, 93, 63, 50
Operation: new = old + 4
Test: divisible by 13
If true: throw to monkey 2
If false: throw to monkey 0

41
inputs/input.12 Normal file
View File

@@ -0,0 +1,41 @@
abccccccccaaaaaaaccaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccaaaaaa
abccccccccaaaaaaaccaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccccaaaaaa
abccccccccccaaaaaaccaaaaaaaaaaaaaaaaccccccccccccccccacccccccccccccccccccaaaaa
abcccccaaaacaaaaaaccaaaaaaaaaaaaaaaaacccccccccccccccaaaccccaccccccccccccccaaa
abccccaaaaacaaccccccaaaaaacaaacaacaaaaaaacccccccccccaaaacccaacccccccccccccaaa
abaaccaaaaaaccccaaacaaaacacaaacaaccaaaaaacccccccccccaklaccccccccccccccccccaac
abaaccaaaaaaccaaaaaacccccccaaacccaaaaaaaccccccccccckkkllllccccccccccccccccccc
abaaccaaaaaaccaaaaaacccccccaaaaacaaaaaaacccccccccckkkklllllcccccccaaaccaccccc
abacccccaacccccaaaaacccccccaaaaaccaaaaaaacccccccckkkkpppllllccccccaaaaaaccccc
abacccccccccccaaaaacccccccccaaaacccaaaaaaccccccckkkkpppppplllccccddddaaaccccc
abccccccccccccaaaaaccccccccccaaaccaaaccccccccccckkkppppppppllllldddddddaccccc
abccacccccccccccccccccccccccccccccaaccccccccccckkkopppupppplllmmmmdddddaacccc
abccaaacaaaccccccccccccccccccccaaaaaaaaccccccckkkkopuuuuupppllmmmmmmddddacccc
abccaaaaaaaccccccccccccccccccccaaaaaaaacccccjjkkkooouuuuuuppqqqqqmmmmddddcccc
abccaaaaaacccccccccccccccaaccccccaaaacccccjjjjjjoooouuxuuuppqqqqqqmmmmdddcccc
abcaaaaaaaacccccccccccccaaacccccaaaaaccccjjjjoooooouuuxxuuvvvvvqqqqmmmdddcccc
abaaaaaaaaaacccccccaaaaaaacaacccaacaaacccjjjooooouuuuxxxxvvvvvvvqqqmmmdddcccc
abaaaaaaaaaacccaaacaaaaaaaaaacccacccaaccjjjooootttuuuxxxyyvyyvvvqqqmmmeeecccc
abcccaaacaaacccaaaaaaacaaaaaccccccccccccjjjooottttxxxxxxyyyyyyvvqqqmmmeeccccc
abcccaaacccccccaaaaaacaaaaaccccaaccaacccjjjnnntttxxxxxxxyyyyyvvvqqqnneeeccccc
SbccccaacccccccaaaaaaaaacaaacccaaaaaacccjjjnnntttxxxEzzzzyyyyvvqqqnnneeeccccc
abcccccccccccccaaaaaaaaacaaccccaaaaaccccjjjnnnttttxxxxyyyyyvvvrrrnnneeecccccc
abcccaacccccccaaaaaaaaaccccccccaaaaaacccciiinnnttttxxxyyyyywvvrrrnnneeecccccc
abcccaaaaaaccaaaaaaaacccccccccaaaaaaaaccciiiinnnttttxyyywyyywvrrrnnneeecccccc
abcccaaaaaaccaaaaaaaacccccccccaaaaaaaacccciiinnnntttxwywwyyywwwrrnnneeecccccc
abcaaaaaaaccaaaaaaaaaccccccccccccaacccccccciiinnnttwwwwwwwwwwwwrrnnneeecccccc
abcaaaaaaaccaaaaaacccccccccccccccaaccccccaaiiiinnttwwwwwwwwwwwrrrnnnffecccccc
abcccaaaaaaccaaaaaccccccccccccccccccccaaaaaciiinnssswwwssssrwwrrrnnnfffcccccc
abaacaaccaaccaaaccccccccaacccccccccccccaaaaaiiinnssssssssssrrrrrronnfffcccccc
abaccaaccaacccccccccaaacaacccccccccccccaaaaaiiimmmssssssmoosrrrrooonffaaacccc
abaaaccccaaaaaaccccccaaaaaccccccccccccaaaaaccihmmmmsssmmmoooooooooofffaaacccc
abaaaccccaaaaaacccccccaaaaaacccccccccccccaacchhhmmmmmmmmmoooooooooffffaaccccc
abaacccaaaaaaaccccccaaaaaaaaccccaaccccccccccchhhhmmmmmmmgggggooofffffaaaccccc
abaacccaaaaaaaccccccaaaaaaaccccaaaaccccccccccchhhhmmmmhggggggggfffffaaaaccccc
abccccccaaaaaaacccccaacaaaaacccaaaaccccccccccchhhhhhhhggggggggggfffaacaaccccc
abccaacccaaaaaaccccccccaaaaaccaaaaacccccccccccchhhhhhhggaaaaaaccccccccccccccc
abccaaaccaaccccccccccccccaaaaaaaaaccccccccccccccchhhhaaaccaaaacccccccccccccaa
abaaaaaaaccccccccccccccccaaaaaaaaccccccccccccccccccccaaaccccaaccccccccccccaaa
abaaaaaaaccccccccaaaccccacaaaaaacccccccccccccccccccccaaaccccccccccccccccccaaa
abaaaaaacccccccaaaaacaaaaaaaaaaacccccccccccccccccccccaaccccccccccccccccaaaaaa
abaaaaaacccccccaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccaaaaaa

449
inputs/input.13 Normal file
View File

@@ -0,0 +1,449 @@
[[9,[8,[7]],4,7,[[4,9,3,2],6,5,[1,10,2,4,5],[1,3,2,6,1]]],[4,[6],3],[4,[7,0,3,8,8],[7,[10],[10,10,10,7]]]]
[[],[[6,4,[5],4,[0,5,5]],3,[5,[],9]],[[[5,1,6,2],[6,4,7],[4,7,4,2]],[10,[],[6,9,4],[6,2],9]],[[[10,5,9],10,0,[4,1,4,10,1],1],[7,7,[10,8],6],2]]
[[[8,2],2,[[10],[],6,10,[10,10,3,10,3]]],[],[]]
[[[[7,3,5],10,[4,1,0,8,7],9],10,[]]]
[[6,2,[2,[10,10,0],[2]],7]]
[[7,9],[5,[8,[0,5,5,10,4],6,8,6],3,[4],2],[4]]
[[[5],[6,[5,3,0],[6,2,5,2,6],1,6],[[]],[3,[1,1,0],[],1,[9,4,3,5,7]]],[[1,9,[2,2,6],[8,9],2],1,[[],0,8],[[],9],3]]
[[],[[10,9],[],[[6],9,8,[3]],[0,5,[5],6],2],[[[5,2,5,3,5],4],9,6],[8]]
[[[[9,10,8,4],2],[[10]]],[1,[[],9,[7,2,2,1,0],5]],[[[10],[],[5]],10,[],9],[[],[2,[1],[4],7,[6,1,5,0,1]]]]
[[[[6,9],[8,2,2],[5,1,6],[0,1]],[[2,5,1,3],9,[]],[[10,3,9],10,4]],[[[5,2,0],[7,3],9],[[5,3,2,6]],4]]
[[[1,0,9,[10]],[],[8,2,[0,2],6,[]]]]
[[4,3],[2]]
[[7]]
[[7,[[4,0,9,9]],3,[10,0,6,[5,2,0,1,7]],7],[5,[3,[2,8,7],[9],[2,3,5,0,10]],10,[[3,0,8],6,[5,5,7],[2,10]]],[3,4]]
[[[[0,9,5,2],[6,0,4,10]],[10,7]],[[6]],[7],[[[1,10,8,0,6],7,[3],0],3],[[[1,5,5],[6,6,9],[],[4]],1,9]]
[[[[2,3],[7],10,[2,1,3]],10,[6,9,[0,8]],[[6,6,5],[10,6]],[[],[],7]]]
[[[6],7,[10,[2],3],[[2,3]],[[1,1,7],[0,6,6,2],[7],[]]],[4],[2],[[6,2,10,3,6],[[5,7,10,3,6],8,[1],[]],7,5,[]],[[]]]
[[[],[7,5,8],0,3,[]],[2,8],[7],[8,0,[[0],3,[2]]],[1]]
[[[],5,[0]],[7],[[2,7,[7]],[[8,3],[8,9,8],6,[]],[1,3,[0,4,10],[6,1,9]],8],[[3,0]]]
[[5,[],10]]
[[8,[[0],5,[],3],[0,8]]]
[[],[3,5],[[[8,9,5],1,[3,9]],[[0,0],9,2],[0,1,8]],[0,3,[[3]],[7,[3,5,10],[1,9,10],[9,5],[2,4,3,9,7]]],[[8,3,6],6,[7,5,8],[[],4,1]]]
[[6],[]]
[[],[[[3,5,9],[0,7,5],[3,8,1,9,6]],[1,[3,3,10],0],[5,8,3,0,3],3,8],[[[1],[9,9,3,3],[7],[7,10,1,6]],4,10,[[7,7,2,0,3]],[10,9]],[9]]
[[3,2,4]]
[[[[2],4,[9,4,6,0]],[7,[]],[[0,5,9],[7],7,3],[[8,0,0,4,5]],[9,[3,5,4,10],[7,7,4]]],[[9,[],[8,5,6,4,9]],1,10,4,7]]
[[],[[],[8]],[1,[[8,10,0,2],1,4,[1,10,9]],3],[[[0,4,5,6,6]],5,[[9,0,5],[3,10],8],3],[[9],4,[[3,6],6],[8,[5],10,[7,0]],7]]
[[1]]
[[[[5,3,8,2],1,[10]],9],[[[9,3,0,7],8,[10,1,6,9],[7,6,3],[6,7,5]],[6,1,[1,6,10,8],7,[]]]]
[[8],[[7,[5,6],0],[4,[],[5,2,10,8]],[10]],[[],6,[],[10,5,3],[3,4]],[[[7,4,7,8,0]],9]]
[[7,[7,7],4,1,4],[10,[10,[2,4,9],0,[5,10,7],1],10,[9,2,[0,6,3,9,10],8,[7,9,7,10,3]],[3,[0,2]]],[9,3]]
[[3,[0,[5,0,8,1]],[]],[],[[3,[2,4,4,0,0],2],[4,[9,1,0]],1],[],[]]
[[[[5,10,10,8]],[[5,7,10,10],[],[2,4,10,9],1,[]],9,8,[10,[5],[7,6,8,2],10,[2,9]]],[8,3,[[],3,[4,3,0],1,2],[6,[2,8],[2],0,0],5],[2,[[6,0,0,4,9],[7,10],1,[]],[[8],10],[[1,10]]],[6,10,[[3,6,7,9],5],4]]
[[[]],[[[10,5,9],2],4,[0,[8],[0,8,9,2,6]],[8,0,[4,4,10],7]],[[6,[]],10,[[],[5,10]],[6,9],[3,10,[2,5,1,7,7],[2,6,10]]],[[],[[],5],[[5],[7],[8,2,2,8]],[2,[4,0],8]],[[[10],8,[10]],[],[]]]
[[[[6,6,1],[3,10,5]],[[3,9,6,0],2,[10,1,8,8]],[],[[6,9],5,5,[],4]],[[7],3],[[[],[8,4,2,0,8]],10,2,7],[8],[10,7,[[2,6,0,0,8],[3,10,10],[],9,[7,9,3]],6]]
[[6,8,[[9,0,8,7,5],0,3],[],0],[8,[6,9],8,[[0],7,[10,6],6,[7]],8]]
[[[[9],[6,6],0,8,[7,2]],[7,[],[9,6,2],9,[]],[[],7,7,[6,6]]],[1,3,1],[1,[[8,0,10,1,9]],9],[10,5]]
[[[[4,6,8,9],8,[3,3,6],[10]],[[3,6,7,5],[],[4,9]],[6,0,8],[],[5,[2]]],[[[5,1,6,2,8],2],3,[9,9,[],0,1],5,[10,[9,5,2],5]],[]]
[[[]],[]]
[[8,[5,[6,3,2],[10,5,4],[5,1],[5,10,5,9,7]],4,[8,2,0,6],4],[[[0,9,5,7],9],6,[[0,8,10,8],9,[9,0,3,7,1],[6,8,2,5,10],[]],7,[1,[],4,[0],[2]]],[1],[[7,[],6,2,1]],[2,3]]
[[5],[3,[1],[[6]],[[2],[],3,[6,1,8,6,1],[4,6,4,7]],[3]]]
[[[[6,5,1],9],[],7,7],[0,4]]
[[[],5,4,7,[[9,5,9],[]]]]
[[10,[1,[2,3],9,[3]]],[[[5,7,9,10,8],[]],0]]
[[6,8,[0,1,10]],[[4,7],[[7,0,0,3],6,2]],[[[10],[6,5,3,10,0],[0,2,4],[8,10],[7]],1],[2,[2]]]
[[],[5,8,[[],[6,3,2,3],9,3,[]],[0,[4,1,5],4],[[0,6,4],[],[3,6,10,9],3,[0,0]]],[[6,3],6,2,10,8],[5,[[0,9,4,6,1],[6,9,4]],3,[],0]]
[[4,8],[],[],[7,6,4]]
[[],[[5],[[8],[10],7,[9,10]],9],[3],[[9],[[3,0,5]]],[10,[[6,0,3],[2,4,3,0],4,10,10]]]
[[4,10,[[8],[6,4,8,8,10],1,[10,2],[7,8,9,0]],1],[6,4,3],[7,8,4],[[9,[10,4,8,7,2]]],[3,5]]
[[],[[[0,0,5,10],9,10],[[6,7,5]],[[3,6,7,2,2],[9],[7,5],9],[[0,0,10,9,8],5,[3,2]],[]]]
[[[],[[],8,0]],[[[],[],[]],9],[[7],3,10,4,[3,[4,7,0,2]]],[[[0,9,2,1],[2]]],[[[1,7],6,8,[2,5]],8,7]]
[[],[1],[6,[],1,[4,[],[10]],[[10,9,1],[]]],[[[2,1,5,10],[9,9,5,7,9],[9,1]],[[2],[5,9]],[[8],[2,8,2,4,5],4,[3,9,3],9],9]]
[[7,[4,9,[],[7,6,8,7],3],6,7],[7,9,[[2,3],7,5,[7]],[[6],4,[2,8,5,10],[4,9,10,6]]],[[],10],[5,[5],8,[],[3,[6,1,7,10,1],7,5,[10,8]]],[[[7,7,8],8,8]]]
[[7,[10,1,[5,3,9],1,[]]]]
[[[[8,2,10,7,3],8,[0,7,0]]]]
[[4,7],[[2,[],7],4,[10,[4],[5,6],1,1]],[5,[[9,1]]],[[6,2],[2,3,[1,4,1]]],[]]
[[6,[[],10],[5,3]],[],[6,4,9],[7,[6]],[0,[],[[8,7,8,10,7],[],[10,6,4],[4],0],8,[8,7,1,[10,6,5],[10,1,5]]]]
[[3,8],[[3,[1],10]],[[6,2,[],[9,6],5],[[1,8,9,2,9]],[3,[],[7,6,4,7,6]]],[[[3,9,5,0,2]]],[[],7,7]]
[[10,7],[9,7,2,5,1]]
[[],[],[[]],[[7,2,[],[2,10,7],8],4,0,[2,[],[8,8,9],5,[6,1]],[1,4,[6,5,4,1,4],[7,7,9],2]],[[],5]]
[[[[6,7,10,0,4],[5,3,2,8,4]],[[1],[],[5,4],8,2],0],[1,5,10],[[2]]]
[[],[10,1,[[1,3,0],[0,1,7,7],[1,5,10,7,3],[4,6]],4,[]],[9,9,[8,[4,1,7],[4,1,8,9],[7,6,5,10,5]],[0,6,[6]],6]]
[[[[2,3,3],2,[]]],[[[4,6,7,5],[7,3,3,10],[4,6,10,2,3],[4],7]],[[[1,3,4,0,4],10],[10,[],4,3]],[],[3,[],9,2,8]]
[[],[[[9,1,8,4],7]]]
[[],[3,10,[[1,6,1],[1,2,1],[9],[3,7,9,10]],[[]]],[[[9,3,7,6],[6,8,2,3],10],[8,8,1,5],[6,2,4,[2,8],1]],[[[6,8,9,8],5,5],[[],[0,4,5],[4,5,8,7]]],[]]
[[[]],[[1,[2,4,0,4,4]],[2,[],4],[7,[9,5,5],[0,2,0,5]],10,8]]
[[],[],[],[3,[8,5,[7,2,9,9]],[[2],[4,10]]],[]]
[[9,[9,10,8,[4,6,3,0]],7],[[4,[8,4,2,8],5,[0,10,9,4,9],2],[2,10],[4,[10,1]]],[10]]
[[4,[[10,5],8]],[4,8,7],[[[7],[],5],10],[[],5]]
[[[[0,7],[9,8],[]],9,[[6,2],4],1,[]],[1],[[7,4,2,[8,2,3]],8,3,[[1,9,10,7],[2,2,3,2]]],[[[3,1,8],8,[6,1,1,6,5],[1],6],[6,[],10],[[],3],7,10]]
[[[7,[5,6,3,2,5],[0,6,0,3],[0,4,10,6,8]],4],[],[[],[[10,9],[10,4,9]],[[1,8,6],6,[]]],[5,9],[[],[[],[3,3]]]]
[[],[6],[[3,[1],4,[10,0,1,6,3],7],[],9],[0,[[],6,4,2]],[]]
[[7,[]]]
[[5,3,[6],[],[10,[0,7,3,9]]],[[[9,1,5],5,0,1,8]],[[[2,3,10,1],10],10],[[[],5,4,1,8],[0,[5,1,4,9,3],2,10],[],[9]],[2,10,8,6,4]]
[[[],1,8,[4]]]
[[[5,5,[]],[[],[3,2,5,10],[4],[5,5,8,2,6]],6],[[10],[[5,0],[2]],9],[[4],[]]]
[[[2,6,[9,10]],9,7],[8],[7,6],[8],[8,0,3,0]]
[[[],[[],4,[1],6,[5,9,0,0]],9,9,4]]
[[[],9],[[10,8],6,[[8,0,0,7],[6],3,[5,5,1],10],[[9,3,6],[8,3,0]],[]],[[0,7,1],3,3],[5],[4]]
[[[8,[4,6,0,4],2,[8]],[[6,10,6],[2],4],5,9,[3,[3],[10],7]],[6]]
[[[6,6,[0,5,3,10],10],[3,0,7,[8],[3,9,10,1,7]],8,[6,9,[]],[1]],[],[5],[5,[4,[6,9],2,[8],[]],0]]
[[],[],[[6,[],6],[9,8],7,[],[3,[5,9],4]],[[7,[3,7],[4,8,10,9],10],[[],9],8,[5],5]]
[[[[],6,0,[2,6,7,7]],9],[[7,1,[5,4,5,2,10],[]],7,[4,2,1,0],10],[6,7,[]]]
[[1,[[],5,10,[8]],[8,1,[],[1]],[[2,0,1,10,6],[10,7,3,5]]],[[[10,5,5,10],[]]],[0,[[5,7],[],9,6],[5,0,3],[]],[[6,5,0,[0,1,9,3],[9]]],[0,[4,1,3],7]]
[[[],[1],[],10],[6,9],[10,10],[]]
[[9,7,[[0,2],5,[8,1,5]]]]
[[],[0,[[7,8,4,1],9,0,2]],[[2,7,[],[1,6],[4,6]],[7,[]],0,[[1,0,5]],1],[5,[6,[9,4,2,6,4],10,[7,7,8,8,1]],[7,9,[7]]],[]]
[[],[9,3,[[2,8,6,3,9],1,6,[6,8]]]]
[[[6,6,[7,7,3]],[]],[3,2,0,[3,[8,4]],5],[9,10,7,10],[[9,[0],10,10,[1,9,0]],[[],1,3]]]
[[2,4,5],[],[0,[],[[0,2,8,0,7]],[[],[7],[0,2,9]]],[]]
[[[[]]]]
[[[[],[10],[0,9,7,9],5,[]]],[]]
[[[],[[],10,1,[7,3,0],[4,10]],[]],[[],[10,[7,4,7],[],9,[0,4,3,8]]]]
[[],[[[],10,1,2,0],10,[[]]],[[4],[[8,7,10],8,7],0],[[0,[4],[],[0,1,10,3],9]]]
[[[7,[],[1],[6,4,0]]],[[[7,1,10]],[[1],[1,9,4,6]]],[9]]
[[1],[4,5,3,8,[9,4,[0],[4,7,0]]],[9,[4]]]
[[],[[[10],6],[],[[2,1,9,10]],4,[4,1,10,3,0]],[[],[],0,[[]],[5,[10,5,9,1,1],[9,4,8]]],[],[3]]
[[9,[[6]],[],[[],5]],[[[3],10,9],1,[5,[10,1,10,1],[8,2,2,10,7],9,10],0],[8,3,[[0,10,3],6,[8,10,7,0,6]]],[[],2,7]]
[[7],[9]]
[[[[6,2,0,5],9],[[2,4,5],5,[0,6,8],[9],3],[[5,5,8],10,[0,5,2,3],7,[3,0,9,3,7]],7],[8,[[2,1,2,6],2,4],6,[],[2,[7,2,6,9],1]],[8,5,[10,[1,3,4,9],1,3],8],[[3,7,[9,5],[10,5,1],10],[[5,7,5,2,8]],[2,7,[],3,2],[[0,2,0,6],[5,7,9],7,[7,8]],[7]],[0,[[],[],4,10],5,[[9,10,5],3]]]
[[4,8,[9,[],[0,6,9,0,7]],[[2]],[1,4,8,10]],[[]],[[6,[1,3,2,7],[7,10,4,9,0]],5,3],[[[],[8],[2,7,1,3,4]],[]]]
[[],[],[4,9,7,6],[3,10,0,[]],[10]]
[[],[[],[],8,10]]
[[[[0,10,2,6],[3,8,9],6,[3,9,8]]],[[5,0,[2,3,9],[0,5],[4,4,1]],[[],7,[6,3,2,10,2]],5,9,[3]],[[]],[3,[[],7]],[[2,6,7,1],[1],3,[9,9]]]
[[[],7,[],[6,3,3,[4,5,6,10,8],[6,3,1,2,10]]],[[[],1,[8],[5,0,0],9],[],[[1,2,8,6]],[[4,3,7,1],2,[1,7,3,0]],[6,[7,5,3,6],5,5,3]],[[[],[6,1,7],[3,0,1,0,5]],0,[[0,10],4,[3,7,5,8,1]]],[4]]
[[5],[6],[],[5]]
[[[8,[7],[9,7,5],[4,4,4,0,9],[0,8]]]]
[[[[3,2,6,6],[1,4,1,7,0],[],10,[8,6]],[[5,4,2],[],6,[10,6,2,2,7]],7,[[6,4],[],8,[2,7]],8],[],[],[[[],7,6],1]]
[[6,[1,6,[9,3,7,5],8,[8,2]]]]
[[[9,3,[6,10],[],[9,5,1,2]],[[9,8],[6,4,8,9],[6,8,3],[9,7,9,10]],0,[[3,5,6,10],[7,0,7]],0],[6,[[8],[0,7,1],7,[8,1]],[4,4,3],[5,[],6,9],10],[7],[]]
[[9,[3,3],[10,[8,10,9,9]],6,3],[[[6,2],6,5],[[6]],[1,[3,2,6]]],[9,7,1,5]]
[[3],[9,[7],[3],[7,5,7],7],[],[[[],[3,3,0,9],[8]],2,8]]
[[[[7,1,1],0,4,7,2],[[3,4,9,2],[8,7,5,0,9],5],[9]],[[[3,8,4,2,8]]],[]]
[[0,3,[[8,10,9,0,4],5],[]]]
[[[]],[[]]]
[[[[2,6,8,2],2,6,0,8],[10,5,[0,2,1,0],0]],[4,3,[0,4,[3,7,0,0,5]],[[1,3,9],4],0]]
[[[10],[[9],0,[6],2,0]],[[1,3,[7,3,1]],[8,[6,3,0,1,1]],5],[[7,[1,0],2,[]],5,4,3,4],[9,7,9,7,5]]
[[9,0,[9,4]],[[[3]],5,5]]
[[5,[10,0,[3,1],[0,8]]],[7,[[8,6,8,4,7],[],5,[7,10,8,3,9]],4,6]]
[[[[7,6,6],8],[[9,7,10,6,3],8],0],[2,9,7],[[[3,9,8,7],[8,0],5],[[0,8,2],[]],[3,3,[3,4],0,6],[6,[8,5,4,6,2]]],[]]
[1,0,10,1]
[1,0,10,1,0]
[[9],[2,6],[]]
[[4,1,[[9],[8,6,10,5,2],3,[6,5,9,5],[8,0,2]],7,2],[1,[[1],6,[0,7],9],[10,5,4]],[6,9],[[[6],[1,5,5,10],5,[],[10,4,6,6,4]]]]
[[[6,7,[],[8,3,9,3,7]],0,5,5,2],[4,[],8,[[10,10,3,0],5],[[4],3,10]],[],[7,10]]
[[[7,[6]],[2,8,[8,1,4]],[[3,1,7,10],10,2],2,[4]],[8],[[]],[[1,[6,0,3,1,1]],[[5,2,7,3,10],8,[0,1,1,2]],[9,4],0],[[[7,9]]]]
[[2,[],[],9,3]]
[[0,9,4,2],[8,6],[[[8,7,3,1],[],[8],3,[4,2]],4,1,0,[]],[[],[]]]
[[[2],[]],[[[3,5,2,3],10],[],[9,2,5,2,3],6],[],[[0,4,0,9],[[],[]],3,[8,5,[],[6]],[[],[],6,[7]]],[[],[9,3,1,[],[8,0,7]]]]
[[6],[6,[[7,3,5,1]],7,3]]
[[5,[[10],[0],[3],[2,4,5]]],[[8,[8,10,5,0],0,[1,7,8,1]],[10,[5,6,4,5],3],[0,3,[5,4,5,8],7],[4,[5,6],0,[0,10,7]]],[8,9],[[5,[10,3],3,[]],[7,1,8,[9],8],[],[9,[2,5],[3,5,2,4],[4]]]]
[[8,10,4,[[],1,2,8,8],8]]
[[[2,9],6,[],[5,0,10]]]
[[[2],[[8,10,7,0],[7],[10,9,7,6]],8,[[8,10],8],[[2,8,9,3],[3]]],[7,2,8]]
[[],[],[2,[6]],[[]],[1,3]]
[[],[4,4,4,[[],3,[],7,[]]],[6,[]],[[9]],[[]]]
[[[[4,5,9,3]],1,[],4,[[],[],[],7]],[[[0,6,9,8,7],[],3,[4,8,1],5]],[6,[9,10,6,9],[[9,10,2,1],[8,7,1],[10,10,3]],[[0,4,3]]],[]]
[[5,[]]]
[[4,8]]
[[],[],[0,6,[10,[5,10],2,1,[3,3,1]],8]]
[[7,10,[[2],10,7,[5,0,5],9],10],[4,[[5],[1,5,8,10,5]]],[0,1,[[2,6],[1,8],8,0],[10,[7,1,10,3,1],[],[0,0,6,10]]],[],[7]]
[[],[3],[[3,1,1,3],1],[10,9,[],2],[[[9,3],6],[[2,10],7,9,[7,8,7,10,6]],10]]
[[[0,5]],[[8,9,10,8]],[[[2,9,6],7,0,3],0,[[7,4],[5,7,0,10],[]]],[[3,9,[7,1,2,6],9,7],[[],10]]]
[[6,[9,[6,1],[6,3,8]]],[9,[]],[[[3,3,7,4,7]],[]],[[[]],[[],7,[10,3]],10,7],[[],7]]
[[[[1,3,7],[],1],5,2,[1,[10,3,7]]],[[8,7],9],[[[3,9,0,8,2],[6],0,[7,4,10]],[6,0,3,1,[6,9]]],[10,7,1,10],[0,[[1],9,7,[7,7,5,4],2],[],[[5,1,9],7,7,9]]]
[[5],[9,3,[1,10],7],[[6,6,[3],3,[0,2,2,8,7]]],[7]]
[[[4,[7,6],9,7],1,[],7,6]]
[[8,[[5,6],[6,4,3,9]],7,10,[3,[],9,[6,5,4]]]]
[[4,2,1,[[4],8,[7,4,0,8]],10],[],[[[7,3,5]],[7,5,1,[7,2,4],[6]],[4,[1],1],[7,[10,10,10,6],[9,2,0]],[[5,1,9,3,5],[3,10,4,9,8]]],[[],6,3],[6]]
[[],[[],[0]],[[2,5,[1,4],6],1,4,[3,[],[10],[2,7,8,4,2]]],[[10],7],[[[4,10,6,3],7,[],1],2,3,3]]
[[6,0,7]]
[[5,2,[4],[[3,0,8,10],0,[4,8,9]]],[[],[[8,9,7,5,3],4,6],7,10,[[5,6],[2,10,5],[9,5,6,0],1,1]],[2,3,[7,10],9,1],[]]
[[4,[2,[],7]]]
[[[6,9,6,[3,6,7,2,3]],4,[1,2,5],6,4],[9,[1],[8,[7]],2],[[[1,3,6,3,6]],0,[],[]],[0,[[9,10]],5,[2],9],[[[3,1],[10,1],[5,0,9]]]]
[[5],[2,[[]],9,[[]]],[1,5,[]]]
[[[0]],[3,1],[10,6],[]]
[]
[[[7]],[[1,[4,10,9,2]],8,[10,[7],[2,1,1,4],2,10]],[],[[[10,6,4,7],7],[],4,8,9]]
[[6,[[6,0,10,7,9],0,[5,1,2]],2],[[[3,1,6,1],7,[],5,4],[[10,10,3],0],8],[],[[[6,7,0,1,5],5,5,[3,7,2]],[6],7,3,1],[10]]
[[],[[[],[1,2,10,9,5]],[[5,7],[7,4,9,9,0]],10]]
[[9,4,8,[],8],[[3,[6],0,[3,1,10,9,2]]],[],[8,0,3,4]]
[[1,1,0],[3],[[[9,1],5,[7]],7,10,[5,[2,4,2,6],6],[[2,2],[6,0,2,0],[3,4,1,3,0]]],[8,[]]]
[[9,5],[[[],8,[0,9],[],0]],[[],7],[3],[10,9,6]]
[[8,[0,[9,5,0]],[],4,1],[]]
[9,10,2,8,0]
[9,10,2,8]
[[6,4,[9,5]],[[[10]],[[4,2,2,5],0,[3,2,1,10],5,[10,1]],0,9]]
[[7,[8,[0,1],4,0],[7,[5,1,9,4],10]],[[10,[0,7,8,5,9]],[10,6,[3,9]]]]
[[3,0,1,2]]
[[[[5,2]],5,9],[],[[[9,6,5,8],[1],[],[],1]],[[[],[3,5],9,[],8],4,[[9,6,8,9,3],9,10,[0,8,1],[]],8,[[],7,[7,5],8,2]]]
[[[[4,4]]],[8],[6,2,[8,9],2]]
[[],[9,[[],2,3],[6]],[[[10,2,9,0]],8,10,0,10]]
[[7],[[4,4,5,8,5],[9,[9,9]]],[[[4,4,1,5,6]],10],[[],[[0,0,2,10]],[[6,9,8,5,6]]],[[[],0,[3,7,1,6,6],[0,7,8,6],[9,7]],7,[2,[9,2]]]]
[[8,7,[7,[],4]],[1,[[4,0,8,7],3],[7,[7,8,1,2],10,6],8,[[3,7,10,7]]],[2,0]]
[[[[3,9,2],[7,2,9,10],4,[6],9],9,[[6,0,9,10,5]],[9,[10,5,7],5,6]],[],[9,4]]
[[[[8,9,9,5]]],[[[4,8],2]]]
[[[6,10,4],[],[7,[5],[0,9,1,4,3],8,8],[4,4,7],9],[[[3,7],3,[5,4,7,0],6],2],[[[7,1,6,0,4],[],[4],[9,0],1],[[8,3,9,6],9,[2,7,8]]],[]]
[[]]
[[],[7,6,[],[3,6,10,[9,7],4],[]],[4,9,8,[],2],[]]
[[],[4,[9,1,10,9,6],4,0],[[],[[],[10,7]],[[6,5],5,[3,2,6,3]],[2,3,10,10],[]],[9,[2,9]],[[5],10]]
[[[[2,2,9,8],[5,2,8,5,5],[5,9,5,9],4,2],7,[],[9,[2,7,9,7]],2],[],[0,9,5],[[6],[3,[],[],0,2],5],[]]
[[[1,[9,8,8,1],3,10,[7,10,2,7]]],[[],[],[[],[10,10,4],10],10],[8,9,0,4],[],[1]]
[[[7,[0,6,8],6],[[10,4,5,1,10]],[],4,7],[[[5,9],[4,4],5,2],2,2,[[7,10,3,7,9],10,6],2]]
[[],[]]
[[[5,[6],[7,9,4,0]],[[4,4],[],5,[6]],[7,[5,6,9,9],6],[]]]
[[],[],[2,10,[],[[]]],[[8,7,[8],1,1]]]
[[],[[7,0,[1,10,5,2,1],[2],[]],[[2,9,3,3],[10,9,3]],[[2],8,1]]]
[[[[5,8,6,5]],2,[3,8,10,9,0],[[5,9,1,4],[7,7],9],7]]
[[5,3],[10,5],[]]
[[6,10,[],[[8]],[[],0,[]]],[],[],[],[]]
[[5,[7,[5],[6,3,10],9,3],3],[[[7,0,0,1],9,[1,4],3,[0,5,8,7,7]],1,[2,[1],[3]],4,7],[[1,10,4,1,[10,3,3,8]],3,[[6,5],[1,4]]],[3,[[7],[2,3,3,5,3],[4,2],[8,7,9,1,10]],[[9,10,7]],10],[[[2]],7,5]]
[[4,7],[[10,[2,4]],[8,1,9],9],[[4],8,[],9,5],[[5,[1,0,1,1,8]],[[5,2,4],[],[],8],8,[[4,4,6,10,4]]]]
[[8,1],[[[5],9],9,[]]]
[[9,[],3,3],[[[10,3,4,1],6,7,[9]],10,5,2],[[0,3,8],9,4,[8,7],[]],[4,4]]
[[3],[7]]
[[1],[4,3],[6,[1],[[5],3,[]]],[0],[2]]
[[[9,4,8],[[8,8,10],[4,6],10,10],3,6],[[[1,4],4,[],[8,3],[0,0,5]],[0,[0],4,[1,9,2,6,0],5],[4]],[[2],[0],7,6,[]]]
[[[[],[9,4,7],[9,1],5,[3,4,9]],[8]],[1,[],[[0,4]],[6,1,9],2],[],[[6]]]
[[[[],10,8],[6,[],7,[7,6],[10,8]],[[],8,9]],[]]
[[6],[[]]]
[[],[7,[[0,4],[],5,1],[[8,1,7,0],0,[4,3],5],[3,[],[3,9,3],[0,4,5,2],6]],[[[5,2,0],[8],[3,10,9,3,5],[],[0,5]],5,0,[],4]]
[[[[],5],[9,[5,7,8],5,[],[5,2,2,10]]],[[9],[1,5,0]]]
[[[],[4,0,[1,7],3,7],8],[5,[],3,7,[[8,9]]],[[],[7],[[3],0]]]
[[3,8,5,[[9,10,5,5],[0,1],[2]],7],[1,1,9,4],[[[4,8,9,0],[],[],[5]]],[[],[],1,8,5],[]]
[[5,[1,0,[9]],[[1,8,10,10,1],[],[0],[4,10,9,8,5],7]],[[6,3,2,0],[6],9,[9,7,[1,0,0],5]]]
[[10,5,1,4],[6,0,[]]]
[[[3,9],5,[[0],[6]],[[9,9,3],[],8],5],[],[]]
[[8,8,4,[],[[9,9,7,3,8],[4,6,8,7,8],[10],2,7]],[10,0,1,[[3,10],[6,2,10,3]]],[3,6],[],[[],4]]
[[],[9],[2,9,[[],[5,1,0,2,1],[9,10],0],[[7,3],5,10],2],[[9,[9],3],[4,[10,2,10],[0,2]],1,[2,4,[4,1,7,1,0],[],[1,0,1]],[10,[1,4,5],9]]]
[[[[],[9,1,3],[5,0,1,7],7]]]
[[[[0,5,10],[7,8],[0,5],[7,10,1]]],[[2,10,[3],[5,4],[8,9,0,1,6]],0],[]]
[[6,[8,4,4,[10,9,4,2,9]],4,[5,1]],[1,6,5,[],[10,[7,3,10,6],[0,2]]],[4,[2,5],[3,[7,7,2,10,5],3,[0,4]],[2,9,2,[]],[2,[1],1,[6,6,5,5]]],[4,[],10,[[2,7,0,4,8]],[0,2]],[[[8,10],[7,9]],[10,5,[6,5,8,2],0,[10,8,2,9]],8]]
[[[3,9,[],[4,1,6],6],8,[[3,8,1,3,10]],[]],[5],[],[]]
[[3,10,[]],[[9,[1,8],2,[4,3,6],7],3],[0,[[9,0,7],3,9,8,[]],5,[[],[10,5,7]],[[4,3,3,6],10,[3,9,0,6]]],[[2,[4],[5]],10,[6],6,2]]
[[[[4,0,8],[4,3,8,10]],8,10,[10,0,3]],[[],0,7,5],[2,[[],[1,6,9,2],4,[8,2,6]],6,[6,[10,0]],[[],[4],[5,6]]],[]]
[[5,[[]],2,2],[[[10,4,7,9],10,8,[]],9,5],[[[10,10,8],2,[8,7,1,2],8],1]]
[[5,4,3],[4,[8],1,[[]],[]],[[]],[4,[],[[1,5,5],[]]],[6,6,8,9]]
[[[5,[10,7,7,6],5,7],6,6,4,10]]
[[2,[[]],[6,[0]],[[3,7,5,2,1],0,[9,6]],[]],[[[4,9,6]],3,8]]
[[[]],[2],[[[4,6],[6,4,10,7],10,[4,5,10]],7,[4,7,[9,1,3],8]],[[9,5,7,[],9],[8],[],7,[[1,1,7,2]]]]
[[],[[[7,6,1,0],6,7,7]],[6],[[],6]]
[[],[],[[],[[]],[[8,5],9,[2],8,5],4]]
[[1,2,[9,[7,5,1,0,9],[8,7,2],0,[4,10,10,7]],9],[9,[],[[0,8,10]],10]]
[[5,[[10,7,3,0,9],[0,6,4],[9,10,0]]],[1]]
[[[],3],[[0,[6,10,6,3,10],[3,7,6,0,5],10,1]],[5],[[]],[10,0,[],8]]
[[[9,[5,10,6],7,0],8,[6,6,[2,0,9,5,1]],[[],3,[10],7],7],[[[2,3,9],[2,6,9],[10,2],[]],[2,[0,6,9],[8,5,4]],[4,[4,8,6,4],[1,1,1,4,8],10,1],4,[5,1,[]]]]
[[[],[]],[[[10,4,6]],[[2],4,[1,1,3]],[7,9,[3,3,10,5]]]]
[[0,6,0,[10,6],10],[7,10]]
[[[],[2,[8,3],[3,5,9,9]],[8,[8,9,2],2,[4]]]]
[[7,6,[[5,2,8,5,0],[5,2,5,5,7]],4,6],[[9,2,5],[],7],[6]]
[[5,0]]
[[[2,[3,5,6,6],9,[6,8,8,7,2],0],1,2,7,[0,2]],[4],[9,0,4]]
[[[[4],0,[4,6],5],[],[3,4]],[1,7,[8],6],[[1,0,[],[2,1,7,5,7],7],[6,10],[],6,[8,[9,9,9,5],2,1]],[7,[],5,[]],[7,[]]]
[[[4,1,[10,0]]]]
[[1,[],2,6,[[6,10,2,4]]],[],[4,5,0]]
[[[],8,10],[[5,[10,9],0],10,8,3],[[[5],8],0],[]]
[[0,10],[[[4,6]],[]],[10,0],[],[6]]
[[6,0],[[],8],[3,[8,[3,4,10],9,[6,5,10,5,9]],4,[2,[6,3],8],[10,[2,6,2],[0,4],[4],6]],[[[],[8,1]],8,5,8,3],[3,2]]
[[[],6,[[9,3,0],[2,2,10],9,8,[]]]]
[[[5,0],[0,4,8,[7]]],[[[4],2,4,[1],[3,7,0,6,7]]]]
[[[[7],2],[[8,9]],[],4,10],[[0,[9,0,7]],[[2,9],10]],[]]
[[[],4,[0,3,0],5],[7,0],[2,8,[6,[3,8,10,3]],5],[],[[3,[10,9],[1,6]],4,8,[[],7,[2,6,10,9],9,[8,6,3]],1]]
[[[[0,8,6,9]],0,4],[[8,6,5,4],8],[7,[[],[10,0,9,5,9],0,6]],[10,1,3,[[8,9,9,8],[0,10,7],[2,10,9,2,10],4,2]]]
[[3,[]],[1,0,10,4,[[2,1,9,1],[]]],[0,[[],[9,1,1],1,[10,7,7,2,1]],5],[[[8,3,4,8],7,4,8,[7,4,9,1]],[5,[0,6,10],[]],[],8],[[9,0,[10,5],1],6,[5,[1,4,1,0,8],[5,10]],7]]
[[1],[3,[[],[6],[1,6,2,9,8],[10,3,3,5]]]]
[[[3,[4,9,8,5,0]],[[3,2],[],[9,1,3,7,7]],[7,[],[7],4],[]],[2],[6,5,6,[]],[[2,[6],[6,7]],7,8],[5,[[7,6,8,6,9],[]]]]
[[[10,[],2,3,[]],[[]],[7,[],[5,10,7,1],2],[4,[3,7,2,1,2],[7,8,4,0]],[7]],[[],[[6,3],6,[5,7,7,4],[1,7,3,4,0],6],5,1,9],[[6,[7,0,4,10,8],6,[7,7,10],[1,7]],6,3,10]]
[[],[2],[[0,4,[6,6,10,8,4],[7,8,10,1],0],[[9,6,8,0,10],1,[2,5,2,10,1],10,8],3,10]]
[[],[],[],[[[4,0,10,8,2]]],[[],10,3,2,[[],7]]]
[[[[6,6,4,4,4],[1,4],9],[9],[[3,7,0],[10,8,10],6,[6]],7,[]],[]]
[[[[5,0,4],[9,2,7,0],[4,4],2,6],4,7],[[[0,4,9],[5,9,1,1,5],[]]],[7]]
[[[[8,5,9,4,8],4]],[],[[[9,1,4,9],0,2],10],[2,[6,2,9,[3,4,10,2],[5,8]],[[6,5,6,6,9],[3,2,6,3,5]],[[],7,[8,3,8,7,4]]]]
[[5,[],5],[[5],9,[8,[3,6],[10,5,7],10,2],[],[]]]
[[0,[[7,10],[7,2,6,5,2]]],[],[[[7,6],[],0],2,[[2,5,3]],0,[5,[8,7,1,3,1],5]]]
[[[10,9,[],6]],[5,3],[3,5,10,[[1],[7,5,8,7,4],[4,4,2]]],[[4,[7],1,[10],[3,8,1]],[[],[10,0,10],[7,4,2],[5,6,1,4]],[[10,4,5],[2]],[4,[5,2,5,8],2]]]
[[[],[[6,1,9],5,[8,2,8],[5,5]],5],[10,[[10,5,8,10],10],[[3,8,1,6,0],3,8],7],[6,[5,[3,7,3,0],6,0,[0,6]],10,6]]
[[],[[[7]],7,5],[[[8,3,0],[9,8]],3,3,[[3,1,8,1,9],10]],[[[9,4,4,7],[3,0,7,1],[6,2,9,4],[0,2,3,8],[]],[8,1,[8,6]],0,[],[[10]]],[2]]
[[2,[[2,6,10],[],7]],[[9,8,2,[10,10]],3,0,[6,0,1,3],[]],[[],9,10],[[6,10,[0,1,6,8],6,[7,5,10,10]],[[10,4,2,5],9,[4],0,0],[[9,3,5],[],[7],6,[10,0,4,7,6]],[[8,6],10,6],[]]]
[[[3],[5,9,1,10,[8]],6,4],[[[],8,4,2],1,[10,[1,10,10],10],8],[0,[],[[6,2,1,10],4],7],[0,3,[10,[9,4,4],0,4,[1]]]]
[[],[[9,[1],[],[]]],[6],[6,[5,[8,5,5]],[9,9,[6],[8,3,7,5]],[9,[5],4,9,[10,7,8,9,4]],4],[[[4],[9,1,8],7,8,[4,2,10,10,1]],[8,7,[],10]]]
[[],[8,9,3,5]]
[[10,[[5,5,1,6],[],5],8,[6],6],[]]
[[10,2,[],[[]]],[2,[6,8,[10,4,1,7],3],[4,2,[9,1,3,6]]],[[]],[[2,9,[4,2,10,7],8],[10,[7,1]]]]
[[[6,7,[4,0]]],[[[5,7,5,10]]],[10,5,[[5,4,3,5,6]],10,[]]]
[[10],[],[[[6]]],[],[[6,[7,4,5,4,8],[],[2,0,9,5,3],2],[[8]],[0,10,2,[1,0]]]]
[[[1,10,[5,6]],[[10,3,3,1,10],3,2],[[7,4],6],[],[]],[10,[[2,9,2,5],2,[6,6,10,8],2,8]]]
[[[],[3],[[8,6,5,2,2],8,[9,3,1,1],[0,4,9,10]],4]]
[[],[[9],7,10]]
[[[[7,6,10],6,6],[9],[1],7],[3,9],[7,[4,4]],[1,[4,3],[[5,7,9,4],8,[0,10,5],[4,1,10,6,3],[7]],[[]],[7,10,[4,4,6,5,10],9,[7,0,10,7]]],[[]]]
[[],[[[6],3,[]],[[3,6],10],9],[[[3,4,0,3],5,3,9]],[0,10,9],[3]]
[[5,0,[6]],[[[],2],[[5],2,[5,8,2],[2,8,3,9,1],[7]]],[10,[4,[4,7,3,9,2],7,[6,0,0,7,2],0],[10,[10,4,3,7],1,10]],[3,[[9,10,9],[8,1,4],6,[],5],[8,[6,1],[6,2]],[[5,9],8,5],[[8],[6,9,6],7]]]
[[7,8],[[[6,5,8,0,7],[1,2],[4,6,4]],[],[[],8,10]]]
[[[[10,5],3,[5,2,2,6,3]]]]
[[10,[[5,0],4,1,[0],[5,8,0]]],[8,0,10,4],[1,8,[9,[7,8,8],4,[5,0,6,0],0]],[[],6],[6]]
[[[0,0,5,10,[9,10,0,5,8]]],[0,9,[[],[2,9,5,2],[7,7]]]]
[[[10,0,5,4,[]],8,5,8],[[10,4,[7,5,3]],9,4]]
[[4,5,10],[7,9],[2,[2,[3],[5,5,2]],5,2]]
[[10,1,[[5,3,6],1,7,[1],[7,9,8,5]],6,10],[6,5,[5,9]],[],[[6,1],8,3]]
[[6,[3,4,4],[],[8,[7,6,1,10],7,[4,6,1,4],3]],[10],[[0]],[[8,3,[8,4,4,8],8]]]
[[[10],[[5],3],1,4,0],[[1],2]]
[[5,2],[3,8,[]],[[[5,8]],5,2,9],[[5,1,6,[0,6,10,4,10]]]]
[[[[5,2,10,8],3],[[1]]],[0,[0],[3,[10,2,0,2],[]],[10,[8,2,7]],0],[[7,[5,2,0,7,8],[9,6,5,0],10],[[10,5],[4,4,9,6],[],4,6],0,[],9],[0,[[],[10,10],3],5],[[[10,10,3],[],[8,2,3],5,[2,1,9]]]]
[[4,2],[],[8,9,[],1],[],[]]
[[0,[10,[1,10,5],[3,2,6,7],5],[[7,3,10],6,8,[6,8,8,4,2],7],9],[0,2]]
[[[0,[],8],[[8,7,4],10,8,9],0,[2,6,[3,2,9,7],6]],[0,[0,5,6]],[2],[[[0,4,1,2,9],5,[3]],[[6,10,7,8,9],0,[1,4,6],[9,4,10,9]],[[],1]]]
[[3,[]],[[0,3],[8,[4,5,7,10,5]],10,[],[4]]]
[[[]],[],[[],[]],[],[]]
[[[8],[9,[10,4,0,9],2,6]],[0,[6,5,[4,5,10,8,2]],6],[8],[7],[10,[8]]]
[[],[4,[[4,7,0,5,3],2,[7,6,5,1]],8],[]]
[[[[2,2,3,7],0,[6,3],[5]],[8]],[[[10,5,5,10,2],0,8,[5]],[],[[8,10,1,10],1,[4],[1,8,1,8],1],10,[[10]]],[2,6,[[]],3,[8,[0],[0,0,0,9]]]]
[[5],[[[5,1,1],[1,2,10],5,10],2,[[3],[],3],10,[1]],[]]
[[7,5,7],[],[9,[6,4,8,[5,2,10,2],5],4],[],[3]]
[[8,5,6,10,[8,[10],0,3]],[6],[[[]],[6,5,[0,4,9,1,9],[1,6,2]],[[4,7,2,7],1]]]
[[8,[0,8,[8,4,4],[10,5],[10,10,1,2]],10],[1,10,[9,9,[10,1],7,6]]]
[[[5,7],[4,[0,1,1,2,6]],[5],3],[]]
[[4,[4,[6,6]]],[[[],[9,4,4,2,8]]],[[[7]],[3],[],[3]]]
[[[4,4,[0,3],5],3,6],[[4,[2,9],1,[]],2,0,[]],[6],[8,[[]]]]
[[10],[1,[8,[],10],3,9],[],[[5,7],7,8]]
[[[],3,5,[[3,4,8,2]]],[3],[10,[[2,3],1,9,[],[7,9]],[[5,6],10,3,0,1]]]
[[1],[5]]

144
inputs/input.14 Normal file
View File

@@ -0,0 +1,144 @@
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
510,167 -> 514,167
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
498,175 -> 498,176 -> 505,176
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
489,79 -> 493,79
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
483,85 -> 487,85
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
480,82 -> 484,82
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
494,144 -> 494,145 -> 504,145 -> 504,144
486,54 -> 490,54
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
492,60 -> 496,60
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
497,147 -> 497,148 -> 513,148 -> 513,147
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
474,70 -> 478,70
466,103 -> 466,104 -> 481,104 -> 481,103
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
471,85 -> 475,85
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
480,70 -> 484,70
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
468,70 -> 472,70
480,60 -> 484,60
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
477,68 -> 481,68
483,79 -> 487,79
495,85 -> 499,85
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
474,82 -> 478,82
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
495,63 -> 499,63
489,63 -> 493,63
477,79 -> 481,79
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
501,170 -> 505,170
497,147 -> 497,148 -> 513,148 -> 513,147
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
489,85 -> 493,85
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
471,68 -> 475,68
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
486,76 -> 490,76
483,73 -> 487,73
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
466,103 -> 466,104 -> 481,104 -> 481,103
504,167 -> 508,167
507,170 -> 511,170
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
507,164 -> 511,164
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
474,66 -> 478,66
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
486,120 -> 486,122 -> 482,122 -> 482,128 -> 491,128 -> 491,122 -> 490,122 -> 490,120
489,57 -> 493,57
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
480,76 -> 484,76
488,36 -> 488,32 -> 488,36 -> 490,36 -> 490,26 -> 490,36 -> 492,36 -> 492,26 -> 492,36 -> 494,36 -> 494,32 -> 494,36
477,63 -> 481,63
492,82 -> 496,82
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
513,170 -> 517,170
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
483,57 -> 487,57
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
498,175 -> 498,176 -> 505,176
486,60 -> 490,60
497,147 -> 497,148 -> 513,148 -> 513,147
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
486,82 -> 490,82
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
477,85 -> 481,85
493,23 -> 493,21 -> 493,23 -> 495,23 -> 495,18 -> 495,23 -> 497,23 -> 497,19 -> 497,23 -> 499,23 -> 499,18 -> 499,23 -> 501,23 -> 501,18 -> 501,23 -> 503,23 -> 503,15 -> 503,23 -> 505,23 -> 505,16 -> 505,23
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
483,63 -> 487,63
513,151 -> 513,155 -> 510,155 -> 510,161 -> 519,161 -> 519,155 -> 515,155 -> 515,151
466,103 -> 466,104 -> 481,104 -> 481,103
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
463,98 -> 463,97 -> 463,98 -> 465,98 -> 465,94 -> 465,98 -> 467,98 -> 467,94 -> 467,98 -> 469,98 -> 469,88 -> 469,98 -> 471,98 -> 471,90 -> 471,98 -> 473,98 -> 473,97 -> 473,98 -> 475,98 -> 475,95 -> 475,98
494,144 -> 494,145 -> 504,145 -> 504,144
493,39 -> 493,43 -> 489,43 -> 489,51 -> 501,51 -> 501,43 -> 496,43 -> 496,39
490,131 -> 490,134 -> 482,134 -> 482,139 -> 501,139 -> 501,134 -> 495,134 -> 495,131
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117
494,144 -> 494,145 -> 504,145 -> 504,144
476,117 -> 476,114 -> 476,117 -> 478,117 -> 478,110 -> 478,117 -> 480,117 -> 480,110 -> 480,117 -> 482,117 -> 482,114 -> 482,117 -> 484,117 -> 484,113 -> 484,117 -> 486,117 -> 486,113 -> 486,117

19
inputs/input.15 Normal file
View File

@@ -0,0 +1,19 @@
Sensor at x=3482210, y=422224: closest beacon is at x=2273934, y=-202439
Sensor at x=3679395, y=2737332: closest beacon is at x=4104213, y=2980736
Sensor at x=3173475, y=3948494: closest beacon is at x=3494250, y=3554521
Sensor at x=27235, y=3642190: closest beacon is at x=-190885, y=3635525
Sensor at x=3851721, y=1754784: closest beacon is at x=3145586, y=2167751
Sensor at x=327074, y=3250656: closest beacon is at x=-190885, y=3635525
Sensor at x=3499970, y=3186179: closest beacon is at x=3494250, y=3554521
Sensor at x=150736, y=2522778: closest beacon is at x=-85806, y=2000000
Sensor at x=3000768, y=3333983: closest beacon is at x=2564067, y=3163630
Sensor at x=1751302, y=1660540: closest beacon is at x=3145586, y=2167751
Sensor at x=2591068, y=2923079: closest beacon is at x=2564067, y=3163630
Sensor at x=48946, y=3999178: closest beacon is at x=-190885, y=3635525
Sensor at x=3695475, y=3863101: closest beacon is at x=3494250, y=3554521
Sensor at x=1504031, y=2760: closest beacon is at x=2273934, y=-202439
Sensor at x=3021186, y=2667125: closest beacon is at x=3145586, y=2167751
Sensor at x=1514629, y=3771171: closest beacon is at x=2564067, y=3163630
Sensor at x=234064, y=616106: closest beacon is at x=-85806, y=2000000
Sensor at x=3990843, y=3393575: closest beacon is at x=4104213, y=2980736
Sensor at x=768875, y=2665271: closest beacon is at x=-85806, y=2000000

62
inputs/input.16 Normal file
View File

@@ -0,0 +1,62 @@
Valve AV has flow rate=0; tunnels lead to valves AX, PI
Valve JI has flow rate=0; tunnels lead to valves VD, HF
Valve FF has flow rate=0; tunnels lead to valves ZL, CG
Valve CG has flow rate=10; tunnels lead to valves TI, SU, RV, FF, QX
Valve RC has flow rate=18; tunnels lead to valves EQ, WR, AD
Valve ZJ has flow rate=0; tunnels lead to valves GJ, WI
Valve GJ has flow rate=21; tunnels lead to valves TG, YJ, EU, AZ, ZJ
Valve VJ has flow rate=0; tunnels lead to valves UJ, AA
Valve ER has flow rate=0; tunnels lead to valves QO, ZK
Valve QO has flow rate=24; tunnels lead to valves MF, ER
Valve LN has flow rate=0; tunnels lead to valves ZR, TI
Valve SU has flow rate=0; tunnels lead to valves CG, LM
Valve AJ has flow rate=12; tunnels lead to valves QX, JW, TR, MK
Valve YJ has flow rate=0; tunnels lead to valves GJ, EQ
Valve JW has flow rate=0; tunnels lead to valves YI, AJ
Valve WI has flow rate=13; tunnels lead to valves XO, ZJ, ZL
Valve VS has flow rate=0; tunnels lead to valves XL, VD
Valve TI has flow rate=0; tunnels lead to valves LN, CG
Valve VD has flow rate=17; tunnels lead to valves TR, VS, JI, GQ, VO
Valve TX has flow rate=0; tunnels lead to valves FV, WR
Valve HP has flow rate=0; tunnels lead to valves AX, ET
Valve BK has flow rate=0; tunnels lead to valves PI, AD
Valve ET has flow rate=0; tunnels lead to valves ZR, HP
Valve VY has flow rate=0; tunnels lead to valves KU, LM
Valve DZ has flow rate=0; tunnels lead to valves VO, AA
Valve ZK has flow rate=0; tunnels lead to valves FR, ER
Valve TG has flow rate=0; tunnels lead to valves GJ, AX
Valve YI has flow rate=0; tunnels lead to valves JW, LM
Valve XO has flow rate=0; tunnels lead to valves ZR, WI
Valve ZR has flow rate=11; tunnels lead to valves KX, AZ, ET, LN, XO
Valve EQ has flow rate=0; tunnels lead to valves RC, YJ
Valve PI has flow rate=4; tunnels lead to valves BK, KX, VQ, EU, AV
Valve VO has flow rate=0; tunnels lead to valves VD, DZ
Valve WR has flow rate=0; tunnels lead to valves TX, RC
Valve TF has flow rate=0; tunnels lead to valves FR, KU
Valve FR has flow rate=22; tunnels lead to valves ZK, TF
Valve MK has flow rate=0; tunnels lead to valves AJ, YW
Valve AZ has flow rate=0; tunnels lead to valves GJ, ZR
Valve TC has flow rate=0; tunnels lead to valves KU, RO
Valve GQ has flow rate=0; tunnels lead to valves MF, VD
Valve YW has flow rate=0; tunnels lead to valves MK, KU
Valve AA has flow rate=0; tunnels lead to valves RO, EI, VJ, VQ, DZ
Valve MF has flow rate=0; tunnels lead to valves QO, GQ
Valve ZL has flow rate=0; tunnels lead to valves WI, FF
Valve LM has flow rate=3; tunnels lead to valves YI, SU, UJ, VY, HF
Valve KU has flow rate=9; tunnels lead to valves XL, TC, TF, VY, YW
Valve FV has flow rate=23; tunnels lead to valves KV, TX
Valve EU has flow rate=0; tunnels lead to valves PI, GJ
Valve KV has flow rate=0; tunnels lead to valves FV, OF
Valve QX has flow rate=0; tunnels lead to valves AJ, CG
Valve RO has flow rate=0; tunnels lead to valves AA, TC
Valve TR has flow rate=0; tunnels lead to valves VD, AJ
Valve VQ has flow rate=0; tunnels lead to valves AA, PI
Valve HF has flow rate=0; tunnels lead to valves JI, LM
Valve RV has flow rate=0; tunnels lead to valves EI, CG
Valve KX has flow rate=0; tunnels lead to valves PI, ZR
Valve UJ has flow rate=0; tunnels lead to valves LM, VJ
Valve AX has flow rate=5; tunnels lead to valves TG, AV, HP
Valve XL has flow rate=0; tunnels lead to valves KU, VS
Valve AD has flow rate=0; tunnels lead to valves BK, RC
Valve EI has flow rate=0; tunnels lead to valves RV, AA
Valve OF has flow rate=19; tunnel leads to valve KV

1
inputs/input.17 Normal file

File diff suppressed because one or more lines are too long

2192
inputs/input.18 Normal file

File diff suppressed because it is too large Load Diff

30
inputs/input.19 Normal file
View File

@@ -0,0 +1,30 @@
Blueprint 1: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 18 clay. Each geode robot costs 4 ore and 19 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 4 ore and 12 obsidian.
Blueprint 3: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 12 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 4: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 4 ore and 13 obsidian.
Blueprint 5: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 10 obsidian.
Blueprint 6: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 4 ore and 8 obsidian.
Blueprint 7: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 8: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 6 clay. Each geode robot costs 3 ore and 16 obsidian.
Blueprint 9: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 3 ore and 17 obsidian.
Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 9 clay. Each geode robot costs 4 ore and 16 obsidian.
Blueprint 11: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 4 ore and 18 obsidian.
Blueprint 12: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 12 obsidian.
Blueprint 13: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 5 clay. Each geode robot costs 3 ore and 18 obsidian.
Blueprint 14: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 15: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 16: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 3 ore and 20 obsidian.
Blueprint 17: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 2 ore and 11 obsidian.
Blueprint 18: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 17 clay. Each geode robot costs 3 ore and 11 obsidian.
Blueprint 19: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 2 ore and 17 obsidian.
Blueprint 20: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 7 obsidian.
Blueprint 21: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 15 clay. Each geode robot costs 4 ore and 17 obsidian.
Blueprint 22: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 15 clay. Each geode robot costs 2 ore and 13 obsidian.
Blueprint 23: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 24: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 10 obsidian.
Blueprint 25: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 2 ore and 20 obsidian.
Blueprint 26: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 14 clay. Each geode robot costs 2 ore and 16 obsidian.
Blueprint 27: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 28: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 2 ore and 12 obsidian.
Blueprint 29: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 2 ore and 15 obsidian.
Blueprint 30: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 2 ore and 9 obsidian.

2500
inputs/input.2 Normal file

File diff suppressed because it is too large Load Diff

5000
inputs/input.20 Normal file

File diff suppressed because it is too large Load Diff

1677
inputs/input.21 Normal file

File diff suppressed because it is too large Load Diff

202
inputs/input.22 Normal file

File diff suppressed because one or more lines are too long

71
inputs/input.23 Normal file
View File

@@ -0,0 +1,71 @@
..#.#.#.....#.#.###...#..#.#.##...#..#.#....#....#.###..#.#.##.#.#####.
...#......#.##.#......#...#.##.....#.#.##.#####..##.##.#...#..##..#.#..
##....###.###..###....#.#..####...#####..#..###.##...########..#.####..
#.#..###.#.#..#...###.......##.###.##.###.##.#..##..#.#.#..#..#..#####.
##.#..###.##..##..#.###.....#...#..#.##.#.###.####..#.###.#.#.###..###.
#.#####.####......###.###..#..#...#.......##.###...#.#.#...######.#.###
..###.#.#...##.###.#.####.###.##...###.###..#...#.#######.##.#.##.#.##.
##.##..##.#.####..####..#.##...#.#.#.###.###.####.#....#..#..##.#..####
.#####...#####...####...#.##.##...#..####..#.......#..##.#..#..##.####.
##..###..##......####......#.##....#....###..#..##...#......###.#.####.
.#.#.......#.###.##......#..#..#.##....##....##.####.#.##..###..#.#####
....#..#....##..##########...#...#.#...#.##.#..##...#.#.###.##..##..###
#.#..#.###.#.#..###......###.#..#..#.#.#.##..###.#.##.##..####.#.#....#
..##...###...###....###..###.#######..##.....#..#.#####.#.########...#.
..#.#.....####..#..###..#.......#.#..#.#...#######..###......####...#..
##.##.###..##..####.#..#....##.#....#.#.###.#..#...####....#.###.#....#
.#.....##.###.#.##...#.######.#.######.#..##..#.##...##....#...#####.#.
#..#....#.....#.#.......##.......##..#.#....#..#.#####..#...#...###.#..
##..#....####.#....##....##.###.#....#...###..####..##.####........#.#.
###......#.#.#.##.##.#.#....#..############.#.#..##.##.####...#.#.###.#
#####.####.#.#.####..#...#.###..#.#.#....##.#.######.###.##.####.....##
...###.###....###.#.#.#.#.#..##.#..#..#..##.#....###..#.#.#.###....#.##
#######.##.##.#..##.###...#..#.#..#..#####.#..####..###.#....##.#..#.#.
....#..#...#.#.##.#.####..###.#.#..#.##.#.#...........#..#..#.##.##.##.
.##...#...###....##.##.....#....###.#####...#.##..##..#..##.....##...#.
###..#.##.##.#.#..##.....##.##.###.#...##.#..##..########.#.#.###.#.#.#
.####...##..##..#.##.#..#.#.###...#...##.###..##.#.######..##....#..#.#
.##.#.....#...#.###.....#..#...##...##.###.#.##...##.#......#...#...#..
..###.#...##..##.##........#...##.#.#.##.#....###..#######.#.##...#....
###..###..#.###.#.########...#.##.#...#.#...###..###..#...#.#.##...##.#
..##...#....###.###..#..##.####.#.##.....#.####.....###....#..#.##.###.
#....#.###..##...#...#....#..##...####..#.....#..#...####.#..##.##....#
##.##.#.#.##...####.######.#.#...##..###.....###...#..#######..#####.##
#.#..#...#....###.#.##.#.#....#..#.###.##.###.##.#..##..#.#..#...##....
#..#..##....##..#.###.#..#...#.#..##.###..#.#..#...#.#..#...##.#####.#.
#..#...##..###.#...#.######..###.#..##.##..####.....####.#########.#.#.
#.#######.###.....#....##.#.#........##.##.###...##.###.#.##.#.########
.##..##.#..#..#..#.##.########.##....#.###.#....#######...#..###.######
#.#....##....#..##.#.#.###..####...######.#####.#.#.#..#.#.###...###.##
#........###..#.####......######.#...##...#..#.#..#.#.#.#...#.#.####.##
###.#.#.#....##.......###...#.###....#####..#....###.#.....#.##.#....##
..#.#.####.#.#.#..##.##..#.#.##..#...###..#.#.###.#.#...##.###.###..#..
##.#..#...##..##..###...##..#.###..#..##..#..#.....#.#..###..##.##.###.
..#...#..####..#.##.##.#...#..#..#..##.#.####.##....#...#.#.#####..##..
.....##...#.#......#..##..####...###..####..#........#..#...#.####.###.
.##.#..####.######....###.#.###.###.##...###....##.##..####.#...#.##.#.
.#.#.#####.#.#.#####.###...###.....##..#.#.#.##.#.###....###.#...#..#.#
##.#....#..#.##.##....##.#.###.###..#.##.##.##.#.#.#....#..#....#.#.#..
...#.#.###.....##..#####.###.##..#..####.#..####.#.#.#.####..#.##..##..
....##.##.###...#####.#..#....##..#..#.#.#.#.#..#.#...#...#.#.....#####
.#.##...#.###...#.#.#..##.##...####.....##.....#...##..####.#.#.#....##
.....#.#.##...#....#.###.#.##.###...#####..#.#.#...#####.#.#.##....##.#
.......##.##.....#....#..####...#....##.####..#..##..#...#.#..####...##
###.....####.##....###..######..#..###....##...##.#.###...##.##..##...#
.#.##.#.##....####......#.#..#.......##....##.##..##..#..##.##.#####..#
#.#....######..###..#.##...###..#.##..#.#...#.#.#.#.#...###.##.#.##.#.#
.....#..###..###..#..#..###..#...#.#.#.#.##..###.#.#.#...#......#...###
###..#..####.##.#...###...###.#.#..#...###.####.#...#...#.....#.#.###.#
###....#######.#..#....##..######.##.#.#..##.#.##..#.#...#...#.#.#..###
##.##..#..#####..##.#..#..#####.###.##.#####..####..#####.#.....###.##.
...##.####...#..###..#.#.#...#..##......#####.#.#.##.......####.....##.
.#....#.#.#.###.##.#.#..##...####.##..###..##..#....#...#####.#...##.#.
#....#.##....#...#.##.####..#...#.#..#.....#####.#.##.#.#..####.##.#.#.
....##...##############.#.##....####.#.#.#...##.###...###.#....##....#.
..###.#.#.#.##..##.#.##.##..#.#.#..#....##.#..#.######..##.#######.#...
###.#..##.#.###.##..##.#.#....###.#.##....##..##.##...#.#.###..#...###.
##..#..##.......###.###...##.##.#.#.##.#.#.##.#.#..#..###...###.##.#...
##..#####..#.#.#..##.#..###.#.#...###.#.##.##....###....#.#.#....##.#.#
#.###..###......##.###.#...####.#.##..##.#.#...##....#####.#.###.###..#
#.....#....#.##.##.#.#...#.#.####..#.###...#.####.####..#...#.##.###...
.#.#.....##...#.#...####..####.#.##...#..##.#..###...###.#.#.#.#.######

300
inputs/input.3 Normal file
View File

@@ -0,0 +1,300 @@
jVTBgVbgJQVrTLRRsLvRzWcZvnDs
dhtmhfdfNlNNldfqmPCflqGbNZDHsDWcRzvczWsczZNzHz
tmwwwCCfbJSMbwMb
hsrZZhHlhrHmPPbMbDFDQdnQgLfMFDdDQQ
GpBtwtqrcCcjgnLgqfgDDgRn
cJwVwpCpGJctJtBcCrSCGrVJhlsbvSvTvbmHmmsWmHslmsHm
gCtWJvmfmGGwVVMhJw
nzRSpZbSVFFRDFSDzcplddqplqMhQMclMp
zFLszzRTDnZnbTZTRZsVNgCjrvfvgtvNmtfvLW
glRQRpQQtQtGtQws
TnmbLqvBFRFFLPBFnPbvRBhshTtHWhwzdwtHdsdzWhws
qmCLPNmCFnLBnmPPqVbFLRrJjVggDgJjlZVVDjDlDD
vRRgpWvPQFdTFDDNQs
bqtCmltmlbwqLVLZqwtmLBBTMcGBddTTBgFNGcZGMD
bbtmJmjlVlwblwwbwzbbvrrznvzShgRhRvhfWrWn
ZMhThfNcpbbMNNjsHpmpsRqsPmRs
wQjDgggQDPqqDlsD
SCwSzvLVCSVtQVgLnrccfdGdTdZfcZMtjJhG
wNnNmNHnNPPwwPGCrLSZZvdVVZvBtMMvdm
WQzlhzjzbBtMMlBrMl
szbgWhJjTTcsWTqgzsqcsGHfwNcwfwnHHrCGCPPGwr
CNsbpFCMSrmDhQHNNGmH
fQPPPcqvljQzjVDDgRBhGGqDgqqD
ZctlcVzcfltQtnrndbQMCM
NQjQjQvZvZjcvrrrNjgTQgBQwTJsJswJlbGstqqtmGhmwhqw
PWpHRzRnPHHSCnPFwlqhbtqGZClJqGqG
ZzVpMpWPHnVzzpWzDRzSZrcdDQdrQNrcQgQfjcNfjf
BSZMtdtZBzMFvhCbBJDbhDDC
qcqVVmccrmVcjrlHqTrjDJRPQhWvPWWfPvblffDf
cHTrbGwpmGwVjdFMnzpLznMztd
DGDGGbNgTgJQQLMRMMTNVzvPsPbdsfPVsdVVZfPf
lcCmmlpwwnwSjCHtFpCpHzCrZsVrBZZzdvDfVrsfZd
lSHwnjpFmppHqppttttcFmnhMLGNRLhTMDqJLQNLLQNLhJ
WqWfDWBjBjLbfcbbqGbWqQsrFFztsppMFCzgCJzJCrFpCM
VRlhdHZTZVRRmZwlmFrJwFpMMDDrrrtJwg
PPVddvvDZmRmHvndTHmLcbcjSjLQBGWGGQWSqP
HHvgvwHMPMwHwmcRfJNFchFGNNCm
BsTDsjzBCCBJGffN
jznSnSdqzqnQTbdDljQjQSMHWWvvgWvtZlrWpPfWwtPr
DJCJJCNjCDRfDfDRhDnNhfjFPgbGbddBTjFdTFTPbgGSdF
cmMcMVqBZVcwsGFgGqgWdFqb
vcZVzwmHVcrtrwMMvvmBHwNNCDpQRfhLhrNJNfJDDDRC
VWSSScsncpDRdnsWsVncVzTwMMMHtMTrLTLMMVHM
fjJvQqBCQNhfQlZZnqmFHLFMTFTzwzLzrHMB
CqfjjQZJPjjvpRppDPgbnSnP
tLnjNwjRWttdCwRLsfGzfzPbzbWbQQPT
cvvBvlBrFrlTffsbfTqZ
vmrFpsrvFMMMNwhtDwhN
wzgRNqwtgzMWtqGwCssBBSBZnSRsrQQS
bbjLTmpjpHcpVncVdmffPCDrjZDSDsZffDQC
pbVFncvvbpbbHJJHVdvqMGMJNwWlNlJMwqzlNM
TdszlzFsRQqFdRzqwwQGlFsGmmSBBdmdVVmgSZdSPZBBBmSD
HMCCMbJHJJLHSmSvZLBcSDBP
NWbhPjfrbbNfWCPjhNnGsNzsqpQszTQGRwGQzR
ppQpTNCPBTlNBVmNQTNrrrrtqsrWbGrVFWqhZb
DMvDHnjRvMDLghhhgbqZWbqFSS
vWvMRRJDLMnHLJjDwWnnndcllNTzBmClQBpBBzQQzCBzCJ
VsNZfPMnrCnlCnWtbvBbvwtTbZwT
JhJQdQhmRHDRdLmHJhljhphgGwtttmcvbwwTWtvtbGBttc
jqLpjSLDHlhnffCMzsqCPP
JzJdLRmmzJwrLLwLJwLTWwBrMrpHlFnScVVqccrBHSlc
tvQDQhjhvbqFqFSpjHSV
QbgZtsgfbNNQbgbsbQRfmWRJwJGWWTPRwqzR
MwvDgpwszSpSJPsssMccTQfTDfTQRTljfRfT
PmGbWhbVtZWPTqRrcTrrjTrt
NbZbWHBmVGmLbZVBVNLPsMBzwSSzMJMCsCzvnvSp
cTpgTnpzbZlJHTZm
jRrLVtqtvtrjqsHZhvpmBfJHmhhp
FqDsFLCwCVRDqwgNQcQMwnncnMpg
sCCtssdZdZJmMbNJDmtmJzLSrcGfHGLTHDHnGLrHTSSn
gQwRRWqwqgpggFWPjPpFnSTSnHNfLLQrccrLGHLL
qqlpqhjFwPgPwvvRgFlPdslZCzMZtVdtVdVMtJlN
BWVmPtRVRRWDNtZBVQzCfdscmfjcfdfzzSfz
MhgJLbGggHbqpGgpgJbrFJdjwsCChCzllzCdjDSszCCD
grpDLFrbgpJnqJrHGFHGqMHBBPRWQTPWZBQVTQWnPNVvBt
gJfggdmHDgfJJWzCcbqvcqcmTG
hLZlRBZNlBlrpprzrWqvtHvvGtbvHT
sNLRjHZLNVnZZVLppnhNsMFJSjFPPQMjwgMPPfDMfS
mDDzHfrPBvJRJhpBRg
SsTSTwJwcbCtwssGFVWppgZRbLpLRNhpLhbLvg
ttVCGjTGrfJJMfjD
ffhcsTjnfqHLqvZSHvHB
CsgmPVmstsQVpRbHBvFbHBDMvZLZGB
ppgpmmRVpVPwPrrrTNlcrwrlWs
NDtssPNBjQtCtCcT
ZZqncfqhZqhJZFTJTllCGVljSl
ndrWbfZwWhngwbqbZnMZcwWhDmmLDmzvHPvzNLdmzsvBBHHP
FQtptwMppSFQRRQfSfvTrTJJJTrvLjMMJbgJ
CcDqWBWzbldcchDGCWBCBhdGrvhnrsrjjsJvLvghrjjnnjsJ
GDBldPDGqPGWVBBcwHFmSmbpSpNRwHFV
CwHwCFwtCmdCDflHDpwFnnvzhhNJhJNzmhzhhNMM
sTbZssPqScTrqSWSShdMvgMRRzdRRQ
brBrsWPTrdrWsPcBcTcGqDLDDHjFfDClwLLBfFlFlw
lNptNFWpbVMjlBgQgvdNBRQLrd
TsDCDfSCQqqQQqDq
TwTmwPPPzZSCccScJwpWZHljtbWMFFQVHpnj
fhFmwbrgnCcSnwtS
vZVVZvQZVPZsMnNSccMHPN
ddzvQJvQzBzWRTJzdRVSWGqbRbgmfbFFbmbgmpmlff
wdslVdQtdlBVHDrHBcBc
TJWvpncCcJzCWcRfWvJRRpfZHBDZZHmDZPBjZHjZrSfb
TRJFvvWpTRRWCpCgGtgtGQdlcNtsGlwg
rCHvRLJtCjpbRCLpptHMVCQgGlMndVlQGNcCMc
zZfzSmsfSsMzMccQMVcN
ssSmPmSmhwVhZBZsTBRJrtRjtbDvjvrTHLtJ
wswRCNHHhsrWFsGfGWFBGb
lLtngDPLgLJPttgWzQWlbCfBlmBFCW
DcDnVpcnnJPngjjcdpRhwNZSCZNdNdvr
NWNzWpfMRHfwsRNznPdjtdjJtPVPHVdJ
CSLTZBrGbSmClvBVdGzFVVcFdjjjnV
SrZhZbTvmmbbLvwQzMhsfhqqWwQR
vvZqwFBZvzZzrqltPsQstrGGpMcbbR
bhJdjJJmTRQMTMMPPM
mCmgLbdVVVLhVnJmLgJhBWZFDlqFvwZDlZBnBvWB
sMrcmQcHHsLLrSHZhvdCddvtJJFl
jzjjWplWpPRPDzPzfRGjqvdJqqqCtqdqDvdDqtwC
pPNWVpGGVVffPlnSMnMsTmgsQVLr
zGMMRbpGmqqqNRmmzbNfbzPRPlvThCTrHPnrHSVPlTHR
LSjjwgsjtTjhPhHhvC
dJZtJwFgtBLDZZbmNMGzMMqS
ZrnstppPWccnsFWpnZnRdjRtjbCtSSRjjjLLbG
JgBQPJvPgHHJvmmzwGGLdjHGSjShGHqdHL
wTJvPzmTJvzJQBfwNmTmlPsrVfnVFpcMVZprDpFrsrVc
ssGCtltsSdJJtQjPdvHvfbfvqLHqZtBfVb
pzRwwDwDTgzbqVTVvHqVWB
grzHnRpmFpDMnmzFhplJCjlsPdGJSjsFCdFs
CTGBBGCBlSTTSsnTMrQbNrBMtpVzNddWHWzVpHVtdHmwhphm
JqPZgMRFFvFZvDZMDFcFFfDchdtdPWpzpWhtHWwwhVzWpddW
ZfLZMcgqRDjgjcLccDRDLsbbrSBBlQGQBCTrCBnT
VjVGVqSqFLFVSqCjFJSsbfPprHbCCRRPccRWPW
wwnQmtwlvNmpZRsPsWWNbZ
DBhhhznhddldnvjMqJMTqDMGPSjF
TTJbsJPPBDsBVbJJGJBGWLfmWzgmDmzmLqmmLddQ
jHwVZZjwFZlzLzWZLMdLqM
HHHhjHplrHSpcCSvjlsNPbNRbRnVTrRsNNNJ
NzMMLZtwRmbwFnVDhnqD
SlsJsSdSJdNJnFphVHFjph
vlrsTlGPTgvvSBScGcBvfzmmLLCtMWNZRBQMzftf
tRFLmZZRLrtRvtvvrvvGgvtLNfwzMzNwgdznMpwwpnMpqHdz
hcsBsWTcQJhjbHMncNwzMqnzwl
VWSWWTJhWBVDTJsTVWQWTVVbZtCPSvrrGSLCRFRGtRZLPmmq
hbdFhdShGsFSGBlQhNhQMLLLlLJCvLLDtVJDLlwtwD
WcqWsmcWrmqcmtDHJjVHrJCjjt
WPWcnggssmzqzzzgfzZnWRqqdGpSNFdMSFdBMSFZhSFBZZhh
GNFNtRQMGjDjwfgDZjmz
bqDsPWWbsqVsdvvBJvBfmgfLLzSwzLcmzmfB
WPWrrVrrVJhVWJDVsqnPdRQllRQRNhQGMlFQFMplGl
mChChmSQGSGJrjPHCpPFtwgsFZjtFVZfgVwtdV
MBMqvDWMlTbzlRWzllDzblZfsrgdZffgrtwrswZfdZTd
DlcMvBbBMnqMDqcRqDBMWvLmCGrGLSJhnLHCCHHnPmSQ
tscfGqftGfDnnppJGDGCZLbzMVMwPPhsblzbjzzMMz
TWPTWWmHTmFRSBSvgBPwwwlVzhMdwblhbVjRLL
TTQNNWWgHWQHPBWTNPWNcqJtGCnfqfpQZJCZpQZn
CqzCGDQJCzzftfRqRzzMdvFpFpccdZFvFMtMbd
rNHwmHVmswsHVsPTLnbFSTbZZpFcpvSZZgpg
vPLhLLwHLhVVNVvQhBqDCBfhDzCffG
WsBbBbsWNhsPsCNssRWLPLpmLDDQHlJlnlzFnDDnzF
gcGfqggMqfjjGwrdDZzQFmpJQzZlFDMF
qdwqvjdTrwfvvBCPtpVvtR
RQdbbRHtHRvqZtwVcmwVwV
WnLNnqFDlDWzzNLLrjClwCZCGZcglGCccZ
LnTFfWBpffrfrhBqdsSBqhBJHb
sqsgJpDMrNQgGsFMsPCfjCPChPWjqSWSjh
RBnRnZVcwZllLwbwwLbZVLclhpjRttSdtjPhjWShWdphjCPd
HwHwVVwVnBVBmmGppNFzrrsgJJ
WpmDFlQlzmmgMMLMLQVTvTTSwNbmTVwTtHHw
jrhPDnDnnZfjPTNtHSVTcjccwt
CJqPfGnhGZCBfnPJCrBCqdLqMlQqDLlLRgLQFFRW
vZVvDZsvhDZhZvzgVcgVqPqmwWMqcw
bdTbdBBFQcdCdcGmcP
bmjQpHfbpzDJRjNhJZ
twRrwjFptprQjjjtQRdWCmNJTlNSCmZQcNlmlSST
VVDzMWDnDHMzLZDNNJSqqCJZZD
HHhhsfVHGbnwgjfrgdpgWj
GmszZGMrLmnmsfGVRcVlwtwccc
SSCgbNqSTgCCJMHCJtlVcwVbVljlclVfwf
HTCgHSgHQThMqWQQSgDnvBdsFDvrzdZsLdmLZZ
PRlMlBPPctVBlstzVLhsdwCqCdCNDjSDdWmMqdNw
fZrQQHFffgGFprSJSgvZrfnqjmWdnndCNGWmWDwNNDCG
rTvvpJZZrfpFSbQQvrrsssLRVPPtlRtRPThzTR
FqgHFFMRTRjRFRpRRjFtNdCtJCMnNNdrdMLdrQ
VhWSmwGwWVbGbvlwwlLZJLZSdJZtNCtnTSCJ
BmWwWWzhvVfwWhmhwlmvwlRqHpscHRTpTDRFfTsjDPjD
MJMgGqMFLPGgWVjpcmjZTpmZjZpJ
hdSzzlCtzNdtWSdndttflBmjpBRmvvpjnjcvBjmvHj
zdhCrfztrDSzfWzdChrhlhgPPPGDgqFFLGGFVVqqPVQw
ZQZNQRZzFdCCgfLcCGDfScjDcG
vsmwVHTmTfGcSHjcDS
tMsmMVlSWWzdWNnQNJ
GPRcQnwwQWwFFnrnnldSqzMfSCdfdldrJf
LpTsjmZTsBZjpmzhLLMdSJJSMhCC
ZsZBssBsDpDmmVBjCmDZHgnVNWvPQPNPGvNQncQPcRWn
pznzpzlGFrvGHGrnnMvDmBMfgfTmsBsTTghDsg
LJtWVCWLCNPcSbdcShWBgBThgTfjzwfhhz
VZZCdLCVNNCVbCLzFnRqGqlHprQZHRqr
dFTsQPdMFsMnWFPdSnwBltftttvlflNN
VLZhZLqghCgzqgrLrcgVgbCvtDDtwpqNpDtlBRflDwNqDpNw
cLmVhVcgbZrVhrhCLhczhQdJHTmPJJTjvTJsPFWFTW
SSwNPNHldNJSngHqBssQvBfccB
mMppmDprWpFGRGWmWrDrtGzQfcvvQZBBzzczqRQgRqRT
WtFtFvhvpLphNJJVSCbSNP
chpGMMzcwSSGnQFRQQFWcFWn
sgddTfjLqsWrRtLvQnJr
CsmlZgssbRdMhzCHDGpGGG
vHBrTzpMPTHMtbBRRJGtDsNB
QJWWVwnCZmQlWQWlLWCCmmLwRgtDdDbgngqtRdRGbDNDGtGq
LwmWQLJcWmwPrpvpjjrcjT
fcsWnWzhWcWgcbfbvtbHTRvpvHttmLtR
lNSjwjrDFjlFhlZlQTpLHvSHptvTSRtLmJ
NwjwrQDwFCZBCfWzqhqqzc
fgNJNRcvvWRfWRrZFldlwlFwfFllflDH
spQshQhpqhJsLpnQVLqBqlFwddHSdBFFjSFmwlFmwl
hppLsqPVLnpnzJPtqtPPJTCgNcrcNbrrGNcgRNrzcZbG
PWFdgDGCFPGhMtQqHBrpJqqW
nlllLNmnVNNLllVbVRLRsQMqqpccQQJcJtqcJcnBrc
NmvZLsNrbZNjNZVNGvdFFfwdDhPFdDzC
LpZpwgLsLSzDdjVGpS
bWBlHqqBhNJWNbJQFzGtCtDtGGjNGDgtGC
RBRbJggbWRRmhWqTcnnfnmZMTTsTcP
JJgzvfzpdzzJjJhgdfhvqfdScNsLwwGsrRbwRLbcbVrVRp
WDFBTTDtHTntltnCnnntCDwGlGGbSwNVSssrbwGVsVLs
nCHMDtCWWTCCHmmPDnZQgvfQgZNJJdvdMZQg
lFDgvlsGvvZGDsFZWgGvWrPqnmwwtqmMVSWrSqMM
hRpJhLQHhdTTVPmVSrqwtHmV
ctJJJfjLpjglZDGCGljF
CnnVMbhVRbQQZjBP
rlfsLFLtmLSJscttFfsdjZwZNNwBPWRjRNZBZBfQ
tFrmDFlDtmcltFvqVzDqQzGvCVCG
JzzJzVrmzJpCCmTFmjZS
HtDDtggWssqWfDgwDWvsfDBBchZjSnGGpCFjSFZjpGjFShZg
sbvbvfbbDblWtrNVNRzRlJPCzM
nlFnFWsWhrctWVdJPDPTnTNJPJQJ
fHqvHSqRqSHjBmqvmqqHCtJSTZGdMQJDPQDPPMdNTMZN
jzqmbtRRztmbLHcFpgWVsFphpcLV
PHZFZFVZZfHgpwjFtmgjtq
rpTrTNzzNdrTJwgMwqCBJzJz
vsTWbvccRcdRbrRnRRbRrcvVpGlGHZPspSVhSPPQGGZVHV
HWnDDjfPFccDPhfchnMMVWGzzpvGszCCGWWV
JNBtBTQJNwJQjTpRVRMvpLsQzsRR
JltNSrBjmrHfdPHnDlHg
ldCJHlZFspjzHMnp
zvcLQBQcQvhBwmcDppqbNpjMLnLDDn
BvcmQhWWRzPJJzWWWg
ggSTPZBwTPTPSTRwZPBnwPMLdVvBqzsqLzqqtVzqtzBszN
QRmhQhffCQhJcDfmpChQWJmJNNtzvqtLdvNsGtLqNGzvWqvG
HQFCDhDFCCQJQmZTZwTSSwrZnRFS
QbFlsMbgPWPlJWzsJsJZntvnvZtctHBfZvBZlD
VTqpTqmSrhVLqrpjNppgntfBgfjddHffZBdtcB
VCwpqqqNVgNVgMJJwbsWWGMGFR
GCwRjQlsCQrPrGMQPsRvpdvgnjgmVVmSStptgJ
DzNcZNHZZhzzHhDzDTLWhDzSdJSSpnnVSTSvJJmgvSdmmn
pfLNDppNWHqDWfWbzcHPRslCGbwRCPwQrGQPCF
hVLnDgCmbhltrmDlhbhVmcgFBWdSBSZZBFPwBLBPfWdPWZ
TNTjJNpjqGMTRRsTTCZddfWwFHFWHSSJSFPS
CGQqvQRTNzTpQsDtmcrgDQllhnQl
SWrtcHWjcWrPcwWrBwSPffnJNsqfMNCNqNfJFfSq
QLQvhBpbbvdvTdvpTdGDbDQqqqslsNMJlMMCqMfQnlfC
gThhpmDLbzBmGLptrmRZcwHWHZjVrW
gQvzQRvSSbvvJvQgfRrfbSpGqBPGwqwVjPBBwwjpRmjB
TcNHHVVtNsDHcMcdMBjqpBnGnwlGTwlPBl
MHsMDHFMdDtZddZdFdFrhhgbFFVvffrzzffrrS
QSFmrDSSQrqlfmDDHPRTdrrTPRbsTPTsNN
wBcclhhgwgMhWLLtVMgVvzRTNNjvbszzTdjNdsRbjp
nJgVMtBhwLBctmQHQlnCGqmQZZ
sggtjzzggfGmPbCMvRCMvTmT
RDqqhdQdDlcDpqVlLbSbZFSTTPllbCMv
hqpQWRhhdncDQcBsrwzjnfgtgGfgHs
MTrzlgMNQNggrrrPlzQDPCsFRfscTfFVhVftRsFFsScS
nWWHZHhZWJjjwjLjwbLbwHGSFppVfFVcGcFLfFSVttpf
jWhZZBhqBbwvZvBjZNNQrQQQzPMlzzglPB
jLVhJZQjwFCLRjQhPRZFLDzrGDHpDGsGqztGHststC
SBNlNmWnfvdLmlnvfNSbzrDTTzprdqrDpGqqpHrG
bNmSBnBmcfMmcmnlfcnNSnLhZPVVJhwjZRJPwjZMPjMZ
VpzBDgGTGVNNpSGzppMdTQwcvFdFMQdcdFwc
ZDsqfRftWtllmlWbLLtjFFMwMrjCcwfvMFvwcC
PHbDLHZtZJSJPpVgnV
bRvTdswLLSTvwswSbDhsDTvFmmGRVmJGZJnRcGGfFVJcqn
MWllQMllWHrjWPNplrllQMPZJmnnVmqJcNmVFFnJNFqVGC
PgpQrQjjzQWHzpBdvtwhwdSShBZTsT
MhTwjMTsTRFStjmSMqqppBrHpDrzHtPqbD
dllNcZWgldLvcsvvvvgvWddlHffqBHBBfPzbbqBpPHrpHNbq
VddvgWWdCZhnhsCSSCGT
LPjqHnDNqqHNllqLpqPCZCGRCssGdGrGFrPrgr
WVBztWTQSQMBQrGgRwwwCGgtwg
QJMTgvbTTWSzWWvSbVJTzJllJlHHhLpNqpHqjNjNHpjq
PCHCbPPPHPlTThBhjGTTNhMNTh
FrmfLqdqgfmfttqtWqfrqdhshchDBshDllDBcGDhGDWs
mqgdpvFmmdLdqqQCPHZZblvwZQZl
bQGqmngwwgSNrBWJWdHZmjfZWB
FlpRLCptFLMlLPRLlCCcCCMpjJZJHShWdWvBHHdcZdBWZvSv
FRPCDTTtFptVTnQnrGbwbS
LsdmnDMTLbzsbNtqcb
lJjCnHSvQRRwQQjRRHQbgWbqctNJPbcWrcPPgc
RhGSQGwBvvGShnGlHClwjmfpmfdmVmfFDBLDDZpmMf
ppDnPmwvNDjTjjcssT
qqfRHzdCPHWfhHHtTjjbbLLGZr
MhzqWdJCzqJWSJnpnpvvPSPP
NGWdQgDDHGJgQLznzzsJFFzvzB
twRCpZVjVWqVSqVwwjtZfrrfntfvznBssBncfLrc
jRRwCqwCZhlhZRpSZpjSqWwqmDMQdMmHPQQMHGdlHdTldNGd

1000
inputs/input.4 Normal file

File diff suppressed because it is too large Load Diff

512
inputs/input.5 Normal file
View File

@@ -0,0 +1,512 @@
[S] [T] [Q]
[L] [B] [M] [P] [T]
[F] [S] [Z] [N] [S] [R]
[Z] [R] [N] [R] [D] [F] [V]
[D] [Z] [H] [J] [W] [G] [W] [G]
[B] [M] [C] [F] [H] [Z] [N] [R] [L]
[R] [B] [L] [C] [G] [J] [L] [Z] [C]
[H] [T] [Z] [S] [P] [V] [G] [M] [M]
1 2 3 4 5 6 7 8 9
move 6 from 1 to 7
move 2 from 2 to 4
move 2 from 7 to 4
move 6 from 4 to 3
move 1 from 5 to 1
move 3 from 8 to 3
move 15 from 3 to 4
move 6 from 5 to 9
move 14 from 4 to 2
move 3 from 2 to 7
move 1 from 2 to 7
move 9 from 9 to 1
move 3 from 2 to 1
move 7 from 6 to 7
move 1 from 6 to 8
move 2 from 9 to 1
move 9 from 2 to 3
move 8 from 3 to 9
move 1 from 1 to 4
move 1 from 8 to 6
move 1 from 6 to 2
move 5 from 9 to 8
move 2 from 9 to 1
move 1 from 4 to 2
move 17 from 1 to 9
move 1 from 3 to 1
move 3 from 2 to 3
move 2 from 4 to 5
move 12 from 7 to 3
move 16 from 9 to 2
move 5 from 7 to 5
move 2 from 1 to 2
move 1 from 3 to 6
move 1 from 4 to 6
move 1 from 7 to 3
move 1 from 6 to 3
move 7 from 3 to 4
move 5 from 8 to 3
move 1 from 6 to 7
move 7 from 3 to 4
move 6 from 3 to 1
move 2 from 4 to 8
move 1 from 5 to 2
move 10 from 4 to 5
move 3 from 5 to 2
move 2 from 8 to 9
move 5 from 2 to 8
move 1 from 3 to 5
move 2 from 5 to 8
move 12 from 5 to 7
move 1 from 4 to 2
move 5 from 9 to 4
move 1 from 2 to 5
move 6 from 1 to 3
move 6 from 3 to 5
move 10 from 7 to 4
move 2 from 7 to 3
move 4 from 7 to 6
move 1 from 9 to 5
move 12 from 2 to 1
move 1 from 8 to 7
move 3 from 7 to 4
move 4 from 4 to 8
move 7 from 5 to 3
move 1 from 2 to 4
move 10 from 1 to 5
move 2 from 1 to 2
move 4 from 6 to 7
move 8 from 8 to 3
move 5 from 4 to 9
move 12 from 3 to 8
move 4 from 3 to 8
move 2 from 9 to 2
move 3 from 5 to 4
move 1 from 3 to 5
move 1 from 7 to 6
move 14 from 4 to 6
move 6 from 5 to 9
move 8 from 2 to 8
move 3 from 5 to 7
move 21 from 8 to 4
move 16 from 4 to 9
move 8 from 6 to 2
move 4 from 6 to 1
move 1 from 4 to 6
move 2 from 4 to 8
move 3 from 1 to 8
move 2 from 4 to 6
move 1 from 6 to 2
move 3 from 8 to 4
move 2 from 2 to 5
move 2 from 5 to 7
move 1 from 8 to 9
move 1 from 4 to 9
move 1 from 1 to 6
move 3 from 6 to 3
move 3 from 2 to 3
move 1 from 4 to 6
move 3 from 6 to 7
move 10 from 9 to 7
move 1 from 4 to 7
move 6 from 8 to 3
move 1 from 6 to 8
move 2 from 2 to 5
move 1 from 2 to 1
move 1 from 8 to 9
move 1 from 2 to 8
move 1 from 1 to 9
move 7 from 9 to 1
move 1 from 8 to 5
move 7 from 1 to 7
move 3 from 5 to 8
move 3 from 7 to 2
move 1 from 8 to 4
move 1 from 2 to 4
move 2 from 4 to 6
move 5 from 3 to 1
move 9 from 7 to 2
move 6 from 3 to 8
move 8 from 2 to 7
move 2 from 6 to 4
move 2 from 1 to 7
move 2 from 1 to 4
move 24 from 7 to 4
move 4 from 8 to 9
move 2 from 7 to 5
move 1 from 5 to 2
move 1 from 3 to 8
move 4 from 2 to 8
move 13 from 9 to 2
move 2 from 8 to 6
move 3 from 9 to 6
move 26 from 4 to 2
move 1 from 5 to 7
move 2 from 6 to 2
move 2 from 4 to 1
move 7 from 2 to 1
move 15 from 2 to 6
move 8 from 2 to 8
move 4 from 6 to 8
move 9 from 2 to 9
move 13 from 6 to 7
move 6 from 1 to 9
move 2 from 2 to 4
move 4 from 1 to 6
move 3 from 8 to 3
move 1 from 4 to 9
move 2 from 6 to 7
move 1 from 4 to 3
move 3 from 3 to 2
move 14 from 7 to 4
move 5 from 9 to 5
move 9 from 8 to 5
move 7 from 9 to 6
move 2 from 5 to 6
move 2 from 9 to 2
move 10 from 5 to 1
move 1 from 3 to 1
move 2 from 8 to 1
move 1 from 9 to 2
move 1 from 7 to 5
move 4 from 2 to 1
move 1 from 9 to 8
move 3 from 4 to 1
move 1 from 8 to 6
move 12 from 1 to 5
move 1 from 1 to 6
move 1 from 7 to 5
move 4 from 6 to 9
move 2 from 2 to 4
move 1 from 9 to 6
move 1 from 1 to 5
move 2 from 9 to 7
move 10 from 6 to 5
move 1 from 6 to 7
move 20 from 5 to 1
move 1 from 7 to 9
move 2 from 9 to 1
move 3 from 5 to 1
move 2 from 8 to 4
move 2 from 8 to 7
move 1 from 5 to 9
move 1 from 8 to 4
move 22 from 1 to 7
move 5 from 4 to 8
move 1 from 5 to 9
move 19 from 7 to 4
move 2 from 9 to 1
move 1 from 5 to 9
move 10 from 1 to 8
move 1 from 9 to 1
move 1 from 8 to 3
move 8 from 4 to 7
move 1 from 5 to 6
move 3 from 4 to 5
move 1 from 5 to 9
move 11 from 7 to 4
move 4 from 4 to 9
move 1 from 6 to 2
move 1 from 3 to 9
move 5 from 9 to 4
move 5 from 7 to 9
move 23 from 4 to 2
move 17 from 2 to 7
move 2 from 2 to 8
move 4 from 4 to 7
move 1 from 4 to 5
move 2 from 5 to 2
move 5 from 8 to 9
move 5 from 2 to 7
move 9 from 7 to 5
move 11 from 9 to 2
move 1 from 4 to 3
move 5 from 8 to 7
move 3 from 8 to 5
move 2 from 1 to 3
move 2 from 3 to 9
move 1 from 5 to 8
move 5 from 7 to 5
move 15 from 5 to 4
move 2 from 8 to 1
move 2 from 5 to 1
move 4 from 4 to 1
move 1 from 8 to 7
move 8 from 2 to 1
move 4 from 2 to 8
move 2 from 7 to 4
move 5 from 8 to 6
move 5 from 7 to 9
move 4 from 6 to 5
move 7 from 4 to 8
move 1 from 6 to 1
move 1 from 3 to 1
move 2 from 5 to 1
move 7 from 1 to 5
move 5 from 1 to 3
move 4 from 7 to 9
move 4 from 3 to 9
move 2 from 9 to 7
move 6 from 9 to 2
move 1 from 4 to 1
move 1 from 3 to 5
move 1 from 2 to 5
move 5 from 9 to 4
move 4 from 4 to 6
move 1 from 8 to 9
move 8 from 4 to 3
move 7 from 7 to 3
move 5 from 1 to 3
move 11 from 5 to 9
move 1 from 7 to 6
move 2 from 3 to 5
move 1 from 3 to 1
move 3 from 6 to 2
move 2 from 5 to 1
move 2 from 1 to 2
move 3 from 1 to 5
move 5 from 9 to 2
move 2 from 6 to 8
move 2 from 3 to 8
move 4 from 9 to 7
move 3 from 5 to 2
move 2 from 1 to 8
move 1 from 9 to 8
move 1 from 9 to 2
move 4 from 7 to 9
move 11 from 8 to 7
move 1 from 8 to 2
move 6 from 9 to 7
move 3 from 7 to 1
move 13 from 2 to 7
move 24 from 7 to 1
move 2 from 2 to 6
move 1 from 8 to 3
move 1 from 9 to 3
move 5 from 2 to 4
move 1 from 2 to 5
move 1 from 6 to 2
move 1 from 6 to 3
move 1 from 2 to 4
move 3 from 7 to 3
move 2 from 1 to 7
move 2 from 3 to 8
move 2 from 7 to 8
move 9 from 3 to 2
move 3 from 4 to 8
move 1 from 5 to 1
move 9 from 2 to 1
move 3 from 4 to 9
move 1 from 7 to 8
move 6 from 3 to 9
move 2 from 1 to 5
move 15 from 1 to 3
move 13 from 3 to 9
move 11 from 1 to 4
move 5 from 4 to 1
move 6 from 3 to 6
move 4 from 4 to 8
move 6 from 1 to 4
move 1 from 5 to 2
move 1 from 2 to 1
move 3 from 4 to 2
move 2 from 8 to 5
move 2 from 4 to 2
move 9 from 9 to 3
move 9 from 3 to 5
move 2 from 9 to 4
move 5 from 2 to 6
move 1 from 1 to 8
move 1 from 4 to 1
move 10 from 9 to 2
move 9 from 2 to 4
move 10 from 4 to 1
move 3 from 1 to 3
move 4 from 1 to 2
move 5 from 2 to 4
move 2 from 5 to 2
move 4 from 1 to 7
move 10 from 5 to 4
move 2 from 2 to 4
move 1 from 9 to 2
move 2 from 3 to 5
move 1 from 3 to 5
move 3 from 6 to 7
move 8 from 4 to 9
move 6 from 6 to 1
move 4 from 9 to 5
move 2 from 9 to 1
move 1 from 2 to 6
move 6 from 5 to 2
move 3 from 7 to 9
move 4 from 8 to 2
move 1 from 7 to 9
move 1 from 5 to 3
move 2 from 7 to 4
move 1 from 7 to 1
move 14 from 1 to 9
move 1 from 1 to 9
move 1 from 3 to 8
move 3 from 2 to 5
move 2 from 4 to 2
move 6 from 8 to 1
move 1 from 2 to 1
move 5 from 1 to 9
move 1 from 1 to 7
move 2 from 8 to 5
move 1 from 5 to 4
move 1 from 6 to 1
move 8 from 2 to 7
move 2 from 6 to 1
move 9 from 9 to 5
move 11 from 4 to 8
move 4 from 7 to 4
move 6 from 4 to 6
move 1 from 7 to 4
move 6 from 6 to 7
move 1 from 5 to 9
move 6 from 8 to 9
move 8 from 9 to 5
move 1 from 4 to 5
move 15 from 9 to 3
move 3 from 1 to 4
move 6 from 7 to 2
move 3 from 4 to 9
move 2 from 7 to 3
move 1 from 7 to 3
move 1 from 7 to 2
move 2 from 8 to 1
move 3 from 8 to 5
move 2 from 1 to 7
move 8 from 3 to 6
move 3 from 6 to 5
move 1 from 6 to 1
move 10 from 5 to 7
move 6 from 5 to 4
move 4 from 2 to 4
move 6 from 5 to 1
move 6 from 1 to 8
move 2 from 9 to 2
move 2 from 9 to 7
move 6 from 3 to 7
move 1 from 3 to 5
move 1 from 1 to 9
move 2 from 8 to 1
move 2 from 5 to 4
move 3 from 3 to 7
move 10 from 4 to 6
move 1 from 9 to 7
move 12 from 7 to 3
move 12 from 3 to 8
move 2 from 1 to 5
move 1 from 1 to 3
move 13 from 8 to 1
move 7 from 7 to 1
move 13 from 6 to 9
move 1 from 7 to 4
move 6 from 5 to 3
move 3 from 4 to 3
move 6 from 3 to 1
move 10 from 9 to 4
move 2 from 7 to 6
move 8 from 1 to 9
move 3 from 2 to 9
move 1 from 3 to 5
move 1 from 3 to 5
move 1 from 1 to 4
move 6 from 9 to 3
move 2 from 6 to 7
move 4 from 9 to 5
move 4 from 1 to 6
move 1 from 2 to 4
move 6 from 1 to 4
move 3 from 9 to 3
move 3 from 6 to 8
move 3 from 8 to 7
move 5 from 5 to 1
move 1 from 3 to 9
move 1 from 9 to 5
move 1 from 3 to 2
move 2 from 5 to 1
move 1 from 6 to 9
move 1 from 6 to 3
move 2 from 9 to 7
move 2 from 8 to 1
move 1 from 3 to 2
move 1 from 2 to 5
move 1 from 7 to 1
move 7 from 7 to 9
move 12 from 1 to 9
move 1 from 5 to 2
move 1 from 7 to 1
move 13 from 4 to 7
move 1 from 9 to 4
move 5 from 7 to 3
move 4 from 9 to 1
move 8 from 7 to 9
move 3 from 2 to 3
move 4 from 3 to 7
move 5 from 4 to 6
move 3 from 9 to 4
move 10 from 1 to 5
move 3 from 4 to 7
move 16 from 9 to 2
move 3 from 9 to 2
move 6 from 5 to 3
move 4 from 6 to 2
move 1 from 4 to 6
move 2 from 6 to 8
move 1 from 5 to 2
move 1 from 5 to 8
move 7 from 7 to 2
move 16 from 2 to 1
move 1 from 5 to 1
move 10 from 2 to 8
move 14 from 8 to 5
move 2 from 2 to 6
move 1 from 2 to 5
move 2 from 2 to 1
move 8 from 1 to 7
move 4 from 1 to 7
move 2 from 1 to 7
move 5 from 3 to 2
move 1 from 1 to 6
move 2 from 2 to 5
move 4 from 1 to 7
move 1 from 2 to 8
move 1 from 2 to 8
move 3 from 6 to 7
move 10 from 7 to 5
move 1 from 2 to 8
move 27 from 5 to 9
move 1 from 5 to 6
move 1 from 6 to 4
move 1 from 4 to 3
move 3 from 3 to 7
move 4 from 3 to 6
move 2 from 6 to 4
move 3 from 8 to 1
move 2 from 6 to 1
move 12 from 7 to 8
move 2 from 3 to 9
move 1 from 9 to 2
move 1 from 2 to 8
move 2 from 1 to 2
move 6 from 3 to 8
move 1 from 7 to 4
move 15 from 9 to 5
move 7 from 9 to 4
move 1 from 2 to 1
move 16 from 8 to 2
move 8 from 5 to 2
move 24 from 2 to 9
move 3 from 1 to 2
move 24 from 9 to 1
move 5 from 5 to 9
move 3 from 4 to 1
move 1 from 7 to 6
move 1 from 6 to 3
move 1 from 3 to 2
move 3 from 2 to 3
move 1 from 5 to 6
move 1 from 2 to 7

1
inputs/input.6 Normal file
View File

@@ -0,0 +1 @@
gzbzwzjwwrfftfrrbvvcbcvcffpssvhhzfzbfzzrbrtrcttnthnhsnhsnnclcpctpprwwgppppchhvvctvtsvswwcdcrrdzdhzdzvddvfvfjjlldvvfllfhlfhlhghnhghrgrsggvbbhdhffzggmttjqtjjgljjwtjwjggldlzzrfrpppjsjggqrrdbbgwgtwwwtqwtqqvccjnnhrhqqsnssjbssmjjbzjjqnqnlnjncjjzzqddfqqqnqvnqncqqmsshqqccssvpvllbbfvfmmmgzgdggtjgjtjbttngtnnhhfrfddmtmtftcftthvttwzwrzrbrgrbrqbqccmmtvtqvtqqzmzwmzzzsvzvhhhqlhqlqplpggvmvwmmshhnshsjszzljlnlrnllgddqllpmllsgswwqnqlnlqqlmqqvrqvrqrppvrrqwqhqllgjgcggsllqgllghlghhbvhhcvvbddvcvwwwzdzzfjjvcczbbwccjvccmvmfvfgfmfttwrttpmtmsszccjggcssmqsmsgszzfpphghvgvvcddtltwlwnnrbbfdbbtssrvvmwwjfflmlblwlrlmlwwhrhnhqnnvdvllzblzzndzdlzzhpprbrprnrzrjjlnlnrrjddgrrwrttcstsgshszzvgvfvpfpqfpfbpbfbwbmmzvvnnqvvqppzspzpzplldqlqsqlldmlmgmcmwmsmfsfzfdzzbpzzbbcwbbtppphlhshchjjszztctpprqppszzchcqczczddscsrstsntstjsjqjjfggvccgbggqhghrhppdldnlndnpddllgplgppnlpnnmwwglghhftfrtrqtqsszrssfjjzhzfhfssflfslsmmgrrcdrdnrdnnqznndrrbtrrmhrhbhsbsgsnslsqlqnncpccplpldpldppshsdssqdsqdsqdsdsdfsddchczhczcszcscffzhfzffpbbgttdhthnhnjnwnnwrrmwmlljzlzlzdzrrcvcbbsfstfsfnfqftqffgjfjzfjfsjswswccsvcvlccshhjpjcccnfnqqmsqmmrwmwjwswgsgjsjttmjmjttpqtqwttgmgfmmnbnrnpnwppgspggwnwqnqpqmmbmmnwnllbwwdqqzsqqtgttnrtrllcwcchpchcbhbpbnpbpsptpvtvzvrzzslljddjzjjmqmmdpmddcdzzrdrqddtctppwzzwrzrvzrvrzzjtztqqsmmcncllhmlmpmhgsrtrzjhjbtfvhmzpssfbjwcdshthnmmqmfhlhwcbbllwzbwfgfvzjcqblchzqqqgcgmpnbnnblhbcpgmvsbvtcmhsghldlhqlghgtpdvjflmjsmppdsvrjlwvhmwsmfvvdnzpmtfqjqpjdctnnrlfjfvdtmvdmhsczlfsqwfrqtlqwnzdzrcdzmhvrgwnjjtqjrqljhgcffglvhnsdssqdpfrfhtjwlqzvfjmpjnqhsjvndtstqjsqgcmgqdjvfqnlmtjlvcblndprmffrgqdnnncnlfflclgqbjbmsdqsjrmzpwtbqqqqsqmgthhjfqwzvcbqwlvdbffhcvncpldmchnptbnlbhmzrrjhzvzdrvtlhsnfnfdnvhlrlrmdcpnmvdwswctcqldszlvftqtwldrhmfjmfvcgjcdjsbjqjwdtslblwhqfvgrfcpnhszqqsfwbwcmvfvccvztdmcjqfjvdvmbdtcjvtwqpwsqjtdvpvvvsdrrvngmjztgjtnpdbmtlrbrjlwsdnthgzgpssgbzzrqvgblqhrtfbflnphvhpzmdfrwqvjjvcpsmdrqwdbzlpnqpmglgqzfhctrzdpzdthqgjtvpwcrlsmqnjwgzlnqbthvfswhjtrrsrswhbmnddgzmznvppbnmtjpzpdpmpzpmsgfstzldgmrtgplwwsbztphtcvdfgsqzqwrmlqpnhvpcqpfjpbrthrtwgqlfnrqcrpvhssjmhfgpnzzvlrlcbnpmddhtdvvfrrvprqrwbhfgvvltgrhrpwsdgvrlgthbztcgcfggtcfzqtlcdhpmcvpgcszslhpfrttnrdrqpqlgdfwtccmbhfrnlbhhmrtrjmzstbqhmtphzcpcllzsnghfvlwvzzvlqrjmfsvhrnjnvldgnbqvpjsmmphhrmhqrtcncmjwbdlqtrvmhgjrjsrddcpqnjhfmczfgwzspnrjfwvfdpdlcfpvctfrlspdwwlnpbvbglzsmgfsmrshsqgcvlfrvjssrglbwvvvgpvtqshbtqmzbnglflhhldtfzqssptrbnnzdqwqtstpftdqgmmhfjdlfwtmcmtmcgcvtfhzvsbllgbchvlhrgnvvbsnrwqrlvdqlcwwlgbjrvrzgcvljqzvdngtbhpnppjrzpmbwztzvnvrbfccfgvnqvrcmpdblngcvlwjwzpbbwmnslsdjmbrwbvnjsgcmsfvzvnwbzrrlzvgdnzcqqgggvmcwczjqnrddnzhlndgzjbvtbtjqdnlvlflqnfvjdmfstpdfqsgjdslgtpgdnvvpmfwvlqbmbgdrqjhdfhlmsdtfwpscsvdzmswszjfwqtsjqpfnjjlnsspvlgzwwtvwgdzfjjljfwbvfbvpglcqcdbdpshwcqzswbwhftbfqblzpqfmqpvzdjsrcqtvjntnhmlhmzllffcjsdnwpfzdglvlrhrljbrhjhgdnfcqcrccwrbbhrvqwrzlwjrrwzsfcwsvbqsjgtgpzqwlczljrtdhtzcgsfgqssdbjjmttdtzhrqtbqjtqfwmcpdftrfjmznpscsqmtfcdpcdjwcqjvmhngcqnmtmwfttcvpwgcnhhgnnbgjdvztzhczvqljjqwcmwcbvmqqjsfnmhtbtsvsnsfwfzgdvlctrgdvbjqpgfrrlsnppmvhfbbclprlvcssnvtsgftmlpqrpjzrrphrzltbtgfwjqqvbgqjdpdgqvzppfzcbhdbbjttcdzclsphtlzfvnfqgpmqvpzrqgpdnbmsrqgsnfdwpvndzmsllgmnrlhnnzldwshtrrsrsmdncwrcjnmcjlwbbfpzcwzvldtgvbcvhnbhgjgwjcvslrfcwbqlrqldvpcgnbwbzzncncftrgbrwchfrrtnpqsjbcpzvplnbqdgtvnnrcwwfvbdzdrsfspvtbhflhsbqmlsjvfmpvjbfvcrdmgrfqsmqgfrntfqnlqbvmsqtpncjrstspbqvfmddmhwsssdcddshmwdlscttmdzljtpwhzhzhwsdnmgjstfmlnqqvzzdqpqsjdsllswmqcjtnthwqnhbscrjdstljqgncjvjvlpfrtscrzrqghrdvdnbtnpshpldcchljzrzqjlwwscnphvrwlvzttcdjdrddgmvqpvdmttdqhwpfmslzvnrwlrrdttbhctgpgzjrmdwjbcmsprwggvmdmmltldgpbfnppnrpwcnpgtblccdvbsnfvgzmjppftvndmdslfshjvndfvvzjjlzhgfmhcggttrcrbrlwrqgjpchvhnjwqnbsnmftwszhzftglrfdvvnbcbzsslgmdchtrrrqqzhllrfhwfwbbdgfpdfwssmzcfcnzmrhfdddtdhfqmctsglqbwhwpnbdzbsfbbvvthrrgjvztjjwgjcgjntrddmmdldtmvjnwjbcqwfwvfhsrpchznhlqpcttqjffbrpbftftdjzlrqchmzrfgjrqlndfwfrghtsfsblcvtjmjrbfrwdgsgzmmjpdlbwzfscfsfcdqwdwnjwjbvvbptmfrqltmnlpbtrqspwdfmhnncqgtrtmbzhfmwrbcqhmmpmvprvwrjplspcmmspldmbgpbtmqjtrfcpfhcnpjbnlhjpzflstjqfqvzcnfgvrmtplndchffzrtfrqdpdnzrspddwmpzlfchrzzfcfvmbvfnlfwtfbvnffdqhljbvwwdtmszgrjtzwqdbgvvfphcnsdgvlmslqngfmsbrztrnpjprghmjffscbnfqwrvjjjtfzrmjtzbwdsmzgmbtjzvddhngmzvflwftblbzfd

1030
inputs/input.7 Normal file

File diff suppressed because it is too large Load Diff

99
inputs/input.8 Normal file
View File

@@ -0,0 +1,99 @@
200210101302123001201232003214413304042424024222111455334421333412020113121332322101331130101222121
120100002010203210130421301201404231101254535242322112224524254031333224202413331320010302202022220
001200100200133300103241144403033124133341435524324143423341133252144040000423121430200100022211211
000012321202320024030320421230202213131514345325422513145221212451233202023402411040301113132131121
111103022312211340103042313022513413532253114352113252432213335135141552003023313142423321320321212
012112331020102411442404102132241553154421513555415233312432515445154422402444314033003303323320102
200110201230142322043222345241215442224221523534521123322555135454422121142320102300340211100120310
120012121330311223132012342543213553334431544155643463443115441515143121132442433102420433301221030
232202001121031432403445341332243414414443326545556526423425612114153351234111432130314202330220010
133033302004430221300431213144135422424546344243432363665246244341243432352514332142044434023131003
323030003440212122341123551231453352464334362343245665335563565343421512431425213111441304340011231
003000034413321402514254435224115366533425244663634336625232232553226312522142535212414040004113221
203203234020411021411532552144456644553434362455342664624546642245543563524451523133334201141411113
103032442424101341214421543433253563535422262333555222632224462463423526635422354541113034433423000
020133314440123532124351233325245665424345546323747756264656566346366665333444354252523314300303020
303102341103425544443131253325266522334544545666744335557473366256323634266213415324324341134211112
023044020203451414535535625633224445223364357435363343536455577666362444542245113553311434011140201
130031020304324235255516652533544625454347643363434554557436654343442356543323225524232341230421320
220403302205252431242554332553635575345744474647573376655365465333365246645632425211423335322131241
214400202003451322143346242334324356456753434655775663756755654555657245563342333124515412311131042
144333342021131124452334346355653767663565565443573444757577736363654665266666525633314514341134041
111433243134224443344522523636635556736633645434676475377437457745566744646666544632522235344014021
421102342525325521256266235434736567476654664744455647574564433767653357626264235361354533341223334
030103204353142134336562363447366767454375766855756788856466566674566447433523254456444314525331002
410404421315115456635435323737634573668554668666466474777667486334467637567356564452622223212300033
012140231351312622653242266664756743747655464548677545754787855754646777456542663563451151125130001
122202541435443225443523376367336378575474446665666578564485767586653557636553243543226514123433024
322341213145516625463356665437453687675788656768568586885644456856643777435654242663525154214512210
140223342343464363346556333753354858857777544686557677466886555488585473373334765233552623543312200
422403124152143243445554363655577858878487546898958587796787475657654747656366532662626445424424410
321231255223524234247766447646866656646454795565859795788557647554485844673466335434256341522445230
434145334313623446664556646655886667557495589675986998765976684664875654474437775454342445551523513
433432522546645452345446344376857768848989787655576756768988889768856644743374354326655353222112422
420512322415655344574666457745755754768778785979569655887679799664764746786677655366663463434125353
124155335466242262756735466446866676986698997576575557966855895697587767454454543472442666623435524
415345153363443642766655644464854747967899588766957797576697788779586574578644737774624632644545113
441333524323362443745375688445665755769658789797769878578585579797547585786676677364322333511241423
434241414244556353633455448684455597576765697869997689879755769799778646786856633667554436244553435
245314523664342366643466667485888767568897999988699997889967759988686546445685776346654553265354523
321432211425653366363657657447568665877957979987786779697868577888595675855456734636524456425431142
033422313632342655364345567644755898785796699996888776886796657757797857688876376354363532536232314
052242355542323647576334458576689579586968867996689878797799969587659875547656644765646363224253444
234434342653226546436658855775896968867876797997996768779677667699889796745768337366436634632245213
445222213235346735753667755676669878598898697986687998696976996987769858656476757667332332625351514
435355546442363575345376588657989988589877788898987788998987888969858697674677876744344654353312151
133553556352633665357787686775799577779997878787787897797699998878965787455885663557545355624324115
545233354544544435573376578458655587598789677877787899897869896658788766588656837747764363655341521
211555453542466735366787685658866856979676887788987997989769978968996968546685834576542622243213155
144113123264426777463777488587699869767977889987787997788887696979756858576885677473635653233543243
311313235543366635754558457576795998769778679778889889889987668888968988774448543757733325643231422
443355342254425446767468656476595865887986787897998879979969967775865587546587644777655235234324344
442443355324564334365767887885668589686866989997898887797879967668978575855866836656334552623632351
413433144665547465436464847768768777996977968777788977797977679895685768676556634643436422334442455
453142566345254453333444885587565578677688779977889999789888796877778557847675867477652535546215422
151332265265444777364585745778956687969888787989789897978868788787686655764465553577745632625231455
445223254646322766445774546689887968566967668798798897976876999668956869458456654344465452425345523
354122314463434747436654644484979696677686898978887878797976779669677694454485555635752664656513133
012232355266625635373378685656767767887668769986988989987778777769685698467858437754343553255322444
024555213224464774353435485656687879797989768686778867676969798596899575656786466333455553355345234
132432444233664544676735848585667856997869777886887797667989767578765688576686457343436442546533142
444143435624244477333448558448667577665667766788798979786987858959699677748784665774745235262414311
231541231646652273467743578658756967656599897986666898787998598868878558884847373763743436333442222
452115141256244235637554556584849575796768969699769887767797597866989785545764765437552564345131455
425244513366263336575446588857846976888767658868676696667958899568857767458773744637333452423533532
105131435443626324576435676555478786567757999689999668897789599599856875674774656477364623225123151
032315232453426453465765574644575446896598678899586759777588775565758668474745575344566425615355433
414341314426235264647543645746457657967695558965975769898785985654576867658657635475666624352134144
100323311242236242255347744575476776858879688698797878579969975874748675444573747344653555211352221
014311441544336355454575445686757688689666888758996965685596966444845578855576543546465554243154142
342254542123656656546356366778675574845697675569556687688586558646447667434456665352633422255244414
211453143353434566563465675745864885674687588998996685977676784567474566434544466522533343353114231
313022332133466332336477634667465867888785648576775865668487487544484845366535575442326624351431012
114211155121535434243656644454647447848458486648876856858767458446765544736737656643222525432544232
010122525344156263354227756636434587458665676586887787858748554686666673755577552352343354534152040
412321535231542523462334653374657358685586488785485678564864446878734675557735423665442154552342011
104424333415333444626345536643374555557465464777678466847574454875666744474766234464241242553110441
124112314331255362622446225633636335345644866876474848854678487634655646573245644334324331251444400
312000445323443215433555564337345455776744675674478888474578745344363573744242633426233313351422233
430022234512251423424326264637465355355746637447648757857473743746654776525262553642221524414041323
233102134414232412332356226435465646465443546335436365365755446655434343246552323324433143130002111
111404313153153442123666355224747746356376564475444457353545546774737575424345446353354342244313412
234334440424325351212523232526466575445565545647676363335445774536647332224524363441415351434423203
123130340344441323432464644565445455655737653455763575457374566467753266262333355253144434121341413
032133414041244541233153446223224334665566654364436733465455436362242424353334354423444542342323120
331120000421342243325115456255364522626457536537755343436545747263466663636524533235411311121411332
332230404213303353133111256254363655255434744674474754434646343454354433433515513135334442222004010
202121313223222511453512322255566444565544643556454452443454524223535655434354335552444042314134332
213300030010040331541141441242645424354334635234565662362526354224246533454523242512414430303043302
303300002321212004244535244451242654252646636554662636263664646235263231315331142352102120130122303
331101014024440131342122251123415223633335635453354263636226636262256541131443215354304023243302102
331202033431032221244232125455313233642635432336534464333635335635423524411525215033323313120333013
033030202002100313111523432311242321352266332543436322536365535415434245433251242122313014031212313
222211100333332310242343252221251543414443226355325632364262625135251521332232522230244440201332023
000203310213011213412344315255131512335223453552465335425413252322422253334440310223340313231332020
011332231323130141310431031222132533232453353124412341254122255424331153344341340113311310010033130
010021033100310312123242131122524221555411455523421253253142545515323423322444300142424333201332021
110101220202201114310003401420513324334525253112533435355244442344311112421320024234333132222021000
020011123333222200003244032430305123255531342321413242534522552125444313014002424233330331130222200
100220000312023302114114440201033304323431155212155522541415515211123243000444221343002001121202102

2000
inputs/input.9 Normal file

File diff suppressed because it is too large Load Diff

88
main.go Normal file
View File

@@ -0,0 +1,88 @@
package main
import (
"fmt"
"os"
"github.com/acw/advent2022/solutions/day1"
"github.com/acw/advent2022/solutions/day10"
"github.com/acw/advent2022/solutions/day11"
"github.com/acw/advent2022/solutions/day12"
"github.com/acw/advent2022/solutions/day13"
"github.com/acw/advent2022/solutions/day14"
"github.com/acw/advent2022/solutions/day15"
"github.com/acw/advent2022/solutions/day16"
"github.com/acw/advent2022/solutions/day17"
"github.com/acw/advent2022/solutions/day18"
"github.com/acw/advent2022/solutions/day19"
"github.com/acw/advent2022/solutions/day2"
"github.com/acw/advent2022/solutions/day20"
"github.com/acw/advent2022/solutions/day21"
"github.com/acw/advent2022/solutions/day22"
"github.com/acw/advent2022/solutions/day23"
"github.com/acw/advent2022/solutions/day3"
"github.com/acw/advent2022/solutions/day4"
"github.com/acw/advent2022/solutions/day5"
"github.com/acw/advent2022/solutions/day6"
"github.com/acw/advent2022/solutions/day7"
"github.com/acw/advent2022/solutions/day8"
"github.com/acw/advent2022/solutions/day9"
)
func main() {
if len(os.Args) < 3 {
fmt.Println("USAGE: advent2022 [dayNN] [input]...")
return
}
switch os.Args[1] {
case "day1":
day1.Run(os.Args[2])
case "day2":
day2.Run(os.Args[2])
case "day3":
day3.Run(os.Args[2])
case "day4":
day4.Run(os.Args[2])
case "day5":
day5.Run(os.Args[2], os.Args[2])
case "day6":
day6.Run(os.Args[2], os.Args[2])
case "day7":
day7.Run(os.Args[2])
case "day8":
day8.Run(os.Args[2])
case "day9":
day9.Run(os.Args[2], os.Args[2])
case "day10":
day10.Run(os.Args[2])
case "day11":
day11.Run(os.Args[2])
case "day12":
day12.Run(os.Args[2])
case "day13":
day13.Run(os.Args[2])
case "day14":
day14.Run(os.Args[2])
case "day15":
day15.Run(os.Args[2], os.Args[3], os.Args[4])
case "day16":
day16.Run(os.Args[2])
case "day17":
day17.Run(os.Args[2], os.Args[3])
case "day18":
day18.Run(os.Args[2])
case "day19":
day19.Run(os.Args[2])
case "day20":
day20.Run(os.Args[2], os.Args[3], os.Args[4])
case "day21":
day21.Run(os.Args[2])
case "day22":
day22.Run(os.Args[2])
case "day23":
day23.Run(os.Args[2])
default:
fmt.Println("PANIC! Unknown day.")
}
}

6446
run Normal file

File diff suppressed because it is too large Load Diff

59
solutions/day1/day1.go Normal file
View File

@@ -0,0 +1,59 @@
package day1
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var elf_totals []int
var current_total int
var max_total int
max_total = 0
for scanner.Scan() {
num, err := strconv.Atoi(scanner.Text())
if err == nil {
current_total += num
} else {
// this means we got a newline, I'd guess
elf_totals = append(elf_totals, current_total)
if current_total > max_total {
max_total = current_total
}
current_total = 0
}
}
if current_total > 0 {
elf_totals = append(elf_totals, current_total)
if current_total > max_total {
max_total = current_total
}
}
file.Close()
fmt.Println("Maximum food value is", max_total)
sort.Slice(elf_totals, func(i, j int) bool {
return elf_totals[i] > elf_totals[j]
})
fmt.Println("Top three items are", elf_totals[0:3])
fmt.Println("which adds to", elf_totals[0]+elf_totals[1]+elf_totals[2])
}

98
solutions/day10/day10.go Normal file
View File

@@ -0,0 +1,98 @@
package day10
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func clearLine(line *[]rune) {
for idx := range *line {
(*line)[idx] = '.'
}
}
func printLine(line *[]rune) {
for _, c := range *line {
fmt.Printf("%c", c)
}
fmt.Println()
}
func registerCycle(cycle int, x int, line *[]rune) int {
result := 0
var position int
for position = cycle - 1; position > 40; position -= 40 {
}
if cycle == 20 || (cycle > 20 && ((cycle-20)%40 == 0)) {
result = x * cycle
//fmt.Println("register cycle", cycle, "value of x is", x, "signal strength is", result)
}
//if position == 0 {
// fmt.Println("position is", position, "and x is", x)
//}
if position >= x-1 && position <= x+1 {
(*line)[position] = '#'
}
if position == 40 {
printLine(line)
clearLine(line)
}
return result
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
cycle := 1
x := 1
signalStrengthSum := 0
currentLine := []rune{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'}
if len(currentLine) != 40 {
fmt.Println("line length", len(currentLine))
return
}
registerCycle(cycle, x, &currentLine)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "addx ") {
cycle += 1
signalStrengthSum += registerCycle(cycle, x, &currentLine)
cycle += 1
mod, err := strconv.Atoi(string(line[5:]))
if err != nil {
fmt.Println("Invalid x modifier", err, "having read", string(line[5:]))
return
}
x += mod
signalStrengthSum += registerCycle(cycle, x, &currentLine)
} else if strings.HasPrefix(line, "noop") {
cycle += 1
signalStrengthSum += registerCycle(cycle, x, &currentLine)
} else {
fmt.Println("PANIC: Unknown instruction:", line)
return
}
}
file.Close()
//printLine(line)
fmt.Println("Signal strength fun", signalStrengthSum)
}

226
solutions/day11/day11.go Normal file
View File

@@ -0,0 +1,226 @@
package day11
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type Operation int
const (
Times Operation = iota
Plus
Square
)
type Monkey struct {
items []int
operation Operation
operation_by int
divisible_by int
if_true int
if_false int
}
func printMonkeys(monkeys []*Monkey) {
for monkey_no, monkey := range monkeys {
if monkey != nil {
fmt.Printf("Monkey #%d: ", monkey_no)
var items []int = (*monkey).items
for idx, item := range items {
fmt.Printf("%d", item)
if idx != len(items)-1 {
fmt.Printf(", ")
}
}
fmt.Println()
}
}
}
func lcm(items []int) int {
worstCase := 1
smallest := items[0]
for _, val := range items {
worstCase *= val
if val < smallest {
smallest = val
}
}
retval := worstCase
for candidate := worstCase; candidate > 2; candidate -= smallest {
works := true
for _, val := range items {
works = works && (candidate%val == 0)
}
if works {
retval = candidate
}
}
return retval
}
func runRound(monkeys *[]*Monkey, counts *[]int, ceiling int) {
//three := big.NewInt(3)
for monkey_no, monkey := range *monkeys {
if monkey == nil {
break
}
//fmt.Printf("Monkey %d:\n", monkey_no)
items := (*monkey).items
(*monkey).items = []int{}
for _, item := range items {
(*counts)[monkey_no] += 1
//fmt.Printf(" Monkey inspects an item with a worry level of %d.\n", item)
var result int = item
switch monkey.operation {
case Times:
result = item * monkey.operation_by
//fmt.Printf(" Worry level is multiplied by %d to %d.\n", monkey.operation_by, result)
case Square:
result = item * item
//fmt.Printf(" Worry level is squared to %d.\n", result)
case Plus:
result = item + monkey.operation_by
//fmt.Printf(" Worry level is increased by %d to %d.\n", monkey.operation_by, result)
default:
//fmt.Printf("PANIC: Don't understand operation\n", monkey.operation_by)
return
}
result %= ceiling
//result = result.Div(result, three)
//fmt.Printf(" Monkey gets bored with item. Worry level is divided by 3 to %d.\n", result)
var targetMonkey int
if result%monkey.divisible_by == 0 {
//fmt.Printf(" Current worry level is divisible by %d.\n", monkey.divisible_by)
targetMonkey = monkey.if_true
} else {
//fmt.Printf(" Current worry level is not divisible by %d.\n", monkey.divisible_by)
targetMonkey = monkey.if_false
}
//fmt.Printf(" Item with worry level %d is thrown to monkey %d.\n", result, targetMonkey)
(*monkeys)[targetMonkey].items = append((*monkeys)[targetMonkey].items, result)
}
}
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
monkeys := []*Monkey{nil, nil, nil, nil, nil, nil, nil, nil}
inspectionCounts := []int{0, 0, 0, 0, 0, 0, 0, 0}
divisors := []int{}
var currentMonkey *Monkey = nil
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "Monkey ") {
number, err := strconv.Atoi(line[7 : len(line)-1])
if err != nil {
fmt.Println("Error parsing monkey number", line[7:len(line)-1])
return
}
newMonkey := Monkey{[]int{}, Times, 0, 0, 0, 0}
monkeys[number] = &newMonkey
currentMonkey = &newMonkey
} else if strings.HasPrefix(line, " Starting items: ") {
list := line[18:]
splits := strings.Split(list, ", ")
if currentMonkey == nil {
fmt.Println("Item list with no monkey")
return
}
for _, split := range splits {
splitInt, err := strconv.Atoi(split)
if err != nil {
fmt.Println("Error parsing monkey's item", split)
return
}
(*currentMonkey).items = append((*&currentMonkey).items, splitInt)
}
} else if strings.HasPrefix(line, " Operation: new = old * ") {
amtString := line[25:]
if amtString == "old" {
(*currentMonkey).operation = Square
} else {
amt, err := strconv.Atoi(amtString)
if err != nil {
fmt.Println("Error parsing operation number", amtString)
return
}
(*&currentMonkey).operation = Times
(*&currentMonkey).operation_by = amt
}
} else if strings.HasPrefix(line, " Operation: new = old + ") {
amtString := line[25:]
amt, err := strconv.Atoi(amtString)
if err != nil {
fmt.Println("Error parsing plus operation number", amtString)
return
}
(*&currentMonkey).operation = Plus
(*&currentMonkey).operation_by = amt
} else if strings.HasPrefix(line, " Test: divisible by ") {
amtString := line[21:]
amt, err := strconv.Atoi(amtString)
if err != nil {
fmt.Println("Error parsing divisible by number", amtString)
return
}
(*&currentMonkey).divisible_by = amt
divisors = append(divisors, amt)
} else if strings.HasPrefix(line, " If true: throw to monkey ") {
amtString := line[29:]
amt, err := strconv.Atoi(amtString)
if err != nil {
fmt.Println("Error parsing if true number", amtString)
return
}
(*&currentMonkey).if_true = amt
} else if strings.HasPrefix(line, " If false: throw to monkey ") {
amtString := line[30:]
amt, err := strconv.Atoi(amtString)
if err != nil {
fmt.Println("Error parsing if false number", amtString)
return
}
(*&currentMonkey).if_false = amt
} else if len(line) == 0 {
} else {
fmt.Printf("Invalid line: '%s'\n", line)
return
}
}
ceiling := lcm(divisors)
printMonkeys(monkeys)
for i := 0; i < 10000; i++ {
if i%100 == 0 {
fmt.Println("Running round", i)
}
runRound(&monkeys, &inspectionCounts, ceiling)
//printMonkeys(monkeys)
}
for monkey_no, count := range inspectionCounts {
fmt.Printf("Monkey %d inspected items %d times\n", monkey_no, count)
}
file.Close()
}

174
solutions/day12/day12.go Normal file
View File

@@ -0,0 +1,174 @@
package day12
import (
"bufio"
"fmt"
"os"
)
type Point struct {
x int
y int
}
func to_level(r rune) int {
return int(r - 'a')
}
func from_level(l int) rune {
return rune('a' + l)
}
func validMove(p1 Point, p2 Point, grid [][]int) bool {
if p2.x < 0 || p2.y < 0 || p2.x >= len(grid[0]) || p2.y >= len(grid) {
return false
}
diff := grid[p2.y][p2.x] - grid[p1.y][p1.x]
return (diff <= 1)
}
func updateDistances(grid [][]int, distances [][]int) bool {
y := 0
updatedSomething := false
for _, row := range distances {
for x := range row {
best := distances[y][x]
nexts := nextSteps(Point{x, y}, grid)
for _, next := range nexts {
if distances[next.y][next.x] != -1 {
if best == -1 || distances[next.y][next.x]+1 < best {
fmt.Println("Found a live one; at", Point{x, y}, "with score", distances[y][x], "going to", next, "with score", distances[next.y][next.x])
best = distances[next.y][next.x] + 1
updatedSomething = true
}
}
}
distances[y][x] = best
}
y += 1
}
return updatedSomething
}
func nextSteps(p Point, grid [][]int) []Point {
retval := []Point{}
// point above
above := Point{p.x, p.y - 1}
if validMove(p, above, grid) {
retval = append(retval, above)
}
// point below
below := Point{p.x, p.y + 1}
if validMove(p, below, grid) {
retval = append(retval, below)
}
// point left
left := Point{p.x - 1, p.y}
if validMove(p, left, grid) {
retval = append(retval, left)
}
// point right
right := Point{p.x + 1, p.y}
if validMove(p, right, grid) {
retval = append(retval, right)
}
return retval
}
func printMap(grid [][]int) {
for _, line := range grid {
for _, v := range line {
fmt.Printf("%c", from_level(v))
}
fmt.Println()
}
}
func printDistances(grid [][]int, distances [][]int) {
for y, line := range distances {
for x, v := range line {
fmt.Printf("%5d/%c", v, from_level(grid[y][x]))
}
fmt.Println()
}
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
grid := [][]int{}
distances := [][]int{}
var start Point
var end Point
for scanner.Scan() {
line := scanner.Text()
row := []int{}
drow := []int{}
y := len(grid)
for x, r := range []rune(line) {
if r == 'S' {
r = 'a'
start = Point{x, y}
}
if r == 'E' {
r = 'z'
end = Point{x, y}
}
row = append(row, to_level(r))
drow = append(drow, -1)
}
grid = append(grid, row)
distances = append(distances, drow)
}
file.Close()
distances[end.y][end.x] = 0
printMap(grid)
printDistances(grid, distances)
fmt.Printf("Start position is (%d, %d)\n", start.x, start.y)
fmt.Printf("End position is (%d, %d)\n", end.x, end.y)
fmt.Println("Valid first steps:", nextSteps(start, grid))
iteration := 0
keepGoing := true
for keepGoing {
fmt.Println("Running iteration", iteration)
printDistances(grid, distances)
keepGoing = updateDistances(grid, distances)
iteration += 1
}
fmt.Printf("Best path is %d steps long.\n", distances[start.y][start.x])
closestAIs := -1
for y, line := range grid {
for x, v := range line {
if from_level(v) == 'a' {
distance := distances[y][x]
fmt.Printf("Point (%d, %d) is level `a`, and is %d steps from end.\n", x, y, distance)
if distance != -1 {
if closestAIs == -1 || distance < closestAIs {
closestAIs = distance
}
}
}
}
}
fmt.Println("The closest 'a' is", closestAIs, "steps away.")
}

208
solutions/day13/day13.go Normal file
View File

@@ -0,0 +1,208 @@
package day13
import (
"bufio"
"fmt"
"os"
"sort"
"strings"
)
type Element struct {
isNumber bool
number int
sublist []Element
}
func parseElement(line string) (retval Element, remainder string, err error) {
line = strings.TrimSpace(line)
//fmt.Printf("Working on line: '%s'\n", line)
if line[0] == '[' {
sublist := []Element{}
if line[1] == ']' {
retval = Element{false, 0, sublist}
remainder = line[2:]
return
}
work := line[1:]
for {
element, rest, suberr := parseElement(work)
//fmt.Println("Back from subcall with element", element, "rest", rest, "suberr", suberr)
if suberr != nil {
err = fmt.Errorf("suberror: %s", suberr)
return
}
sublist = append(sublist, element)
if rest[0] == ',' {
work = rest[1:]
} else if rest[0] == ']' {
work = rest[1:]
break
} else {
err = fmt.Errorf("don't know how to deal with list that ends with '%s'", rest)
return
}
}
retval = Element{false, 0, sublist}
remainder = work
return
} else if line[0] >= '0' && line[0] <= '9' {
var computed int
for computed = 0; line[0] >= '0' && line[0] <= '9'; line = line[1:] {
computed = (computed * 10) + int(line[0]-'0')
}
retval = Element{true, computed, nil}
remainder = line
return
} else {
err = fmt.Errorf("panic: Don't know how to parse line element '%s'", line)
return
}
}
func renderElement(element Element) string {
if element.isNumber {
return fmt.Sprintf("%d", element.number)
} else {
retval := "["
if len(element.sublist) > 0 {
retval += renderElement(element.sublist[0])
}
for i := 1; i < len(element.sublist); i++ {
retval += fmt.Sprintf(",%s", renderElement(element.sublist[i]))
}
retval += "]"
return retval
}
}
type OrderResult int
const (
ProperlyOrdered OrderResult = iota
ImproperlyOrdered
Unknown
)
func compareElements(a Element, b Element) OrderResult {
if a.isNumber && b.isNumber {
return compareNumbers(a.number, b.number)
} else if a.isNumber && !b.isNumber {
return compareLists([]Element{{true, a.number, nil}}, b.sublist)
} else if !a.isNumber && b.isNumber {
return compareLists(a.sublist, []Element{{true, b.number, nil}})
} else {
return compareLists(a.sublist, b.sublist)
}
}
func compareNumbers(a int, b int) OrderResult {
if a < b {
return ProperlyOrdered
}
if a > b {
return ImproperlyOrdered
}
return Unknown
}
func compareLists(a []Element, b []Element) OrderResult {
if len(a) > 0 && len(b) > 0 {
headResult := compareElements(a[0], b[0])
if headResult != Unknown {
return headResult
}
return compareLists(a[1:], b[1:])
}
if len(a) == 0 && len(b) == 0 {
return Unknown
}
if len(a) == 0 {
return ProperlyOrdered
}
return ImproperlyOrdered
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
elements := []Element{}
for scanner.Scan() {
line := scanner.Text()
if len(line) == 0 {
continue
}
element, remainder, err := parseElement(line)
if err != nil {
fmt.Println(err)
return
}
if len(remainder) > 0 {
fmt.Printf("Unexpected remainder in line: '%s'\n", remainder)
return
}
fmt.Println("Parsed element", renderElement(element))
elements = append(elements, element)
}
total := 0
for i := 0; i < len(elements); i += 2 {
index := i/2 + 1
switch compareElements(elements[i], elements[i+1]) {
case ProperlyOrdered:
fmt.Printf("Pair #%d is properly ordered\n", index)
total += index
case ImproperlyOrdered:
fmt.Printf("Pair #%d is NOT properly ordered\n", index)
case Unknown:
fmt.Printf("Pair #%d is UNKNOWN\n", index)
default:
fmt.Printf("PANIC PANIC PANIC: Unknown ordering?!\n")
}
}
fmt.Println("\nTotal proper index value is", total)
divider2, _, _ := parseElement("[[2]]")
divider6, _, _ := parseElement("[[6]]")
elements = append(elements, divider2, divider6)
sort.SliceStable(elements, func(i, j int) bool {
return compareElements(elements[i], elements[j]) == ProperlyOrdered
})
fmt.Println()
fmt.Println("Sorted order:")
decoderKey := 1
for i := 0; i < len(elements); i++ {
fmt.Println(renderElement(elements[i]))
if compareElements(elements[i], divider2) == Unknown || compareElements(elements[i], divider6) == Unknown {
decoderKey *= i + 1
}
}
fmt.Println("Decoder key is", decoderKey)
file.Close()
}

295
solutions/day14/day14.go Normal file
View File

@@ -0,0 +1,295 @@
package day14
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
)
type Point struct {
x int
y int
}
func parsePoint(v string) (result Point, err error) {
var parts []string = strings.Split(v, ",")
if len(parts) != 2 {
err = errors.New("Weird number of parts in point")
return
}
x, xerr := strconv.Atoi(parts[0])
if xerr != nil {
err = xerr
return
}
y, yerr := strconv.Atoi(parts[1])
if yerr != nil {
err = yerr
return
}
result = Point{x, y}
return
}
type Segment struct {
start Point
end Point
}
func parseSegments(line string) (result []Segment, err error) {
parts := strings.Split(line, " -> ")
result = []Segment{}
var left *Point = nil
for _, rightString := range parts {
right, rerr := parsePoint(rightString)
if rerr != nil {
err = rerr
return
}
if left != nil {
result = append(result, Segment{*left, right})
}
left = &right
}
return
}
func segmentPoints(segments []Segment) []Point {
retval := []Point{}
for _, segment := range segments {
retval = append(retval, segment.start, segment.end)
}
return retval
}
func findExtents(segments []Segment) (leftmost int, rightmost int, bottom int) {
leftmost = int(^uint(0) >> 1)
rightmost = 0
bottom = 0
for _, point := range segmentPoints(segments) {
if point.x < leftmost {
leftmost = point.x
}
if point.x > rightmost {
rightmost = point.x
}
if point.y > bottom {
bottom = point.y
}
}
return
}
type Cell int
const (
Air Cell = iota
Stone
Sand
Start
)
func drawGraph(graph [][]Cell) {
for _, line := range graph {
for _, v := range line {
switch v {
case Air:
fmt.Printf(".")
case Stone:
fmt.Printf("#")
case Sand:
fmt.Printf("O")
case Start:
fmt.Printf("+")
default:
fmt.Printf("?")
}
}
fmt.Println()
}
fmt.Println()
}
type State int
const (
Good State = iota
Stop
Done
)
func nextStep(curX int, curY int, graph [][]Cell) (nextX int, nextY int, state State) {
if curY+1 >= len(graph) {
state = Done
return
}
if graph[curY+1][curX] == Air {
nextX = curX
nextY = curY + 1
state = Good
return
}
if curX == 0 {
state = Done
return
}
if graph[curY+1][curX-1] == Air {
nextX = curX - 1
nextY = curY + 1
state = Good
return
}
if curX+1 >= len(graph[0]) {
state = Done
return
}
if graph[curY+1][curX+1] == Air {
nextX = curX + 1
nextY = curY + 1
state = Good
return
}
state = Stop
return
}
func dropGrain(startX int, graph [][]Cell) bool {
curX := startX
curY := 0
for true {
nextX, nextY, result := nextStep(curX, curY, graph)
switch result {
case Done:
return true
case Stop:
result := graph[curY][curX] == Start
graph[curY][curX] = Sand
return result
case Good:
curX = nextX
curY = nextY
}
}
return true
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
segments := []Segment{}
for scanner.Scan() {
line := scanner.Text()
newSegments, err := parseSegments(line)
if err != nil {
fmt.Println("PANIC", err)
return
}
for _, segment := range newSegments {
segments = append(segments, segment)
}
}
file.Close()
fmt.Println(segments)
leftmostX, rightmostX, bottomY := findExtents(segments)
fmt.Println("Leftmost X value is", leftmostX)
fmt.Println("Rightmost X value is", rightmostX)
fmt.Println("Bottom Y value is", bottomY)
leftmostX = 0
rightmostX += 500
width := rightmostX - leftmostX
graph := [][]Cell{}
for y := 0; y <= bottomY+2; y++ {
line := []Cell{}
for x := 0; x <= width; x++ {
line = append(line, Air)
}
graph = append(graph, line)
}
segments = append(segments, Segment{Point{leftmostX, bottomY + 2}, Point{rightmostX, bottomY + 2}})
for _, segment := range segments {
if segment.start.x == segment.end.x {
var top int
var bottom int
if segment.start.y < segment.end.y {
top = segment.start.y
bottom = segment.end.y
} else {
top = segment.end.y
bottom = segment.start.y
}
for current := top; current <= bottom; current++ {
graph[current][segment.start.x-leftmostX] = Stone
}
continue
}
if segment.start.y == segment.end.y {
var left int
var right int
if segment.start.x < segment.end.x {
left = segment.start.x
right = segment.end.x
} else {
left = segment.end.x
right = segment.start.x
}
for current := left; current <= right; current++ {
graph[segment.start.y][current-leftmostX] = Stone
}
continue
}
fmt.Println("PANIC: Diagonal line!?")
return
}
graph[0][500-leftmostX] = Start
drawGraph(graph)
count := 0
for !dropGrain(500-leftmostX, graph) {
count += 1
}
drawGraph(graph)
fmt.Println("Dropped", count, "grains of sand")
if graph[0][500-leftmostX] != Sand {
fmt.Println("PANIC: NOT WIDE ENOUGH")
}
}

182
solutions/day15/day15.go Normal file
View File

@@ -0,0 +1,182 @@
package day15
import (
"bufio"
"fmt"
"os"
"strconv"
)
type Point struct {
x int
y int
}
func pointDistance(a Point, b Point) int {
return diff(a.x, b.x) + diff(a.y, b.y)
}
func diff(a int, b int) int {
if a > b {
return a - b
} else {
return b - a
}
}
type Sensor struct {
location Point
distance int
}
func parseLine(line string) (sensor Sensor, beacon Point) {
var sensorX int
var sensorY int
var beaconX int
var beaconY int
fmt.Sscanf(line, "Sensor at x=%d, y=%d: closest beacon is at x=%d, y=%d", &sensorX, &sensorY, &beaconX, &beaconY)
sensorLoc := Point{sensorX, sensorY}
beacon = Point{beaconX, beaconY}
distance := pointDistance(sensorLoc, beacon)
sensor = Sensor{sensorLoc, distance}
return
}
func isBeacon(x int, y int, beacons []Point) bool {
for _, beacon := range beacons {
if beacon.x == x && beacon.y == y {
return true
}
}
return false
}
func inSensorRange(x int, y int, sensors []Sensor) *Sensor {
point := Point{x, y}
for _, sensor := range sensors {
distance := pointDistance(point, sensor.location)
if distance <= sensor.distance {
return &sensor
}
}
return nil
}
func leftmostPoint(sensors []Sensor) int {
leftmost := 0
for _, sensor := range sensors {
candidate := sensor.location.x - sensor.distance
if candidate < leftmost {
leftmost = candidate
}
}
return leftmost
}
func rightmostPoint(sensors []Sensor) int {
rightmost := 0
for _, sensor := range sensors {
candidate := sensor.location.x + sensor.distance
if candidate > rightmost {
rightmost = candidate
}
}
return rightmost
}
func addLinePoints(pointSet *[]Point, start Point, end Point) {
offsetX := 1
offsetY := 1
if end.x < start.x {
offsetX = -1
}
if end.y < start.y {
offsetY = -1
}
for x, y := start.x, start.y; y != end.y; x, y = x+offsetX, y+offsetY {
*pointSet = append(*pointSet, Point{x, y})
}
}
func addEdgePoints(pointSet *[]Point, sensor Sensor) {
distance := sensor.distance + 1
top := Point{sensor.location.x, sensor.location.y - distance}
right := Point{sensor.location.x + distance, sensor.location.y}
bottom := Point{sensor.location.x, sensor.location.y + distance}
left := Point{sensor.location.x - distance, sensor.location.y}
addLinePoints(pointSet, top, right)
addLinePoints(pointSet, right, bottom)
addLinePoints(pointSet, bottom, left)
addLinePoints(pointSet, left, top)
}
func Run(filename string, yStr string, maxCoordStr string) {
y, err := strconv.Atoi(yStr)
if err != nil {
fmt.Println("PANIC: bad y argument", yStr)
return
}
maxCoord, err := strconv.Atoi(maxCoordStr)
if err != nil {
fmt.Println("PANIC: bad y argument", maxCoordStr)
return
}
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
sensors := []Sensor{}
beacons := []Point{}
for scanner.Scan() {
line := scanner.Text()
sensor, beacon := parseLine(line)
sensors = append(sensors, sensor)
beacons = append(beacons, beacon)
}
file.Close()
fmt.Println(sensors)
count := 0
for x := leftmostPoint(sensors); x <= rightmostPoint(sensors); x++ {
if isBeacon(x, y, beacons) {
continue
}
if inSensorRange(x, y, sensors) != nil {
count += 1
}
}
fmt.Println("Beacons couldn't be in", count, "places on line", y)
candidates := []Point{}
for _, sensor := range sensors {
addEdgePoints(&candidates, sensor)
}
for _, candidate := range candidates {
if candidate.x >= 0 && candidate.y >= 0 && candidate.x <= maxCoord && candidate.y <= maxCoord {
closestSensor := inSensorRange(candidate.x, candidate.y, sensors)
if closestSensor == nil {
fmt.Printf("Found possible beacon location at (%d, %d). Frequency value is %d\n", candidate.x, candidate.y, candidate.x*4000000+candidate.y)
}
}
}
}

185
solutions/day16/day16.go Normal file
View File

@@ -0,0 +1,185 @@
package day16
import (
"bufio"
"fmt"
"os"
"strings"
"unicode"
)
type Valve struct {
flowRate int
leadsTo []string
}
type SimulationPoint struct {
time int
imAt string
elephantAt string
opened string
}
type MovePair struct {
me string
elephant string
}
func newMovePair(useElephant bool, a string, b string) MovePair {
if useElephant && a != "**" && b != "**" && b < a {
return MovePair{b, a}
} else {
return MovePair{a, b}
}
}
func addMovePair(pair MovePair, list *[]MovePair) {
for _, existing := range *list {
if existing.me == pair.me && existing.elephant == pair.elephant {
return
}
}
*list = append(*list, pair)
}
func alreadyVisited(place string, point SimulationPoint) bool {
for i := 0; i < len(point.opened); i += 2 {
if place[0] == point.opened[i] && place[1] == point.opened[i+1] {
return true
}
}
return false
}
func addPlace(place string, opened string) string {
injectionPoint := 0
for injectionPoint < len(opened) && (opened[injectionPoint] < place[0] || (opened[injectionPoint] == place[0] && opened[injectionPoint+1] < place[1])) {
injectionPoint += 2
}
return opened[0:injectionPoint] + place + opened[injectionPoint:]
}
var everythingOpened string
var simulatedItems map[SimulationPoint]int
func runSimulations(useElephant bool, time int, myPlace string, elephantAt string, opened string, valves map[string]Valve) int {
maxTime := 30
if useElephant {
maxTime = 26
}
if time == maxTime || everythingOpened == opened {
return 0
}
point := SimulationPoint{time, myPlace, elephantAt, opened}
if previousValue, ok := simulatedItems[point]; ok {
return previousValue
}
bestResult := 0
myMoves := []string{}
if !alreadyVisited(myPlace, point) && valves[myPlace].flowRate != 0 {
myMoves = append(myMoves, "**")
}
myMoves = append(myMoves, valves[myPlace].leadsTo...)
elephantMoves := []string{"AA"}
if useElephant {
elephantMoves = []string{}
if !alreadyVisited(elephantAt, point) && valves[elephantAt].flowRate != 0 && myPlace != elephantAt {
elephantMoves = append(elephantMoves, "**")
}
elephantMoves = append(elephantMoves, valves[elephantAt].leadsTo...)
}
moves := []MovePair{}
for _, myMove := range myMoves {
for _, elephantMove := range elephantMoves {
pair := newMovePair(useElephant, myMove, elephantMove)
addMovePair(pair, &moves)
}
}
for _, pair := range moves {
myMove := pair.me
elephantMove := pair.elephant
openReleases := 0
myNext := myPlace
elephantNext := elephantAt
nowOpen := opened
if myMove == "**" {
openReleases += valves[myPlace].flowRate * (maxTime - (time + 1))
nowOpen = addPlace(myPlace, nowOpen)
} else {
myNext = myMove
}
if elephantMove == "**" {
openReleases += valves[elephantAt].flowRate * (maxTime - (time + 1))
nowOpen = addPlace(elephantAt, nowOpen)
} else {
elephantNext = elephantMove
}
candidate := openReleases + runSimulations(useElephant, time+1, myNext, elephantNext, nowOpen, valves)
if candidate > bestResult {
bestResult = candidate
}
}
simulatedItems[point] = bestResult
return bestResult
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
valveMap := map[string]Valve{}
everythingOpened = ""
for scanner.Scan() {
line := scanner.Text()
var valve string
var rate int
fmt.Sscanf(line, "Valve %s has flow rate=%d", &valve, &rate)
_, after_semi, found_semi := strings.Cut(line, ";")
if !found_semi {
fmt.Println("PANIC: Couldn't find semi colon in line.")
return
}
after_semi = strings.TrimLeftFunc(after_semi, func(r rune) bool {
return !unicode.IsUpper(r)
})
targets := strings.Split(after_semi, ", ")
if rate > 0 {
everythingOpened = addPlace(valve, everythingOpened)
}
valveMap[valve] = Valve{rate, targets}
}
simulatedItems = map[SimulationPoint]int{}
bestRelease1 := runSimulations(false, 0, "AA", "AA", "", valveMap)
fmt.Println("Working on my own, best pressure release found is", bestRelease1)
simulatedItems = map[SimulationPoint]int{}
bestRelease2 := runSimulations(true, 0, "AA", "AA", "", valveMap)
fmt.Println("Working with an elephant, best pressure release found is", bestRelease2)
file.Close()
}

301
solutions/day17/day17.go Normal file
View File

@@ -0,0 +1,301 @@
package day17
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type Piece []string
var horizontalBar Piece = Piece{"@@@@"}
var plus Piece = Piece{".@.", "@@@", ".@."}
var backwardsL Piece = Piece{"..@", "..@", "@@@"}
var verticalBar Piece = Piece{"@", "@", "@", "@"}
var block Piece = Piece{"@@", "@@"}
var pieces []Piece = []Piece{horizontalBar, plus, backwardsL, verticalBar, block}
type Board [][]rune
func newBoard() Board {
return Board{}
}
func pieceToRows(piece Piece) Board {
retval := Board{}
for i := range piece {
newRow := append([]rune(".."), []rune(piece[i])...)
for len(newRow) < 7 {
newRow = append(newRow, '.')
}
retval = append(retval, newRow)
}
return retval
}
func rowEmpty(row int, board Board) bool {
if row >= len(board) {
return false
}
for i := 0; i < 7; i++ {
if board[row][i] != '.' {
return false
}
}
return true
}
func addPiece(piece Piece, board *Board) {
rows := pieceToRows(piece)
for !(rowEmpty(0, *board) && rowEmpty(1, *board) && rowEmpty(2, *board)) {
*board = append(Board{[]rune(".......")}, *board...)
}
for len(*board) >= 3 && rowEmpty(3, *board) {
*board = (*board)[1:]
}
*board = append(rows, *board...)
}
func printBoard(board *Board) {
for _, row := range *board {
fmt.Printf("|")
for _, r := range row {
fmt.Printf("%c", r)
}
fmt.Printf("|\n")
}
fmt.Printf("+-------+\n")
}
func copyBoard(clearPiece bool, currentBoard *Board, newBoard *Board) {
for len(*newBoard) < len(*currentBoard) {
*newBoard = append(Board{[]rune(".......")}, *newBoard...)
}
for len(*newBoard) > len(*currentBoard) {
*newBoard = (*newBoard)[1:]
}
for y, row := range *currentBoard {
for x, value := range row {
if clearPiece && value == '@' {
(*newBoard)[y][x] = '.'
} else {
(*newBoard)[y][x] = (*currentBoard)[y][x]
}
}
}
}
func movePiece(direction rune, currentBoard *Board, newBoard *Board) bool {
/// match the values
copyBoard(true, currentBoard, newBoard)
for y, row := range *currentBoard {
for x, value := range row {
if value == '@' {
newX := x
newY := y
switch direction {
case '<':
newX = x - 1
case '>':
newX = x + 1
case 'v':
newY = y + 1
default:
fmt.Printf("PANIC: Invalid direction %c\n", direction)
return false
}
if newX < 0 || newX >= 7 || newY >= len(*currentBoard) {
return false
}
if (*currentBoard)[newY][newX] == '#' {
return false
}
(*newBoard)[newY][newX] = '@'
}
}
}
return true
}
func freezeBoard(board *Board) int {
for _, row := range *board {
for x, value := range row {
if value == '@' {
row[x] = '#'
}
}
}
for y := 0; y < len(*board)-3; y++ {
allCovered := true
for x := 0; x < 7; x++ {
allCovered = allCovered && ((*board)[y][x] == '#' || (*board)[y+1][x] == '#' || (*board)[y+2][x] == '#' || (*board)[y+3][x] == '#')
}
if allCovered {
originalLength := len(*board)
//fmt.Println("--- original board ---")
//printBoard(board)
*board = (*board)[0 : y+4]
//fmt.Println("--- cleaned board ---")
//printBoard(board)
//fmt.Println("---", originalLength-len(*board), "rows removed ---")
removedRows := originalLength - len(*board)
//if removedRows > 0 {
// fmt.Println("Removed", removedRows, "rows.")
//}
return removedRows
}
}
return 0
}
func sameBoard(board1 Board, board2 Board) bool {
if len(board1) != len(board2) {
return false
}
for y, row := range board1 {
for x := range row {
if board1[y][x] != board2[y][x] {
return false
}
}
}
return true
}
func duplicateBoard(board Board) Board {
newBoard := Board{}
for _, row := range board {
newRow := []rune(".......")
copy(newRow, row)
newBoard = append(newBoard, newRow)
}
return newBoard
}
type PreviousState struct {
moveIndex int
pieceIndex int
}
type PreviousLocation struct {
dropNo int
removedRows int
board Board
}
func Run(filename string, targetStr string) {
targetPieces, err := strconv.Atoi(targetStr)
if err != nil {
fmt.Println("PANIC: Don't understand target number")
return
}
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
instructions := []rune{}
for scanner.Scan() {
line := scanner.Text()
line = strings.TrimFunc(line, func(r rune) bool {
return r != '>' && r != '<'
})
instructions = append(instructions, []rune(line)...)
}
file.Close()
board1 := newBoard()
board2 := newBoard()
moveIndex := 0
pieceIndex := 0
previousStates := map[PreviousState][]PreviousLocation{}
removedRows := 0
skippedAhead := false
for dropNo := 1; dropNo <= targetPieces; dropNo++ {
//fmt.Println("Dropping piece", dropNo, "with piece", pieceIndex, "and move", moveIndex)
if !skippedAhead {
state := PreviousState{moveIndex, pieceIndex}
previousLocations, previousStateExisted := previousStates[state]
if previousStateExisted {
for _, location := range previousLocations {
if sameBoard(board1, location.board) {
dropDifference := dropNo - location.dropNo
removedRowsDifference := removedRows - location.removedRows
fmt.Println("Got it, current drop", dropNo, "previous version", location.dropNo, "removed row diff", removedRowsDifference)
repeats := (targetPieces - dropNo) / dropDifference
fmt.Println("Drop difference of", dropDifference, "meaning we can do this gap", repeats, "more times")
fmt.Println("removed rows", removedRows, "+", repeats*removedRowsDifference, "=", removedRows+(repeats*removedRowsDifference))
removedRows += repeats * removedRowsDifference
fmt.Println("Drop number", dropNo, "+", repeats*dropDifference, "=", dropNo+(repeats*dropDifference))
dropNo += repeats*dropDifference - 1
skippedAhead = true
break
}
}
if skippedAhead {
continue
} else {
previousStates[state] = append(previousStates[state], PreviousLocation{dropNo, removedRows, duplicateBoard(board1)})
}
} else {
previousStates[state] = []PreviousLocation{{dropNo, removedRows, duplicateBoard(board1)}}
}
}
addPiece(pieces[pieceIndex], &board1)
for {
//fmt.Println("Move", moveIndex, "is", string(instructions[moveIndex]))
if !movePiece(instructions[moveIndex], &board1, &board2) {
copyBoard(false, &board1, &board2)
}
moveIndex = (moveIndex + 1) % len(instructions)
if !movePiece('v', &board2, &board1) {
copyBoard(false, &board2, &board1)
break
}
}
removedRows += freezeBoard(&board1)
pieceIndex = (pieceIndex + 1) % len(pieces)
}
//printBoard(&board1)
fmt.Println("Removed", removedRows, "rows.")
rowsWithRocks := removedRows
for i := 0; i < len(board1); i++ {
if !rowEmpty(i, board1) {
rowsWithRocks += 1
}
}
fmt.Println("Rocks are", rowsWithRocks, "rows tall.")
}

148
solutions/day18/day18.go Normal file
View File

@@ -0,0 +1,148 @@
package day18
import (
"bufio"
"fmt"
"os"
)
type Point struct {
x int
y int
z int
}
const (
Lava int = iota
Air
Steam
)
func surroundingPoints(point Point) []Point {
return []Point{
{point.x - 1, point.y, point.z},
{point.x + 1, point.y, point.z},
{point.x, point.y - 1, point.z},
{point.x, point.y + 1, point.z},
{point.x, point.y, point.z - 1},
{point.x, point.y, point.z + 1},
}
}
func countBlankSides(points map[Point]int, against int) int {
blankSides := 0
for point, original := range points {
if original == Lava {
pointBlankSides := 0
for _, surrounding := range surroundingPoints(point) {
if points[surrounding] == against {
pointBlankSides += 1
}
}
//fmt.Println("Point", point, "had", pointBlankSides, "blank sides.")
blankSides += pointBlankSides
}
}
return blankSides
}
func inUniverse(point Point, min Point, max Point) bool {
return point.x >= min.x && point.x <= max.x &&
point.y >= min.y && point.y <= max.y &&
point.z >= min.z && point.z <= max.x
}
func floodSteam(minPoint Point, maxPoint Point, points map[Point]int) {
stack := []Point{minPoint}
for len(stack) > 0 {
nextIdx := len(stack) - 1
next := stack[nextIdx]
stack = stack[0:nextIdx]
if inUniverse(next, minPoint, maxPoint) && points[next] == Air {
points[next] = Steam
stack = append(stack, surroundingPoints(next)...)
}
}
}
func findExtendedBoundingBox(points map[Point]int) (minPoint Point, maxPoint Point) {
minPoint = Point{1000000, 100000, 100000}
maxPoint = Point{0, 0, 0}
for point := range points {
if point.x < minPoint.x {
minPoint.x = point.x
}
if point.x > maxPoint.x {
maxPoint.x = point.x
}
if point.y < minPoint.y {
minPoint.y = point.y
}
if point.y > maxPoint.y {
maxPoint.y = point.y
}
if point.z < minPoint.z {
minPoint.z = point.z
}
if point.z > maxPoint.z {
maxPoint.z = point.z
}
}
fmt.Println("Min point", minPoint)
fmt.Println("Max point", maxPoint)
minPoint.x -= 1
minPoint.y -= 1
minPoint.z -= 1
maxPoint.x += 1
maxPoint.y += 1
maxPoint.z += 1
return
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
points := map[Point]int{}
for scanner.Scan() {
line := scanner.Text()
var x int
var y int
var z int
fmt.Sscanf(line, "%d,%d,%d", &x, &y, &z)
point := Point{x, y, z}
points[point] = Lava
}
file.Close()
minPoint, maxPoint := findExtendedBoundingBox(points)
for x := minPoint.x; x <= maxPoint.x; x++ {
for y := minPoint.y; y <= maxPoint.y; y++ {
for z := minPoint.z; z <= maxPoint.z; z++ {
point := Point{x, y, z}
_, exists := points[point]
if !exists {
points[point] = Air
}
}
}
}
fmt.Println("Found", countBlankSides(points, Air), "blank sides in base solid.")
floodSteam(minPoint, maxPoint, points)
fmt.Println("Found", countBlankSides(points, Steam), "blank sides after filling interior.")
}

171
solutions/day19/day19.go Normal file
View File

@@ -0,0 +1,171 @@
package day19
import (
"bufio"
"fmt"
"os"
)
type Blueprint struct {
blueprintNumber int
oreRobotOreCost int
clayRobotOreCost int
obsRobotOreCost int
obsRobotClayCost int
geodeRobotOreCost int
geodeRobotObsCost int
}
type State struct {
minute int
ore int
clay int
obsidian int
geodes int
oreRobots int
clayRobots int
obsidianRobots int
geodeRobots int
}
var initialState State = State{0, 0, 0, 0, 0, 1, 0, 0, 0}
func copyState(state State) State {
return State{
state.minute,
state.ore,
state.clay,
state.obsidian,
state.geodes,
state.oreRobots,
state.clayRobots,
state.obsidianRobots,
state.geodeRobots,
}
}
func nextStates(current State, minutes int, blueprint Blueprint) []State {
if current.minute == minutes {
return []State{}
}
buyNothing := State{
current.minute + 1,
current.ore + current.oreRobots,
current.clay + current.clayRobots,
current.obsidian + current.obsidianRobots,
current.geodes + current.geodeRobots,
current.oreRobots,
current.clayRobots,
current.obsidianRobots,
current.geodeRobots,
}
retval := []State{buyNothing}
if current.ore >= blueprint.oreRobotOreCost {
buyOre := copyState(buyNothing)
buyOre.ore -= blueprint.oreRobotOreCost
buyOre.oreRobots += 1
retval = append(retval, buyOre)
}
if current.ore >= blueprint.clayRobotOreCost {
buyClay := copyState(buyNothing)
buyClay.ore -= blueprint.clayRobotOreCost
buyClay.clayRobots += 1
retval = append(retval, buyClay)
}
if current.ore >= blueprint.obsRobotOreCost && current.clay >= blueprint.obsRobotClayCost {
buyObsidian := copyState(buyNothing)
buyObsidian.ore -= blueprint.obsRobotOreCost
buyObsidian.clay -= blueprint.obsRobotClayCost
buyObsidian.obsidianRobots += 1
retval = append(retval, buyObsidian)
}
if current.ore >= blueprint.geodeRobotOreCost && current.obsidian >= blueprint.geodeRobotObsCost {
buyGeode := copyState(buyNothing)
buyGeode.ore -= blueprint.geodeRobotOreCost
buyGeode.obsidian -= blueprint.geodeRobotObsCost
buyGeode.geodeRobots += 1
retval = append(retval, buyGeode)
}
return retval
}
func runSimulation(blueprint Blueprint, minutes int) int {
visited := map[State]bool{}
queue := []State{initialState}
bestResult := 0
for len(queue) > 0 {
nextState := queue[len(queue)-1]
queue = queue[0 : len(queue)-1]
_, alreadyDone := visited[nextState]
if alreadyDone {
continue
}
visited[nextState] = true
minutesLeft := minutes - nextState.minute
bestPossibleFuture := nextState.geodes + (minutesLeft*(2*nextState.geodeRobots+(minutesLeft-1)))/2
if bestPossibleFuture < bestResult {
continue
}
newStates := nextStates(nextState, minutes, blueprint)
if len(newStates) == 0 {
if nextState.geodes > bestResult {
bestResult = nextState.geodes
}
}
queue = append(queue, newStates...)
}
return bestResult
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
blueprints := []Blueprint{}
for scanner.Scan() {
line := scanner.Text()
var blueprintNumber, oreRobotOre, clayRobotOre, obsRobotOre, obsRobotClay, geodeRobotOre, geodeRobotObs int
fmt.Sscanf(line, "Blueprint %d: Each ore robot costs %d ore. Each clay robot costs %d ore. Each obsidian robot costs %d ore and %d clay. Each geode robot costs %d ore and %d obsidian.", &blueprintNumber, &oreRobotOre, &clayRobotOre, &obsRobotOre, &obsRobotClay, &geodeRobotOre, &geodeRobotObs)
blueprints = append(blueprints, Blueprint{blueprintNumber, oreRobotOre, clayRobotOre, obsRobotOre, obsRobotClay, geodeRobotOre, geodeRobotObs})
}
file.Close()
fmt.Println("Blueprints", blueprints)
totalQualityLevel := 0
for _, blueprint := range blueprints {
geodesHarvested := runSimulation(blueprint, 24)
fmt.Println("Found", geodesHarvested, "geodes for blueprint", blueprint.blueprintNumber)
totalQualityLevel += geodesHarvested * blueprint.blueprintNumber
}
fmt.Println("Total quality level of all blueprints at 24 minutes is", totalQualityLevel)
multipliedGeodes := 1
if len(blueprints) > 3 {
blueprints = blueprints[0:3]
}
for _, blueprint := range blueprints {
geodesHarvested := runSimulation(blueprint, 32)
fmt.Println("Found", geodesHarvested, "geodes for blueprint", blueprint.blueprintNumber)
multipliedGeodes *= geodesHarvested
}
fmt.Println("Multiplied number of geodes of first three blueprints at 32 minutes is", multipliedGeodes)
}

166
solutions/day2/day2.go Normal file
View File

@@ -0,0 +1,166 @@
package day2
import (
"bufio"
"fmt"
"os"
"golang.org/x/exp/utf8string"
)
type Move = int
const (
Rock Move = 1
Paper = 2
Scissors = 3
)
type Result = int
const (
Loss Result = 0
Tie = 3
Win = 6
)
func score(opponent Move, us Move) int {
switch opponent {
case Rock:
switch us {
case Rock:
return Rock + Tie
case Paper:
return Paper + Win
case Scissors:
return Scissors + Loss
}
case Paper:
switch us {
case Rock:
return Rock + Loss
case Paper:
return Paper + Tie
case Scissors:
return Scissors + Win
}
case Scissors:
switch us {
case Rock:
return Rock + Win
case Paper:
return Paper + Loss
case Scissors:
return Scissors + Tie
}
}
fmt.Println("PANIC: Unknown combo: them", opponent, "us", us)
return 0
}
func compute_move(opponent Move, goal Result) Move {
switch opponent {
case Rock:
switch goal {
case Loss:
return Scissors
case Tie:
return Rock
case Win:
return Paper
}
case Paper:
switch goal {
case Loss:
return Rock
case Tie:
return Paper
case Win:
return Scissors
}
case Scissors:
switch goal {
case Loss:
return Paper
case Tie:
return Scissors
case Win:
return Rock
}
}
fmt.Println("PANIC: Unknown combo: them", opponent, "goal", goal)
return 0
}
func move(r rune) Move {
switch r {
case 'A':
return Rock
case 'B':
return Paper
case 'C':
return Scissors
case 'X':
return Rock
case 'Y':
return Paper
case 'Z':
return Scissors
}
fmt.Println("PANIC: Unknown character", r)
return 0
}
func result(r rune) Result {
switch r {
case 'X':
return Loss
case 'Y':
return Tie
case 'Z':
return Win
}
fmt.Println("PANIC: Unknown character for result", r)
return 99
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var total_score_base int = 0
var total_score_extended int = 0
for scanner.Scan() {
line := scanner.Text()
utf8 := utf8string.NewString(line)
opponent := move(utf8.At(0))
us := move(utf8.At(2))
total_score_base += score(opponent, us)
target := result(utf8.At(2))
computed_move := compute_move(opponent, target)
total_score_extended += score(opponent, computed_move)
}
file.Close()
fmt.Println("Total initial score is", total_score_base)
fmt.Println("Total score with back compute is", total_score_extended)
}

144
solutions/day20/day20.go Normal file
View File

@@ -0,0 +1,144 @@
package day20
import (
"bufio"
"fmt"
"os"
"strconv"
)
func printNumbers(numbers []int, nexts []int) {
current := 0
for nexts[current] == -1 {
current += 1
}
first := numbers[current]
fmt.Printf("%d", first)
current = nexts[current]
for numbers[current] != first {
fmt.Printf(" %d", numbers[current])
current = nexts[current]
}
fmt.Println()
}
func removeIndex(idx int, prevs []int, nexts []int) (before int, after int) {
before = prevs[idx]
after = nexts[idx]
nexts[before] = after
prevs[after] = before
prevs[idx] = -1
nexts[idx] = -1
return
}
func insertAfter(idx int, after int, prevs []int, nexts []int) {
afterNext := nexts[after]
prevs[idx] = after
nexts[idx] = afterNext
prevs[afterNext] = idx
nexts[after] = idx
}
func insertBefore(idx int, before int, prevs []int, nexts []int) {
beforePrev := prevs[before]
prevs[idx] = beforePrev
nexts[idx] = before
prevs[before] = idx
nexts[beforePrev] = idx
}
func shift(count int, idx int, prevs []int, nexts []int) {
count %= len(prevs) - 1
for count != 0 {
before, after := removeIndex(idx, prevs, nexts)
if count > 0 {
insertAfter(idx, after, prevs, nexts)
count -= 1
} else {
insertBefore(idx, before, prevs, nexts)
count += 1
}
}
}
func indexPast(count int, current int, nexts []int) int {
for count > 0 {
current = nexts[current]
count -= 1
}
return current
}
func Run(filename string, keyString string, countString string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
key, err := strconv.Atoi(keyString)
if err != nil {
fmt.Println("Invalid key value", err)
return
}
roundCount, err := strconv.Atoi(countString)
if err != nil {
fmt.Println("Invalid round count", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
numbers := []int{}
nexts := []int{}
prevs := []int{}
zeroIndex := -1
for scanner.Scan() {
line := scanner.Text()
x, err := strconv.Atoi(line)
if err != nil {
fmt.Println("Couldn't parse number", line)
return
}
numbers = append(numbers, x*key)
nexts = append(nexts, 0)
prevs = append(prevs, 0)
if x == 0 {
zeroIndex = len(numbers) - 1
}
}
for idx := range nexts {
nexts[idx] = (idx + 1) % len(nexts)
if idx == 0 {
prevs[idx] = len(prevs) - 1
} else {
prevs[idx] = idx - 1
}
}
file.Close()
for round := 0; round < roundCount; round++ {
for idx := range numbers {
fmt.Println("Working round", round+1, "index", idx, "with value/count", numbers[idx])
shift(numbers[idx], idx, prevs, nexts)
//printNumbers(numbers, nexts)
}
}
idx1k := indexPast(1000, zeroIndex, nexts)
idx2k := indexPast(1000, idx1k, nexts)
idx3k := indexPast(1000, idx2k, nexts)
val1k := numbers[idx1k]
val2k := numbers[idx2k]
val3k := numbers[idx3k]
fmt.Println("Value 1k after 0", val1k, "2k", val2k, "3k", val3k, "sum", val1k+val2k+val3k)
}

221
solutions/day21/day21.go Normal file
View File

@@ -0,0 +1,221 @@
package day21
import (
"bufio"
"fmt"
"os"
"strconv"
)
const (
OpAdd int = iota
OpMul
OpSub
OpDiv
OpTarget
)
func opString(v int) string {
switch v {
case OpAdd:
return "+"
case OpMul:
return "*"
case OpSub:
return "-"
case OpDiv:
return "/"
case OpTarget:
return "=="
default:
return "???????"
}
}
type MonkeyState struct {
valueSet bool
value int
operation int
left string
right string
}
func step(monkeys map[string]MonkeyState) bool {
changedSomething := false
for monkey, state := range monkeys {
if !state.valueSet && monkeys[state.left].valueSet && monkeys[state.right].valueSet {
switch state.operation {
case OpAdd:
state.value = monkeys[state.left].value + monkeys[state.right].value
case OpSub:
state.value = monkeys[state.left].value - monkeys[state.right].value
case OpMul:
state.value = monkeys[state.left].value * monkeys[state.right].value
case OpDiv:
state.value = monkeys[state.left].value / monkeys[state.right].value
}
state.valueSet = true
monkeys[monkey] = state
changedSomething = true
}
}
return changedSomething
}
func contains(ls []string, x string) bool {
for _, tester := range ls {
if tester == x {
return true
}
}
return false
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
monkeys := map[string]MonkeyState{}
for scanner.Scan() {
line := scanner.Text()
monkey := line[0:4]
data := line[6:]
value, err := strconv.Atoi(data)
if err == nil {
monkeys[monkey] = MonkeyState{true, value, 0, "", ""}
} else {
left := data[0:4]
right := data[7:]
switch data[5] {
case '+':
monkeys[monkey] = MonkeyState{false, 0, OpAdd, left, right}
case '-':
monkeys[monkey] = MonkeyState{false, 0, OpSub, left, right}
case '*':
monkeys[monkey] = MonkeyState{false, 0, OpMul, left, right}
case '/':
monkeys[monkey] = MonkeyState{false, 0, OpDiv, left, right}
default:
fmt.Println("Bad operation", string(data[5]))
return
}
}
}
file.Close()
for !monkeys["root"].valueSet {
step(monkeys)
}
fmt.Println("Root monkey value, part 1:", monkeys["root"].value)
humn := monkeys["humn"]
humn.valueSet = false
humn.operation = OpTarget
monkeys["humn"] = humn
unwoundMonkeys := []string{"humn"}
updatedSomething := true
for updatedSomething {
updatedSomething = false
for monkey, state := range monkeys {
if contains(unwoundMonkeys, state.left) || contains(unwoundMonkeys, state.right) {
if state.valueSet {
state.valueSet = false
monkeys[monkey] = state
unwoundMonkeys = append(unwoundMonkeys, monkey)
updatedSomething = true
}
}
}
}
fmt.Println("monkeys now", monkeys)
var targetValue int
var nextNode string
if monkeys[monkeys["root"].left].valueSet {
targetValue = monkeys[monkeys["root"].left].value
nextNode = monkeys["root"].right
fmt.Println("Root's right is the unknown one", nextNode)
} else {
targetValue = monkeys[monkeys["root"].right].value
nextNode = monkeys["root"].left
fmt.Println("Root's left is the unknown one", nextNode)
}
for !monkeys["humn"].valueSet {
nextState := monkeys[nextNode]
if nextState.valueSet {
fmt.Println("PANIC: Grounded in a node with the value set")
return
} else if nextState.operation == OpTarget {
nextState.value = targetValue
nextState.valueSet = true
monkeys[nextNode] = nextState
} else if monkeys[nextState.left].valueSet {
nextState.value = targetValue
nextState.valueSet = true
monkeys[nextNode] = nextState
switch nextState.operation {
case OpAdd:
// T = V + X
// T - V = X
targetValue = targetValue - monkeys[nextState.left].value
case OpMul:
// T = V * X
// T / V = X
targetValue = targetValue / monkeys[nextState.left].value
case OpSub:
// T = V - X
// T + X = V
// X = V - T
targetValue = monkeys[nextState.left].value - targetValue
case OpDiv:
// T = V / X
// TX = V
// X = V / T
targetValue = monkeys[nextState.left].value / targetValue
default:
fmt.Println("PANIC: Bad operation in back compute")
}
nextNode = nextState.right
} else if monkeys[nextState.right].valueSet {
nextState.value = targetValue
nextState.valueSet = true
monkeys[nextNode] = nextState
switch nextState.operation {
case OpAdd:
// T = X + V
// T - V = X
targetValue = targetValue - monkeys[nextState.right].value
case OpMul:
// T = X * V
targetValue = targetValue / monkeys[nextState.right].value
case OpSub:
// T = X - V
// T + V = X
targetValue = targetValue + monkeys[nextState.right].value
case OpDiv:
// T = X / V
// TV = X
targetValue = targetValue * monkeys[nextState.right].value
default:
fmt.Println("PANIC: Bad operation in back compute")
}
nextNode = nextState.left
} else {
fmt.Println("PANIC: Trouble with a double split in search")
return
}
}
fmt.Println("Actually, my value should be", monkeys["humn"].value)
}

635
solutions/day22/day22.go Normal file
View File

@@ -0,0 +1,635 @@
package day22
import (
"bufio"
"fmt"
"os"
)
type Command int
type Tile int
type Direction int
type Face int
type Board [][]Tile
type FaceMap map[Face]Board
const (
TurnRight Command = -1
TurnLeft = -2
)
const (
Void Tile = iota
Empty
Wall
)
const (
Right Direction = 0
Down = 1
Left = 2
Up = 3
)
const (
TopFace Face = iota
BottomFace
LeftFace
RightFace
FrontFace
BackFace
)
func printBoard(board Board) {
for _, row := range board {
for _, tile := range row {
switch tile {
case Void:
fmt.Printf(" ")
case Empty:
fmt.Printf(".")
case Wall:
fmt.Printf("#")
}
}
fmt.Println()
}
}
func parseCommands(runes []rune) []Command {
result := []Command{}
accum := 0
for _, r := range runes {
if r >= '0' && r <= '9' {
accum = (accum * 10) + int(r-'0')
} else {
result = append(result, Command(accum))
accum = 0
if r == 'R' {
result = append(result, TurnRight)
} else {
result = append(result, TurnLeft)
}
}
}
if accum > 0 {
result = append(result, Command(accum))
}
return result
}
func parseBoardLine(runes []rune) []Tile {
result := []Tile{}
for _, r := range runes {
switch r {
case ' ':
result = append(result, Void)
case '.':
result = append(result, Empty)
case '#':
result = append(result, Wall)
default:
fmt.Println("PANIC: Illegal character in board map", string(r))
}
}
return result
}
func initialPosition(board Board) (x int, y int) {
for idx, tile := range board[0] {
if tile == Empty {
x = idx
y = 0
return
}
}
fmt.Println("PANIC: Couldn't figure out initial position")
x = 0
y = 0
return
}
func turn(direction Direction, turn Command) Direction {
switch direction {
case Up:
switch turn {
case TurnLeft:
return Left
case TurnRight:
return Right
}
case Right:
switch turn {
case TurnLeft:
return Up
case TurnRight:
return Down
}
case Down:
switch turn {
case TurnLeft:
return Right
case TurnRight:
return Left
}
case Left:
switch turn {
case TurnLeft:
return Down
case TurnRight:
return Up
}
}
fmt.Println("PANIC: turn default WTF")
return Down
}
type State2D struct {
x int
y int
direction Direction
board Board
}
func step2d(count int, state *State2D) {
if count == 0 {
return
}
keepGoing := true
switch state.direction {
case Right:
currentRow := state.board[state.y]
tester := (state.x + 1) % len(currentRow)
for {
if currentRow[tester] == Void {
tester = (tester + 1) % len(currentRow)
continue
} else if currentRow[tester] == Wall {
keepGoing = false
break
} else {
(*state).x = tester
break
}
}
case Left:
currentRow := state.board[state.y]
tester := state.x - 1
for {
if tester < 0 {
tester = len(currentRow) - 1
}
if currentRow[tester] == Void {
tester -= 1
continue
} else if currentRow[tester] == Wall {
keepGoing = false
break
} else {
(*state).x = tester
break
}
}
case Up:
tester := state.y - 1
for {
if tester < 0 {
tester = len(state.board) - 1
}
if state.board[tester][state.x] == Void {
tester -= 1
continue
} else if state.board[tester][state.x] == Wall {
keepGoing = false
break
} else {
(*state).y = tester
break
}
}
case Down:
fmt.Println("Moving down count is", count, "y value", state.y)
tester := (state.y + 1) % len(state.board)
for {
if state.board[tester][state.x] == Void {
tester = (tester + 1) % len(state.board)
continue
} else if state.board[tester][state.x] == Wall {
fmt.Println("Hit wall at tester", tester)
keepGoing = false
break
} else {
(*state).y = tester
break
}
}
default:
fmt.Println("BAD")
}
if keepGoing {
step2d(count-1, state)
}
}
func copyFace(startX int, startY int, faceSize int, board Board) Board {
retval := Board{}
for y := 0; y < faceSize; y++ {
newRow := []Tile{}
for x := 0; x < faceSize; x++ {
newRow = append(newRow, board[y+startY][x+startX])
}
retval = append(retval, newRow)
}
return retval
}
func validPoint(x int, y int, board Board) bool {
return (x >= 0) && (y >= 0) && (x < len(board[0])) && (y < len(board))
}
var faceMoves map[Face]map[Direction]Face = map[Face]map[Direction]Face{
TopFace: map[Direction]Face{
Up: BackFace,
Left: LeftFace,
Right: RightFace,
Down: FrontFace,
},
BottomFace: map[Direction]Face{
Up: FrontFace,
Left: LeftFace,
Right: RightFace,
Down: BackFace,
},
LeftFace: map[Direction]Face{
Up: TopFace,
Left: BackFace,
Right: FrontFace,
Down: BottomFace,
},
RightFace: map[Direction]Face{
Up: TopFace,
Left: FrontFace,
Right: BackFace,
Down: BottomFace,
},
FrontFace: map[Direction]Face{
Up: TopFace,
Left: LeftFace,
Right: RightFace,
Down: BottomFace,
},
BackFace: map[Direction]Face{
Up: BackFace,
Left: RightFace,
Right: FrontFace,
Down: FrontFace,
},
}
var faceName map[Face]string = map[Face]string{
TopFace: "top",
BottomFace: "bottom",
LeftFace: "left",
RightFace: "right",
FrontFace: "front",
BackFace: "back",
}
var dirName map[Direction]string = map[Direction]string{
Up: "up",
Down: "down",
Left: "left",
Right: "right",
}
var tileName map[Tile]string = map[Tile]string{
Void: "void",
Empty: "empty",
Wall: "wall",
}
type State3D struct {
x int
y int
face Face
direction Direction
board FaceMap
}
func translate(x int, y int, faceSize int, face Face, dir Direction) (resx int, resy int, resdir Direction) {
switch face {
case TopFace:
resdir = Down
switch dir {
case Right, Left:
resy = 0
resx = y
case Up, Down:
resy = 0
resx = x
}
case FrontFace:
resdir = dir
switch dir {
case Up:
resy = faceSize - 1
resx = x
case Down:
resy = 0
resx = x
case Left:
resy = y
resx = faceSize - 1
case Right:
resy = y
resx = 0
}
case LeftFace:
switch dir {
case Up:
resx = 0
resy = x
resdir = Right
case Down:
resx = 0
resy = x
resdir = Right
case Left:
resy = y
resx = faceSize - 1
resdir = Left
case Right:
resy = y
resx = 0
resdir = Right
}
case RightFace:
switch dir {
case Up:
resx = faceSize - 1
resy = x
resdir = Left
case Down:
resx = faceSize - 1
resy = x
resdir = Left
case Left:
resx = faceSize - 1
resy = y
resdir = Left
case Right:
resy = y
resx = 0
resdir = Right
}
case BackFace:
switch dir {
case Up:
resx = x
resy = 0
resdir = Down
case Down:
resx = x
resy = faceSize - 1
resdir = Up
case Left:
resx = faceSize - 1
resy = y
resdir = Right
case Right:
resy = y
resx = 0
resdir = Left
}
case BottomFace:
switch dir {
case Up:
resx = x
resy = faceSize - 1
resdir = Up
case Down:
resx = x
resy = faceSize - 1
resdir = Up
case Left:
resx = y
resy = faceSize - 1
resdir = Up
case Right:
resy = faceSize - 1
resx = y
resdir = Up
}
}
return
}
func step3d(count int, state *State3D) {
if count == 0 {
return
}
for i := 0; i < count; i++ {
newX := state.x
newY := state.y
newFace := state.face
newDirection := state.direction
switch state.direction {
case Up:
newY -= 1
case Down:
newY += 1
case Left:
newX -= 1
case Right:
newX += 1
}
if !validPoint(newX, newY, state.board[state.face]) {
newFace = faceMoves[state.face][state.direction]
newX, newY, newDirection = translate(newX, newY, len(state.board[state.face]), state.face, state.direction)
}
fmt.Printf("(%d, %d) going %s on %s ---> (%d, %d) going %s on %s [%s]\n", state.x, state.y, dirName[state.direction], faceName[state.face], newX, newY, dirName[newDirection], faceName[newFace], tileName[state.board[newFace][newY][state.x]])
if state.board[newFace][newY][newX] == Wall {
return
}
(*state).x = newX
(*state).y = newY
(*state).face = newFace
(*state).direction = newDirection
}
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var commands []Command
initialBoard := Board{}
for scanner.Scan() {
line := scanner.Text()
runes := []rune(line)
if len(runes) > 0 {
if runes[0] >= '0' && runes[0] <= '9' {
commands = parseCommands(runes)
} else {
initialBoard = append(initialBoard, parseBoardLine(runes))
}
}
}
file.Close()
maximumRowLength := 0
for _, row := range initialBoard {
if len(row) > maximumRowLength {
maximumRowLength = len(row)
}
}
board := Board{}
for _, row := range initialBoard {
for len(row) < maximumRowLength {
row = append(row, Void)
}
board = append(board, row)
}
printBoard(board)
startX, startY := initialPosition(board)
x, y := startX, startY
fmt.Println("initial position is", x, y)
state := State2D{x, y, Right, board}
for _, command := range commands {
fmt.Println("x", state.x, "y", state.y, "direction", dirName[state.direction])
fmt.Println("Running", command)
switch command {
case TurnRight:
state.direction = turn(state.direction, TurnRight)
case TurnLeft:
state.direction = turn(state.direction, TurnLeft)
default:
step2d(int(command), &state)
}
}
finalRow := state.y + 1
finalColumn := state.x + 1
finalPassword := 1000*finalRow + 4*finalColumn + int(state.direction)
fmt.Println("Final row is", finalRow, "final column is", finalColumn, "final password is", finalPassword)
narrowestSection := len(board[0])
for _, row := range board {
startIdx := -1
endIdx := -1
for idx, tile := range row {
if tile != Void && startIdx == -1 {
startIdx = idx
}
if tile == Void && (startIdx != -1) && (endIdx == -1) {
endIdx = idx
}
}
if endIdx == -1 {
endIdx = len(row) - 1
}
if (endIdx - startIdx) < narrowestSection {
narrowestSection = endIdx - startIdx
}
}
cubeFaceSize := narrowestSection
fmt.Println("Cube face size is", cubeFaceSize)
faceMap := FaceMap{}
currentFace := TopFace
currentSpineX := startX
currentSpineY := startY
for validPoint(currentSpineX, currentSpineY, board) {
faceMap[currentFace] = copyFace(currentSpineX, currentSpineY, cubeFaceSize, board)
fmt.Printf("Found %s face at (%d,%d)\n", faceName[currentFace], currentSpineX, currentSpineY)
leftwardsFace := faceMoves[currentFace][Left]
for leftX := currentSpineX - cubeFaceSize; validPoint(leftX, currentSpineY, board) && board[currentSpineY][leftX] != Void; leftX -= cubeFaceSize {
faceMap[leftwardsFace] = copyFace(leftX, currentSpineY, cubeFaceSize, board)
fmt.Printf("Found %s face at (%d,%d)\n", faceName[leftwardsFace], leftX, currentSpineY)
fmt.Println("Moving face", faceName[leftwardsFace], "left to", faceName[faceMoves[leftwardsFace][Left]])
leftwardsFace = faceMoves[leftwardsFace][Left]
}
rightwardsFace := faceMoves[currentFace][Right]
for rightX := currentSpineX + cubeFaceSize; validPoint(rightX, currentSpineY, board) && board[currentSpineY][rightX] != Void; rightX += cubeFaceSize {
faceMap[rightwardsFace] = copyFace(rightX, currentSpineY, cubeFaceSize, board)
fmt.Printf("Found %s face at (%d,%d)\n", faceName[rightwardsFace], rightX, currentSpineY)
fmt.Println("Moving face", faceName[rightwardsFace], "right to", faceName[faceMoves[rightwardsFace][Left]])
rightwardsFace = faceMoves[rightwardsFace][Right]
}
currentSpineY += cubeFaceSize
fmt.Println("Moving face", faceName[currentFace], "down to", faceName[faceMoves[currentFace][Down]])
currentFace = faceMoves[currentFace][Down]
}
if len(faceMap) != 6 {
fmt.Println("COULD NOT FIND ALL SIX FACES")
return
}
for face, board := range faceMap {
fmt.Println("Board", faceName[face])
printBoard(board)
}
fmt.Println("initial position is", x, y)
state3 := State3D{0, 0, TopFace, Right, faceMap}
for _, command := range commands {
fmt.Println("x", state3.x, "y", state3.y, "face", faceName[state3.face], "direction", dirName[state3.direction])
fmt.Println("Running", command)
switch command {
case TurnRight:
state3.direction = turn(state3.direction, TurnRight)
case TurnLeft:
state3.direction = turn(state3.direction, TurnLeft)
default:
step3d(int(command), &state3)
}
}
finalRow = state3.y + 1
finalColumn = state3.x + 1
finalPassword = 1000*finalRow + 4*finalColumn + int(state.direction)
fmt.Println("Final row is", finalRow, "final column is", finalColumn, "final password is", finalPassword)
}

237
solutions/day23/day23.go Normal file
View File

@@ -0,0 +1,237 @@
package day23
import (
"bufio"
"fmt"
"os"
)
type Direction int
const (
North Direction = iota
South
East
West
)
type Point struct {
x int
y int
}
type ElfLocations map[Point]bool
func extents(locations ElfLocations) (topLeft Point, bottomRight Point) {
lowestX := 1000000000000000000
highestX := -1000000000000000000
lowestY := 1000000000000000000
highestY := -1000000000000000000
for location := range locations {
if location.x < lowestX {
lowestX = location.x
}
if location.x > highestX {
highestX = location.x
}
if location.y < lowestY {
lowestY = location.y
}
if location.y > highestY {
highestY = location.y
}
}
topLeft = Point{lowestX, lowestY}
bottomRight = Point{highestX, highestY}
return
}
func hasElf(x int, y int, locations ElfLocations) bool {
_, exists := locations[Point{x, y}]
return exists
}
func printMap(locations ElfLocations) {
topLeft, bottomRight := extents(locations)
fmt.Println("top left", topLeft)
fmt.Println("bottom right", bottomRight)
for y := topLeft.y; y <= bottomRight.y; y++ {
for x := topLeft.x; x <= bottomRight.x; x++ {
if hasElf(x, y, locations) {
fmt.Printf("#")
} else {
fmt.Printf(".")
}
}
fmt.Println()
}
}
func directionIsEmpty(direction Direction, x int, y int, locations ElfLocations) bool {
switch direction {
case North:
return !hasElf(x-1, y-1, locations) && !hasElf(x, y-1, locations) && !hasElf(x+1, y-1, locations)
case South:
return !hasElf(x-1, y+1, locations) && !hasElf(x, y+1, locations) && !hasElf(x+1, y+1, locations)
case West:
return !hasElf(x-1, y-1, locations) && !hasElf(x-1, y, locations) && !hasElf(x-1, y+1, locations)
case East:
return !hasElf(x+1, y-1, locations) && !hasElf(x+1, y, locations) && !hasElf(x+1, y+1, locations)
}
return false
}
func showDirection(dir *Direction) string {
if dir == nil {
return "<nil>"
}
switch *dir {
case North:
return "north"
case South:
return "south"
case East:
return "east"
case West:
return "west"
}
return "<???>"
}
func proposeMove(x int, y int, directionPreference []Direction, locations ElfLocations) *Point {
var firstEmpty *Direction = nil
allEmpty := true
for _, dir := range directionPreference {
if directionIsEmpty(dir, x, y, locations) {
if firstEmpty == nil {
firstEmpty = new(Direction)
*firstEmpty = dir
}
} else {
allEmpty = false
}
}
if allEmpty {
return nil
}
if firstEmpty == nil {
return nil
}
switch *firstEmpty {
case North:
return &Point{x, y - 1}
case South:
return &Point{x, y + 1}
case East:
return &Point{x + 1, y}
case West:
return &Point{x - 1, y}
}
fmt.Println("PANIC: fell through?!")
return nil
}
func runRound(locations ElfLocations, preferredDirections []Direction) (newLocations ElfLocations, done bool) {
suggestedMoves := map[Point]Point{}
takenPoints := map[Point]int{}
for location := range locations {
proposed := proposeMove(location.x, location.y, preferredDirections, locations)
if proposed != nil {
fmt.Println("Proposed to move", location, "to", proposed)
suggestedMoves[location] = *proposed
curVal := takenPoints[*proposed]
takenPoints[*proposed] = curVal + 1
}
}
newLocations = ElfLocations{}
done = true
for originalLocation := range locations {
newPlace, hasNewPlace := suggestedMoves[originalLocation]
if hasNewPlace && takenPoints[newPlace] <= 1 {
newLocations[newPlace] = true
done = false
} else {
newLocations[originalLocation] = true
}
}
return
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
elfLocations := ElfLocations{}
y := 0
for scanner.Scan() {
line := []rune(scanner.Text())
for x, r := range line {
if r == '#' {
elfLocations[Point{x, y}] = true
}
}
y += 1
}
file.Close()
preferredDirections := []Direction{North, South, West, East}
for i := 0; i < 10; i++ {
fmt.Println("Round", i)
printMap(elfLocations)
newLocations, done := runRound(elfLocations, preferredDirections)
preferredDirections = append(preferredDirections[1:], preferredDirections[0])
if done {
fmt.Println("No one moves after this round, so we're done.")
break
}
elfLocations = newLocations
}
printMap(elfLocations)
topLeft, bottomRight := extents(elfLocations)
emptyGround := 0
for x := topLeft.x; x <= bottomRight.x; x++ {
for y := topLeft.y; y <= bottomRight.y; y++ {
if !hasElf(x, y, elfLocations) {
emptyGround += 1
}
}
}
fmt.Println(emptyGround, "empty spots in smallest bounding box.")
round := 11
for {
fmt.Println("Starting round", round)
newLocations, done := runRound(elfLocations, preferredDirections)
if done {
fmt.Println("No one moved after round", round)
break
}
elfLocations = newLocations
preferredDirections = append(preferredDirections[1:], preferredDirections[0])
round += 1
}
}

92
solutions/day3/day3.go Normal file
View File

@@ -0,0 +1,92 @@
package day3
import (
"bufio"
"fmt"
"os"
)
func in_set(target rune, set []rune) bool {
for _, char := range set {
if char == target {
return true
}
}
return false
}
func priority(value rune) int {
var base_value int = 0
if value >= 'A' && value <= 'Z' {
base_value = int('A') - 27
}
if value >= 'a' && value <= 'z' {
base_value = int('a') - 1
}
return int(value) - base_value
}
func part1_addition(runes []rune) int {
var total int = 0
midpoint := len(runes) / 2
left_runes := runes[0:midpoint]
right_runes := runes[midpoint:]
for pos, char := range left_runes {
if !in_set(char, left_runes[0:pos]) {
if in_set(char, right_runes) {
total += priority(char)
}
}
}
return total
}
func score_badge(set1 []rune, set2 []rune, set3 []rune) int {
for pos, char := range set1 {
if !in_set(char, set1[0:pos]) {
if in_set(char, set2) && in_set(char, set3) {
return priority(char)
}
}
}
fmt.Println("PANIC: Couldn't find overlapping badge item")
return 0
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var total_overlap int = 0
var total_badge int = 0
var grouping [][]rune = [][]rune{}
for scanner.Scan() {
line := scanner.Text()
runes := []rune(line)
total_overlap += part1_addition(runes)
grouping = append(grouping, runes)
if len(grouping) == 3 {
total_badge += score_badge(grouping[0], grouping[1], grouping[2])
grouping = [][]rune{}
}
}
file.Close()
fmt.Println("Total initial score is", total_overlap)
fmt.Println("Total badge score is", total_badge)
}

114
solutions/day4/day4.go Normal file
View File

@@ -0,0 +1,114 @@
package day4
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
)
type SectionRange struct {
start int
end int
}
func total_overlap(a SectionRange, b SectionRange) bool {
return ((a.start >= b.start) && (a.end <= b.end)) ||
((b.start >= a.start) && (b.end <= a.end))
}
func partial_overlap(a SectionRange, b SectionRange) bool {
return (a.start >= b.start && a.start <= b.end) ||
(a.end >= b.end && a.end <= b.end) ||
(b.start >= a.start && b.start <= a.end) ||
(b.end >= a.start && b.end <= a.end)
}
func range_from_string(s string) (ret_range SectionRange, err error) {
ret_range = SectionRange{0, 0}
items := strings.Split(s, "-")
if len(items) != 2 {
err = errors.New("invalid range format")
return
}
start, start_err := strconv.Atoi(items[0])
if start_err != nil {
err = start_err
return
}
ret_range.start = start
end, end_err := strconv.Atoi(items[1])
if end_err != nil {
err = end_err
return
}
ret_range.end = end
err = nil
return
}
func line_to_pair(s string) (left SectionRange, right SectionRange, err error) {
items := strings.Split(s, ",")
if len(items) != 2 {
err = errors.New("invalid range format")
return
}
left, left_err := range_from_string(items[0])
if left_err != nil {
err = left_err
return
}
right, right_err := range_from_string(items[1])
if right_err != nil {
err = right_err
return
}
return
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
var total_overlapping int = 0
var partial_overlapping int = 0
for scanner.Scan() {
line := scanner.Text()
left, right, err := line_to_pair(line)
if err != nil {
fmt.Println("ERROR: failed to parse line:", err)
} else {
if total_overlap(left, right) {
total_overlapping += 1
}
if partial_overlap(left, right) {
partial_overlapping += 1
}
}
}
file.Close()
fmt.Println("# of overlapping pairs", total_overlapping)
fmt.Println("# of partially overlapping pairs", partial_overlapping)
}

282
solutions/day5/day5.go Normal file
View File

@@ -0,0 +1,282 @@
package day5
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
"unicode"
)
type Stack struct {
identity rune
then *Stack
}
func newStack() *Stack {
return nil
}
func push(box rune, stack *Stack) *Stack {
var retval *Stack = new(Stack)
retval.identity = box
retval.then = stack
return retval
}
func pushToEnd(box rune, stack *Stack) *Stack {
if stack == nil {
retval := new(Stack)
retval.identity = box
retval.then = nil
return retval
} else {
stack.then = pushToEnd(box, stack.then)
return stack
}
}
func pushSet(front *Stack, stack *Stack) *Stack {
var prev *Stack = nil
current := front
for current != nil {
prev = current
current = current.then
}
if prev == nil {
return stack
} else {
prev.then = stack
}
return front
}
func pop(stack *Stack) (newStack *Stack, value rune, err error) {
if stack == nil {
newStack = nil
value = 'X'
err = errors.New("attempt to pop from empty stack")
return
}
value = stack.identity
newStack = stack.then
return
}
func popSet(amt int, stack *Stack) (newStack *Stack, set *Stack, err error) {
var prev *Stack = nil
var current *Stack = stack
for i := 0; i < amt; i++ {
if current == nil {
err = errors.New("tried to take more items than existed in stack")
return
}
prev = current
current = current.then
}
if prev != nil {
set = stack
prev.then = nil
} else {
set = nil
}
newStack = current
return
}
func stackLength(stack *Stack) int {
if stack == nil {
return 0
} else {
return 1 + stackLength(stack.then)
}
}
type Workspace []*Stack
func addLine(line string, input *Workspace) (err error) {
currentColumn := 0
fmt.Println("Workspace line's length is", len(line))
for len(line) >= 3 {
fmt.Println(" line length now", len(line))
// make sure we've got enough space in the workspace
for currentColumn+1 >= len(*input) {
*input = append(*input, newStack())
}
// see if there's actually something there
if line[0] == '[' && unicode.IsLetter(rune(line[1])) {
fmt.Println("Adding", rune(line[1]), "to column", currentColumn)
(*input)[currentColumn] = pushToEnd(rune(line[1]), (*input)[currentColumn])
} else if line[0] != ' ' {
err = errors.New("doesn't start with square or blank")
return
}
currentColumn += 1
if len(line) == 3 {
return
}
if len(line) > 3 {
line = line[4:]
}
}
return
}
func runMove(problem int, move OperatorMove, workspace *Workspace) error {
switch problem {
case 1:
for i := 0; i < move.count; i++ {
newFrom, value, err := pop((*workspace)[move.from])
if err != nil {
return err
}
(*workspace)[move.from] = newFrom
(*workspace)[move.to] = push(value, (*workspace)[move.to])
}
return nil
case 2:
newFrom, poppedSet, err := popSet(move.count, (*workspace)[move.from])
if err != nil {
return err
}
(*workspace)[move.from] = newFrom
(*workspace)[move.to] = pushSet(poppedSet, (*workspace)[move.to])
return nil
default:
return errors.New("weird problem number found in runMove")
}
}
func printWorkspace(input Workspace) {
maxLength := 0
for _, element := range input {
current := stackLength(element)
if current > maxLength {
maxLength = current
}
}
for _, element := range input {
current := stackLength(element)
blanks := maxLength - current
outputString := ""
for i := 0; i < blanks; i++ {
outputString = outputString + " "
}
node := element
for node != nil {
outputString = outputString + fmt.Sprintf("[%c] ", node.identity)
node = node.then
}
fmt.Println(outputString)
}
}
type OperatorMove struct {
count int
from int
to int
}
func parseMove(line string) (move OperatorMove, err error) {
words := strings.Split(line, " ")
if len(words) != 6 {
err = errors.New("wrong number of words in move line")
return
}
if words[0] != "move" || words[2] != "from" || words[4] != "to" {
err = fmt.Errorf("illegal words in move line: %s/%s/%s", words[0], words[2], words[4])
return
}
count, cerr := strconv.Atoi(words[1])
from, ferr := strconv.Atoi(words[3])
to, terr := strconv.Atoi(words[5])
if cerr != nil || ferr != nil || terr != nil {
err = fmt.Errorf("illegal number found: %s/%s/%s", words[1], words[3], words[5])
}
move = OperatorMove{count, from - 1, to - 1}
return
}
func Run(filename string, problemStr string) {
problem, err := strconv.Atoi(problemStr)
if err != nil || (problem < 1 || problem > 2) {
fmt.Println("Didn't understand problem number", os.Args[2], "should be 1 or 2")
}
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
workspace := new(Workspace)
moves := []OperatorMove{}
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, "[") {
fmt.Println("Adding workspace line")
addLine(line, workspace)
} else {
move, err := parseMove(line)
if err == nil {
fmt.Println("Adding move", move)
moves = append(moves, move)
} else {
fmt.Println("Skipping dead line")
}
}
}
file.Close()
printWorkspace(*workspace)
for count, move := range moves {
fmt.Println("-----", count+1, "-----")
runMove(problem, move, workspace)
printWorkspace(*workspace)
}
resultString := ""
for _, stack := range *workspace {
if stack == nil {
resultString += "*"
} else {
resultString += fmt.Sprintf("%c", rune((*stack).identity))
}
}
fmt.Println("Final string is", resultString)
}

58
solutions/day6/day6.go Normal file
View File

@@ -0,0 +1,58 @@
package day6
import (
"bufio"
"fmt"
"os"
"strconv"
)
func allDifferent(a string) bool {
length := len(a)
for i := 0; i < length; i++ {
for j := i + 1; j < length; j++ {
if a[i] == a[j] {
return false
}
}
}
return true
}
func Run(filename string, problemStr string) {
problem, err := strconv.Atoi(problemStr)
if err != nil || !(problem == 4 || problem == 14) {
fmt.Println("Didn't understand problem number", os.Args[2], "should be 4 or 14")
}
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
line := scanner.Text()
if len(line) > 0 {
var index int
offset := problem - 1
for index = offset; index < len(line); index++ {
if allDifferent(line[index-offset : index+1]) {
break
}
}
fmt.Println("First marker after character", index+1)
}
}
file.Close()
}

159
solutions/day7/day7.go Normal file
View File

@@ -0,0 +1,159 @@
package day7
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
)
type FileSystem struct {
name string
parent *FileSystem
subdirectories []*FileSystem
files []FileInfo
}
func newFileSystem(name string, parent *FileSystem) *FileSystem {
return &FileSystem{name, parent, []*FileSystem{}, []FileInfo{}}
}
func printFileTree(tree *FileSystem, prefix string) {
fmt.Println(prefix, "-", tree.name, fmt.Sprintf("(dir size=%d)", totalSize(tree)))
for _, file := range tree.files {
fmt.Println(prefix, " ", "-", file.name, fmt.Sprintf("(file, size=%d)", file.size))
}
for _, dir := range tree.subdirectories {
printFileTree(dir, prefix+" ")
}
}
func totalSize(tree *FileSystem) int {
total := 0
for _, file := range tree.files {
total += file.size
}
for _, dir := range tree.subdirectories {
total += totalSize(dir)
}
return total
}
func computePart1(tree *FileSystem) int {
result := 0
for _, dir := range tree.subdirectories {
result += computePart1(dir)
}
currentSize := totalSize(tree)
if currentSize <= 100000 {
result += currentSize
}
return result
}
func computePart2(tree *FileSystem, size int) int {
result := 70000000
for _, dir := range tree.subdirectories {
subResult := computePart2(dir, size)
if subResult < result {
result = subResult
}
}
currentSize := totalSize(tree)
if currentSize > size && currentSize < result {
result = currentSize
}
return result
}
type FileInfo struct {
name string
size int
}
func parseFileInfo(line string) (result FileInfo, err error) {
splits := strings.Split(line, " ")
if len(splits) != 2 {
err = errors.New("too many values from file info split")
return
}
size, err := strconv.Atoi(splits[0])
if err != nil {
err = errors.New(fmt.Sprintf("could not parse file size: '%s'", splits[0]))
return
}
result = FileInfo{splits[1], size}
return
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
root := newFileSystem("/", nil)
current := root
for scanner.Scan() {
line := scanner.Text()
fmt.Println("line", line)
if strings.HasPrefix(line, "$ cd /") {
current = root
} else if strings.HasPrefix(line, "$ cd ..") {
current = current.parent
} else if strings.HasPrefix(line, "$ cd ") {
for _, subdir := range current.subdirectories {
if subdir.name == line[5:] {
current = subdir
continue
}
}
} else if strings.HasPrefix(line, "$ ls") {
// don't do anything
} else if strings.HasPrefix(line, "dir ") {
newTree := newFileSystem(line[4:], current)
current.subdirectories = append(current.subdirectories, newTree)
} else {
fileInfo, err := parseFileInfo(line)
if err != nil {
fmt.Println("PANIC:", err)
return
}
current.files = append((*current).files, fileInfo)
}
}
file.Close()
printFileTree(root, "")
fmt.Println("example first part", computePart1(root))
unusedSpace := 70000000 - totalSize(root)
fmt.Println("unused space is currently", unusedSpace)
needToGet := 30000000 - unusedSpace
fmt.Println("need to find a directory at least", needToGet, "bytes big")
fmt.Println("that directory has size", computePart2(root, needToGet))
}

142
solutions/day8/day8.go Normal file
View File

@@ -0,0 +1,142 @@
package day8
import (
"bufio"
"fmt"
"os"
"strconv"
)
func isVisible(treeMap [][]int, x int, y int) bool {
treeHeight := treeMap[y][x]
left_test := true
for trial := 0; trial < x; trial++ {
left_test = left_test && treeMap[y][trial] < treeHeight
}
right_test := true
for trial := x + 1; trial < len(treeMap[y]); trial++ {
right_test = right_test && treeMap[y][trial] < treeHeight
}
up_test := true
for trial := 0; trial < y; trial++ {
up_test = up_test && treeMap[trial][x] < treeHeight
}
down_test := true
for trial := y + 1; trial < len(treeMap); trial++ {
down_test = down_test && treeMap[trial][x] < treeHeight
}
fmt.Println("Test for x", x, "y", y, "which has height", treeHeight, "tests are", left_test, right_test, up_test, down_test)
return (left_test || right_test || up_test || down_test)
}
func score(treeMap [][]int, x int, y int) int {
treeHeight := treeMap[y][x]
if x == 0 || y == 0 {
return 0
}
final := 1
score := 0
for trial := x - 1; trial >= 0; trial-- {
if treeMap[y][trial] >= treeHeight {
score += 1
break
}
score += 1
}
final *= score
score = 0
for trial := x + 1; trial < len(treeMap[y]); trial++ {
if treeMap[y][trial] >= treeHeight {
score += 1
break
}
score += 1
}
final *= score
score = 0
for trial := y - 1; trial >= 0; trial-- {
if treeMap[trial][x] >= treeHeight {
score += 1
break
}
score += 1
}
final *= score
score = 0
for trial := y + 1; trial < len(treeMap); trial++ {
if treeMap[trial][x] >= treeHeight {
score += 1
break
}
score += 1
}
final *= score
return final
}
func Run(filename string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
treeMap := [][]int{}
for scanner.Scan() {
line := scanner.Text()
row := []int{}
for _, c := range line {
value, err := strconv.Atoi(string(c))
if err != nil {
fmt.Println("PANIC: bad character")
return
}
row = append(row, value)
}
treeMap = append(treeMap, row)
}
file.Close()
width := len(treeMap[0])
height := len(treeMap)
visibleTrees := 2*width + 2*height - 4
bestScore := 1
for y := 1; y < (height - 1); y++ {
for x := 1; x < (width - 1); x++ {
if isVisible(treeMap, x, y) {
visibleTrees += 1
//fmt.Printf("*")
} else {
//fmt.Printf("%d", treeMap[y][x])
}
current := score(treeMap, x, y)
if current > bestScore {
bestScore = current
}
}
//fmt.Println()
}
fmt.Println("There are", visibleTrees, "visible trees")
fmt.Println("Best score is", bestScore)
}

153
solutions/day9/day9.go Normal file
View File

@@ -0,0 +1,153 @@
package day9
import (
"bufio"
"fmt"
"os"
"strconv"
)
type Point struct {
x int
y int
}
func makeSnake(length int) []*Point {
snake := []*Point{}
for i := 0; i < length; i++ {
snake = append(snake, &Point{0, 0})
}
return snake
}
func move(direction rune, point *Point) {
switch direction {
case 'U':
point.y -= 1
case 'R':
point.x += 1
case 'D':
point.y += 1
case 'L':
point.x -= 1
default:
fmt.Println("PANIC! Bad direction", string(direction))
}
}
func abs(x int) int {
if x >= 0 {
return x
} else {
return -x
}
}
func areTouching(head *Point, tail *Point) bool {
return abs(head.x-tail.x) <= 1 && abs(head.y-tail.y) <= 1
}
func updateTail(head *Point, tail *Point) {
if areTouching(head, tail) {
return
}
if head.x == tail.x {
if head.y <= tail.y-2 {
tail.y -= 1
return
}
if head.y >= tail.y+2 {
tail.y += 1
return
}
}
if head.y == tail.y {
if head.x <= tail.x-2 {
tail.x -= 1
return
}
if head.x >= tail.x+2 {
tail.x += 1
return
}
}
proposedTails := []Point{
{tail.x - 1, tail.y - 1},
{tail.x - 1, tail.y + 1},
{tail.x + 1, tail.y - 1},
{tail.x + 1, tail.y + 1}}
for _, proposed := range proposedTails {
if areTouching(head, &proposed) {
tail.x = proposed.x
tail.y = proposed.y
return
}
}
fmt.Println("PANIC, couldn't figure out next step for", *head, "and", *tail)
}
func contains(array *[]Point, point Point) bool {
for _, val := range *array {
if val == point {
return true
}
}
return false
}
func runMove(direction rune, amount int, snake []*Point, visitedPoints *[]Point) {
for i := 0; i < amount; i++ {
move(direction, snake[0])
for t := 1; t < len(snake); t++ {
updateTail(snake[t-1], snake[t])
}
lastPoint := snake[len(snake)-1]
if !contains(visitedPoints, *lastPoint) {
*visitedPoints = append(*visitedPoints, *lastPoint)
}
}
}
func Run(filename string, lengthStr string) {
file, err := os.Open(filename)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
snakeLength, err := strconv.Atoi(lengthStr)
if err != nil {
fmt.Println("Error parsing snake length:", err)
return
}
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
snake := makeSnake(snakeLength)
visitedPoints := []Point{}
for scanner.Scan() {
line := scanner.Text()
amount, err := strconv.Atoi(line[2:])
if err != nil {
fmt.Println("Could not parse argument", line)
return
}
runMove(rune(line[0]), amount, snake, &visitedPoints)
}
fmt.Println("The tail visited", len(visitedPoints), "points")
file.Close()
}