summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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