summaryrefslogtreecommitdiff
path: root/2025/ocaml
diff options
context:
space:
mode:
authorDJ O'Leary <dijitol@proton.me>2025-12-07 17:16:09 +0100
committerDJ O'Leary <dijitol@proton.me>2025-12-07 17:16:09 +0100
commit661ce5a9f27b25cae3672087bc8d1f8eac24ea06 (patch)
treee916ff447dadb07922ec477cda804ee6a0b51299 /2025/ocaml
parentcca606659bd0854cfe4f2668d3117ca42fe059b2 (diff)
fix(2025d4p1): flip x and y of matrix when pretty printing
fixes: pp_matrix
Diffstat (limited to '2025/ocaml')
-rw-r--r--2025/ocaml/lib/application/d04p01.ml8
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)