Tidy up code for 2024 day 12.

This still has some mutable state.
This commit is contained in:
2024-12-12 10:23:08 +00:00
parent 7e0e6d3770
commit 932b2c926c
3 changed files with 48 additions and 33 deletions

View File

@@ -114,6 +114,10 @@ module Grid : sig
(** [Grid.get_by_pos grid pos] returns the character at position [pos] in
[grid]. *)
val get_by_pos_opt : t -> int * int -> char option
(** [Grid.get_by_pos_opt grid pos] returns [Some (get_by_pos grid pos)] if
[pos] is a valid position in [grid], and [None] otherwise. *)
val pos_of_idx : t -> int -> int * int
(** [Grid.pos_of_idx grid idx] returns the [(x, y)] position mapped by [idx]
in [grid]. *)