Skip to content

Commit

Permalink
Last clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
drewolson committed Dec 11, 2023
1 parent 4201724 commit 65ef1db
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/year2023/day11.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ module CoordMap = Map.Make (Coord)
let parse input = input |> String.split_lines |> List.map ~f:String.to_list

let expand amount galaxy =
let open Z in
let x_counts =
galaxy
|> List.transpose_exn
|> List.mapi ~f:(fun i line ->
i, if List.for_all line ~f:(Char.equal '.') then ~$amount else ~$1)
in
let y_counts =
galaxy
let build_counts l =
let open Z in
l
|> List.mapi ~f:(fun i line ->
i, if List.for_all line ~f:(Char.equal '.') then ~$amount else ~$1)
|> IntMap.of_alist_exn
in
IntMap.of_alist_exn x_counts, IntMap.of_alist_exn y_counts
build_counts (List.transpose_exn galaxy), build_counts galaxy
;;

let to_grid galaxy =
Expand Down

0 comments on commit 65ef1db

Please sign in to comment.