summary refs log tree commit diff stats
path: root/solutions
diff options
context:
space:
mode:
authorBrian Chu <brianmchu42@gmail.com>2022-11-30 23:02:09 -0800
committerBrian Chu <brianmchu42@gmail.com>2022-11-30 23:02:09 -0800
commit217582a34d4c47c5b0bc6e137e6019f2485b741f (patch)
treee90559dd3f087b8b80b0067c45b576c15f3a30fb /solutions
downloadAdventOfCode2022-217582a34d4c47c5b0bc6e137e6019f2485b741f.tar.gz
template scaffolding and day1 solution
Diffstat (limited to 'solutions')
-rw-r--r--solutions/day1.fs19
1 files changed, 19 insertions, 0 deletions
diff --git a/solutions/day1.fs b/solutions/day1.fs
new file mode 100644
index 0000000..0b2c519
--- /dev/null
+++ b/solutions/day1.fs
@@ -0,0 +1,19 @@
+namespace Solutions
+
+module Day1 =
+    open System.IO
+
+    let lines = File.ReadLines("inputs/day1.txt")
+    let totalWeights = seq {
+        let mutable subseq = 0
+
+        for line in lines do
+        if line.Equals("") then
+            yield subseq
+            subseq <- 0
+        else
+            subseq <- subseq + int line
+    }
+
+    let part1 () = totalWeights |> Seq.max
+    let part2 () = totalWeights |> Seq.sortDescending |> Seq.take 3 |> Seq.sum