summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBrian Chu <brianmchu42@gmail.com>2022-01-07 17:28:46 -0800
committerBrian Chu <brianmchu42@gmail.com>2022-01-07 17:28:46 -0800
commit465484d81e536596b544d8f1c8f1c61dd3fe49b5 (patch)
treee6cd3d55971976a954ec84ffbae2e395f477107d
parent4899f8e9dba07b4c6969a96d8fcb1458ebe87a69 (diff)
downloadAdventOfCode2016-465484d81e536596b544d8f1c8f1c61dd3fe49b5.tar.gz
solution for day 15
-rw-r--r--day15.fsx13
1 files changed, 13 insertions, 0 deletions
diff --git a/day15.fsx b/day15.fsx
new file mode 100644
index 0000000..0a7a8a0
--- /dev/null
+++ b/day15.fsx
@@ -0,0 +1,13 @@
+let findTime data =
+    let rec check_result data x =
+        if data
+         |> List.mapi (fun i a -> (i+1),a)  
+         |> List.forall (fun a -> ((fst (snd a)) + x + (fst a)) % (snd (snd a)) = 0) then x
+        else check_result data (x+1) 
+    check_result data 0
+
+let data1 = [ (10, 13); (15, 17); (17, 19); (1, 7); (0, 5); (1, 3)]
+findTime data1 |> printfn "%d"
+
+let data2 = [ (10, 13); (15, 17); (17, 19); (1, 7); (0, 5); (1, 3); (0, 11)]
+findTime data2 |> printfn "%d"
\ No newline at end of file