# advent_of_code_2022

My (attempted) solutions to the 2022 Advent of Code
git clone https://git.eamoncaddigan.net/advent_of_code_2022.git
Log | Files | Refs | README

```commit 25de54a3a55bb34d9111fb6915cef329d0896296
parent 6779cfa5c75ac163437cb9a67907825067a42d04
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date:   Tue, 13 Dec 2022 22:06:11 -0800

Solution to day 13, part 2.

Only 66 minutes after the deadline. I bet people are already finished
with day 14 now. And I still need to go back for day 12.

Diffstat:
Msrc/day_13.jl | 14+++++++++++++-
```
```1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/day_13.jl b/src/day_13.jl
@@ -1,3 +1,4 @@
+#!/usr/bin/env julia
# https://adventofcode.com/2022/day/13
using AdventOfCode

@@ -78,7 +79,18 @@ end
@assert part_1(example) == 13
@info part_1(input)

+# Redoing my parsing function for part 2
+function parse_input2(input)
+    [
+        map(eval ∘ Meta.parse, Iterators.filter(x -> x != "", input));
+        [ [[2]], [[6]] ]
+    ]
+end
+
function part_2(input)
-    nothing
+    packets = parse_input2(input)
+    sort!(packets, lt = (x,y)->comparesides(x, y) == "right")
+    findfirst(==([[2]]), packets) * findfirst(==([[6]]), packets)
end
+@assert part_2(example) == 140
@info part_2(input)
```