Skip to content

Commit

Permalink
Use regex
Browse files Browse the repository at this point in the history
  • Loading branch information
drewolson committed Dec 8, 2023
1 parent a64b319 commit a4cf01c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/year2023/day08.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ let solve { dirs; map } =
;;

let solve' { dirs; map } =
let is_start s = s |> String.to_list_rev |> List.hd_exn |> Char.equal 'A' in
let is_end s = s |> String.to_list_rev |> List.hd_exn |> Char.equal 'Z' in
let is_start s = Pcre.pmatch ~rex:(Pcre.regexp {|A\z|}) s in
let is_end s = Pcre.pmatch ~rex:(Pcre.regexp {|Z\z|}) s in
let starts = map |> Map.keys |> List.filter ~f:is_start in
let make_move (count, steps, nodes) dir =
let ends, rest = List.partition_tf nodes ~f:is_end in
Expand Down

0 comments on commit a4cf01c

Please sign in to comment.