@@ -9,12 +9,14 @@ import gleam/result
99import gleam/set . { type Set }
1010import gleamy/priority_queue . { type Queue }
1111import grid . { type Dir , type Grid , type XY }
12+ import pocket_watch
1213
1314pub type Input {
1415 Input ( grid : Grid ( Nil ) , reindeer : XY , exit : XY )
1516}
1617
1718pub fn parse ( input : String ) -> Input {
19+ use <- pocket_watch . simple ( "parse" )
1820 let grid : Grid ( Nil ) =
1921 input
2022 |> grid . from_string
@@ -33,6 +35,7 @@ pub fn parse(input: String) -> Input {
3335}
3436
3537pub fn pt_1 ( input : Input ) {
38+ use <- pocket_watch . simple ( "part 1" )
3639 pt_1_aux (
3740 input ,
3841 todos : priority_queue . from_list (
@@ -128,6 +131,7 @@ fn find_cost(step: Step) -> Int {
128131}
129132
130133pub fn pt_2 ( input : Input ) {
134+ use <- pocket_watch . simple ( "part 2" )
131135 let steps =
132136 pt_2_aux (
133137 input ,
@@ -145,16 +149,16 @@ pub fn pt_2(input: Input) {
145149 seen : dict . new ( ) ,
146150 best : 109_496 ,
147151 )
148- io . println_error (
149- grid . to_string ( input . grid , fn ( xy , c ) {
150- case set . contains ( steps , xy ) , c {
151- True , Error ( Nil ) -> # ( "O" , Error ( Nil ) )
152- True , Ok ( Nil ) -> panic as "walked over a wall?"
153- False , Error ( Nil ) -> # ( "." , Error ( Nil ) )
154- False , Ok ( Nil ) -> # ( "#" , Error ( Nil ) )
155- }
156- } ) ,
157- )
152+ // io.println_error(
153+ // grid.to_string(input.grid, fn(xy, c) {
154+ // case set.contains(steps, xy), c {
155+ // True, Error(Nil) -> #("O", Error(Nil))
156+ // True, Ok(Nil) -> panic as "walked over a wall?"
157+ // False, Error(Nil) -> #(".", Error(Nil))
158+ // False, Ok(Nil) -> #("#", Error(Nil))
159+ // }
160+ // }),
161+ // )
158162
159163 set . size ( steps )
160164}
@@ -222,16 +226,15 @@ fn pt_2_aux(
222226 }
223227 } ,
224228 )
225- io . debug ( # (
226- "found" ,
227- todo_ . cost ,
228- set . size ( pt_2_final ( input . exit , new_seen ) ) ,
229- ) )
229+ // io.debug(#(
230+ // "found",
231+ // todo_.cost,
232+ // set.size(pt_2_final(input.exit, new_seen)),
233+ // ))
230234 let new_best = int . min ( best , todo_ . cost )
231235 pt_2_aux (
232236 input ,
233237 todos : rest_of_todos ,
234- // |> list.filter(fn(t) { t.cost <= new_best }),
235238 seen : new_seen ,
236239 best : new_best ,
237240 )
0 commit comments