From 6d80c94eb7ea8ac0421df0832409b63be7c1246a Mon Sep 17 00:00:00 2001 From: Alexandre Jesus Date: Wed, 3 Dec 2025 21:05:57 +0000 Subject: Setup ocamlformat Define a initial setup for ocamlformat. I might still tweak the settings in the future. --- lib/day01.ml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/day01.ml') diff --git a/lib/day01.ml b/lib/day01.ml index 9a983a6..097ad28 100644 --- a/lib/day01.ml +++ b/lib/day01.ml @@ -5,10 +5,10 @@ *) let parse_rotation s = - let num = lazy (int_of_string (String.sub s 1 ((String.length s) - 1))) in + let num = lazy (int_of_string (String.sub s 1 (String.length s - 1))) in match s.[0] with | 'R' -> Lazy.force num - | 'L' -> -(Lazy.force num) + | 'L' -> -Lazy.force num | s -> failwith (Printf.sprintf "Unknown rotation %c" s) let parse_rotations ch = @@ -25,8 +25,7 @@ let part1 ch = (fun (a, p) r -> let nxt = (p + r) mod m in let inc = if nxt = 0 then 1 else 0 in - (a + inc, nxt) - ) + (a + inc, nxt)) (0, s) |> fst |> Printf.printf "%d\n" @@ -38,10 +37,9 @@ let part2 ch = |> List.fold_left (fun (a, p) r -> let nxt = p + r in - let inc = (abs nxt) / m + if p > 0 && nxt <= 0 then 1 else 0 in + let inc = (abs nxt / m) + if p > 0 && nxt <= 0 then 1 else 0 in let nxt = ((nxt mod m) + m) mod m in - (a + inc, nxt) - ) + (a + inc, nxt)) (0, s) |> fst |> Printf.printf "%d\n" -- cgit v1.2.3