diff options
Diffstat (limited to '2025')
| -rw-r--r-- | 2025/ocaml/lib/application/d03p01.ml | 52 | ||||
| -rw-r--r-- | 2025/ocaml/lib/application/d03p01.mli | 2 |
2 files changed, 0 insertions, 54 deletions
diff --git a/2025/ocaml/lib/application/d03p01.ml b/2025/ocaml/lib/application/d03p01.ml index 14f49e8..522f5d0 100644 --- a/2025/ocaml/lib/application/d03p01.ml +++ b/2025/ocaml/lib/application/d03p01.ml @@ -1,31 +1,3 @@ -(** Day 3 Part 1 - Implementation Plan: - - For each line: - 1. Start with the tuple [(None, None)] - 2. Put the first two digits in the sequence into the tuple => [(Some m, Some n)] - 3. Walk the sequence - - IF the digit in the sequence is greater than the first element of the tuple - AND we are not looking at the last digit in the sequence, - replace the first element of the tuple with that digit and set the other digit to None. - - IF the digit in the sequence did not replace the first element of the tuple - AND the digit is greater than the second element of the tuple, - replace the second element of the tuple with that digit. - 4. Concat the elements of the tuple "string-wise" => [(Some m', Some n')] => [m' ^ n'] - 5. Cast to int - - Sum the result of each line - - Tried: 17024 (hint: too low) - original - Tried: 17061 (hint: too low) - fixed second digit promotion, e.g. "343411" would give 41 instead of 44 - Tried: 17081 (no hint given) - fixed second last digit promotion, e.g. "789" would give 79 insted of 89 - Tried: 17091 (no hint given) - no change but found diff of 10 in failing test case - Tried: 17090 (no hint given) - no change but realised failing test case actually had a diff of 9 not 10 (have 56, want 65) - Tried: 17099 (no hint given) - no change but found additional failing test case (have 67, want 76) - - Upper bound: 200 * 99 = 19800 - *) - open Domain.D03p01 let err_empty_input = "input is empty" @@ -49,27 +21,3 @@ let solve input () = |> Seq.fold_left ( + ) 0 in Ok answer - -let print_occurring_digits input () = - input |> to_lines |> List.to_seq - |> Seq.map BatteryBank.of_string - |> Seq.map BatteryBank.to_list - |> Seq.map (List.sort_uniq Battery.compare) - |> Seq.map BatteryBank.of_list - |> Seq.iteri (fun idx bb -> - Logs.debug (fun m -> m "%d %s" (idx + 1) (BatteryBank.pp bb)) ) ; - -1 -(* disables unused function warning *) -[@@warning "-32"] - -let _solve' input () = - if input = "" then Error err_empty_input - else - let banks = - input |> to_lines |> List.to_seq - |> Seq.map BatteryBank.of_string - |> Seq.map BatteryBank.to_list - |> Seq.map (fun bb -> List.map Battery.to_int bb) - |> List.of_seq - in - Ok banks diff --git a/2025/ocaml/lib/application/d03p01.mli b/2025/ocaml/lib/application/d03p01.mli index b492753..31dd0cd 100644 --- a/2025/ocaml/lib/application/d03p01.mli +++ b/2025/ocaml/lib/application/d03p01.mli @@ -2,5 +2,3 @@ val solve : string -> unit -> (int, string) result (** [solve input ()] is the solution for the first part of the third day of advent of code 2025 for [input]. The solution for an empty input is [Error msg]. Requires: [input] to be a string. *) - -val print_occurring_digits : string -> unit -> int |
