diff options
| author | DJ O'Leary <dijitol@proton.me> | 2025-12-07 02:26:13 +0100 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2025-12-07 02:26:13 +0100 |
| commit | 26799e3010ce58a268ae9d989f6e3a71b303c509 (patch) | |
| tree | 922df2f05272d87ddd858b0bf675cbd769ab99f5 /2025/ocaml | |
| parent | 9ed30f54f5d73fcdc9a56613baed28c53659aba5 (diff) | |
feat(2025d3p1): started on alternative solution
Alternative solution is to scan each line once to find the index of the largest left-most and non-final digit.
Then getting a substring of the line [idx, len) and finding the largest digit in that substring.
These digits concatenated together should be the biggest 2 digit number that can be made from the line
Diffstat (limited to '2025/ocaml')
| -rw-r--r-- | 2025/ocaml/lib/application/d03p01.ml | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/2025/ocaml/lib/application/d03p01.ml b/2025/ocaml/lib/application/d03p01.ml index 8e9c32c..691fe65 100644 --- a/2025/ocaml/lib/application/d03p01.ml +++ b/2025/ocaml/lib/application/d03p01.ml @@ -17,8 +17,8 @@ Sum the result of each line Tried: 17024 (hint: too low) - original - Tried: 17061 (hint: too low) - fixed second digit promotion - "343411" would give 41 instead of 44 - Tried: 17081 (no hint given) - fixed second last digit promotion - "789" would give 79 insted of 89 + 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) @@ -52,3 +52,14 @@ let print_occurring_digits input () = |> Seq.iteri (fun idx bb -> Logs.debug (fun m -> m "%d %s" (idx + 1) (BatteryBank.pp bb)) ) ; -1 + +[@@warning "-32"] (* disables unused function warning *) +let _solve' input () = + 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 + banks |
