From 465484d81e536596b544d8f1c8f1c61dd3fe49b5 Mon Sep 17 00:00:00 2001 From: Brian Chu Date: Fri, 7 Jan 2022 17:28:46 -0800 Subject: solution for day 15 --- day15.fsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 day15.fsx 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 -- cgit 1.4.1-2-gfad0