summary refs log tree commit diff stats
path: root/solutions
diff options
context:
space:
mode:
authorBrian Chu <brianmchu42@gmail.com>2022-12-05 21:23:25 -0800
committerBrian Chu <brianmchu42@gmail.com>2022-12-05 21:23:25 -0800
commit0f4c87139ea2099d000d59ab0acf9307011a9af0 (patch)
treed99c621a9159beceba3c035ebd9d0567e9dfc542 /solutions
parentaf2b874eb5cf4d173a1b90d90e730352b7d599cd (diff)
downloadAdventOfCode2022-0f4c87139ea2099d000d59ab0acf9307011a9af0.tar.gz
solution for day 6
Diffstat (limited to 'solutions')
-rw-r--r--solutions/day6.fs20
1 files changed, 20 insertions, 0 deletions
diff --git a/solutions/day6.fs b/solutions/day6.fs
new file mode 100644
index 0000000..bb83388
--- /dev/null
+++ b/solutions/day6.fs
@@ -0,0 +1,20 @@
+namespace Solutions
+
+module Day6 =
+    open System.IO
+
+    let buf = File.ReadAllText("inputs/day6.txt")
+
+    let rec scan size str index =
+        if String.length str < size then -1
+        else
+            let current = str[..size - 1] |> Set.ofSeq
+            if Set.count current = size then index + size
+            else
+                scan size str[1..] index + 1
+
+    let part1 () =
+        scan 4 buf 0
+
+    let part2 () =
+        scan 14 buf 0
\ No newline at end of file