summary refs log blame commit diff stats
path: root/day15.fsx
blob: 0a7a8a07cdafa36f4f9c60ba2f82bed0864db8d4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
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"