diff --git a/bin/day2403.ml b/bin/day2403.ml index 531de90..cf2bcbe 100644 --- a/bin/day2403.ml +++ b/bin/day2403.ml @@ -1,7 +1,11 @@ -type cmd = Do | Donot | Mul of int * int +(** Type containing commands available in input *) +type cmd = + | Do (** Enable processing *) + | Donot (** Disable processing *) + | Mul of int * int (** Multiply two integers. *) (** [find_nums s] returns the list of instructions given in [s]. *) -let instrs_of_string s = +let cmds_of_string s = let r = Str.regexp {|do()\|don't()\|mul(\([0-9][0-9]?[0-9]?\),\([0-9][0-9]?[0-9]?\))|} @@ -23,8 +27,8 @@ let instrs_of_string s = in List.rev (impl [] 0) -let instrs_of_file fname = - Aoc.strings_of_file fname |> List.map instrs_of_string |> List.concat +let cmds_of_file fname = + Aoc.strings_of_file fname |> List.map cmds_of_string |> List.concat (** [mac acc a b] returns [acc + a * b]. *) let mac acc = function Mul (a, b) -> acc + (a * b) | _ -> acc @@ -42,5 +46,4 @@ let day2403b lst = impl 0 true lst let _ = - Aoc.main instrs_of_file - [ (string_of_int, day2403a); (string_of_int, day2403b) ] + Aoc.main cmds_of_file [ (string_of_int, day2403a); (string_of_int, day2403b) ]