diff --git a/src/day10.rs b/src/day10.rs index 5f73aef..2dc0675 100644 --- a/src/day10.rs +++ b/src/day10.rs @@ -1,10 +1,6 @@ -use itertools::Itertools; - use crate::spatial::{ - Point, adjacent_cardinal, adjacent_cardinal_points, all_coords, flood, paths_to_each_point, - print_grid, + Point, adjacent_cardinal_points, all_coords, flood, paths_to_each_point, }; -use std::collections::{BTreeSet, HashMap}; pub fn day10_part1(input: &str) -> String { let topomap = parse(input); @@ -32,10 +28,8 @@ pub fn day10_part2(input: &str) -> String { .filter(|pt| topomap[pt.row][pt.col] == 9) .map(|pt| grid[pt.row][pt.col].len()) .sum::() - }) - .collect_vec(); - dbg!(&ratings); - ratings.iter().sum::().to_string() + }); + ratings.sum::().to_string() } fn parse(input: &str) -> Vec> { diff --git a/src/spatial.rs b/src/spatial.rs index e73a67e..f222c05 100644 --- a/src/spatial.rs +++ b/src/spatial.rs @@ -8,12 +8,6 @@ pub struct Point { pub col: usize, } -impl ToString for Point { - fn to_string(&self) -> String { - format!("({}, {})", self.row, self.col) - } -} - pub fn all_coords(width: usize, height: usize) -> impl Iterator { (0..height) .cartesian_product(0..width) @@ -87,15 +81,8 @@ pub fn paths_to_each_point( let mut frontier = BTreeSet::from_iter([start]); while let Some(cursor) = frontier.pop_first() { - println!("cursor is at ({}, {})", cursor.row, cursor.col); for point in &digraph[cursor.row][cursor.col] { - println!("dealing with adjacent point ({}, {})", point.row, point.col); frontier.insert(*point); - println!( - "frontier now has {} points: {}", - frontier.len(), - frontier.iter().map(|pt| pt.to_string()).join(", ") - ); let paths_to_new_point = paths_to_each_point[cursor.row][cursor.col].clone(); for mut path in paths_to_new_point { path.push(*point); @@ -104,15 +91,5 @@ pub fn paths_to_each_point( } } - dbg!(paths_to_each_point.len()); paths_to_each_point } - -pub fn print_grid(paths: Vec>) -> Vec> { - let s = paths - .iter() - .map(|row| row.iter().map(|count| count.to_string()).join("")) - .join("\n"); - println!("{s}\n"); - paths -}