advent-of-code

Perserverance, or the lack thereof

git clone git://git.shimmy1996.com/advent-of-code.git
commit 4db9605cc6ae0f13baded3dfef2a59f8c8986b6d
parent 3a7b708f004161627add3ac0b11464a3730cd597
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Thu, 12 Dec 2019 23:56:59 -0500

Add input parsing

Diffstat:
Mday-12/day-12.jl | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/day-12/day-12.jl b/day-12/day-12.jl
@@ -50,12 +50,10 @@ function part_2(input)
     lcm(period_x, period_y, period_z)
 end
 
-input = [
-    14 15 -2;
-    17 -3 4;
-    6 12 -13;
-    -2 10 -8;
-]
+input = reshape(collect(Iterators.flatten(map(readlines(open("input.txt"))) do line
+    map(x -> parse(Int, x),
+        match(r"<x=(-?[0-9]+), y=(-?[0-9]+), z=(-?[0-9]+)", line).captures)
+end)), (3, :)) |> transpose
 
 println("Julia:")
 println("Part 1: ", part_1(input))