summary refs log tree commit diff stats
path: root/solutions/day1.fs
diff options
context:
space:
mode:
authorBrian Chu <brianmchu42@gmail.com>2022-12-23 15:24:35 -0800
committerBrian Chu <brianmchu42@gmail.com>2022-12-23 15:24:35 -0800
commit4c9eaafa1b7b7c4c9bd0899cd38b0cc885804954 (patch)
tree0317ff7a8009fa827e690f0493acace3b0a3ea63 /solutions/day1.fs
parent7e4bb2316cf6dedb05c40a86b06fc31d93931660 (diff)
downloadAdventOfCode2022-4c9eaafa1b7b7c4c9bd0899cd38b0cc885804954.tar.gz
refactor modules to clean up indenting
Diffstat (limited to 'solutions/day1.fs')
-rw-r--r--solutions/day1.fs30
1 files changed, 14 insertions, 16 deletions
diff --git a/solutions/day1.fs b/solutions/day1.fs
index 0b2c519..5561601 100644
--- a/solutions/day1.fs
+++ b/solutions/day1.fs
@@ -1,19 +1,17 @@
-namespace Solutions
+module Solutions.Day1
+open System.IO
 
-module Day1 =
-    open System.IO
+let lines = File.ReadLines("inputs/day1.txt")
+let totalWeights = seq {
+    let mutable subseq = 0
 
-    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
+}
 
-        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
+let part1 () = totalWeights |> Seq.max
+let part2 () = totalWeights |> Seq.sortDescending |> Seq.take 3 |> Seq.sum