diff options
Diffstat (limited to '2025')
| -rw-r--r-- | 2025/ocaml/lib/application/d04p01.ml | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/2025/ocaml/lib/application/d04p01.ml b/2025/ocaml/lib/application/d04p01.ml index 1671d53..2cc5f5d 100644 --- a/2025/ocaml/lib/application/d04p01.ml +++ b/2025/ocaml/lib/application/d04p01.ml @@ -26,7 +26,13 @@ let input_to_matrix input = (** [pp_matrix matrix] is the [input] that was used to create the [matrix] via [input_to_matrix input]. *) let pp_matrix matrix = - matrix + let row_count = Array.length matrix in + let column_count = Array.length matrix.(0) in + let matrix' = Array.make_matrix row_count column_count "" in + Array.iteri + (fun x row -> Array.iteri (fun y c -> matrix'.(y).(x) <- c) row) + matrix ; + matrix' |> Array.map @@ Array.fold_left (fun acc c -> acc ^ c) "" |> Array.fold_left (fun acc line -> if acc = "" then line else acc ^ "\n" ^ line) |
