From bbc6863be3fc4f3c20566b95e183ebaf1d23e58b Mon Sep 17 00:00:00 2001 From: Connor Slade Date: Wed, 18 Dec 2024 00:42:02 -0500 Subject: [PATCH] [LIB] Fix swapped Grid method names --- aoc_2021/src/day_15.rs | 4 ++-- aoc_2023/src/day_14.rs | 2 +- aoc_2023/src/day_16.rs | 2 +- aoc_2023/src/day_17.rs | 2 +- aoc_2023/src/day_21.rs | 2 +- aoc_2023/src/day_23.rs | 2 +- aoc_2024/src/day_04.rs | 4 ++-- aoc_2024/src/day_06.rs | 2 +- aoc_2024/src/day_08.rs | 2 +- aoc_2024/src/day_10.rs | 2 +- aoc_2024/src/day_12.rs | 2 +- aoc_2024/src/day_15.rs | 2 +- aoc_2024/src/day_16.rs | 4 ++-- aoc_2024/src/day_18.rs | 2 +- aoc_lib/src/matrix.rs | 4 ++-- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/aoc_2021/src/day_15.rs b/aoc_2021/src/day_15.rs index 65857bb..0e8e623 100644 --- a/aoc_2021/src/day_15.rs +++ b/aoc_2021/src/day_15.rs @@ -11,12 +11,12 @@ solution!("Chiton", 15); type Point = Vector; fn part_a(input: &str) -> Answer { - let matrix = Grid::new(input, |chr| chr.to_digit(10).unwrap() as u8); + let matrix = Grid::parse(input, |chr| chr.to_digit(10).unwrap() as u8); solve(matrix.size, |pos| matrix.get(pos).copied()).into() } fn part_b(input: &str) -> Answer { - let matrix = Grid::new(input, |chr| chr.to_digit(10).unwrap() as u8); + let matrix = Grid::parse(input, |chr| chr.to_digit(10).unwrap() as u8); solve(matrix.size * 5, |pos| { let (cx, cy) = (pos.x() / matrix.size.x(), pos.y() / matrix.size.y()); if cx > 4 || cy > 4 { diff --git a/aoc_2023/src/day_14.rs b/aoc_2023/src/day_14.rs index 4c93cc9..44f333f 100644 --- a/aoc_2023/src/day_14.rs +++ b/aoc_2023/src/day_14.rs @@ -40,7 +40,7 @@ struct Dish { fn parse(input: &str) -> Dish { Dish { - tiles: Grid::new(input, identity), + tiles: Grid::parse(input, identity), } } diff --git a/aoc_2023/src/day_16.rs b/aoc_2023/src/day_16.rs index 495254b..d8f1f37 100644 --- a/aoc_2023/src/day_16.rs +++ b/aoc_2023/src/day_16.rs @@ -31,7 +31,7 @@ fn part_b(input: &str) -> Answer { } fn parse(input: &str) -> Grid { - Grid::new(input, Tile::from_char) + Grid::parse(input, Tile::from_char) } #[derive(Debug, Clone, Copy, PartialEq)] diff --git a/aoc_2023/src/day_17.rs b/aoc_2023/src/day_17.rs index bae4827..17c61c1 100644 --- a/aoc_2023/src/day_17.rs +++ b/aoc_2023/src/day_17.rs @@ -20,7 +20,7 @@ fn part_b(input: &str) -> Answer { } fn parse(input: &str) -> Grid { - Grid::new(input, |c| c as u8 - b'0') + Grid::parse(input, |c| c as u8 - b'0') } fn pathfind(board: Grid, min_dist: u8, max_dist: u8) -> u32 { diff --git a/aoc_2023/src/day_21.rs b/aoc_2023/src/day_21.rs index 970b779..5fe0946 100644 --- a/aoc_2023/src/day_21.rs +++ b/aoc_2023/src/day_21.rs @@ -87,7 +87,7 @@ enum Tile { } fn parse(input: &str) -> Grid { - Grid::new(input, |x| match x { + Grid::parse(input, |x| match x { '#' => Tile::Wall, '.' => Tile::Garden, 'S' => Tile::Start, diff --git a/aoc_2023/src/day_23.rs b/aoc_2023/src/day_23.rs index 8b5095b..e219028 100644 --- a/aoc_2023/src/day_23.rs +++ b/aoc_2023/src/day_23.rs @@ -125,7 +125,7 @@ fn solve_b(map: &Grid) -> u32 { } fn parse(input: &str) -> Grid { - Grid::new(input, identity) + Grid::parse(input, identity) } fn dir_matches(dir: Direction, chr: char) -> bool { diff --git a/aoc_2024/src/day_04.rs b/aoc_2024/src/day_04.rs index 1688645..21d3d23 100644 --- a/aoc_2024/src/day_04.rs +++ b/aoc_2024/src/day_04.rs @@ -7,7 +7,7 @@ use nd_vec::vector; solution!("Ceres Search", 4); fn part_a(input: &str) -> Answer { - let matrix = Grid::new(input, identity); + let matrix = Grid::parse(input, identity); let mut count = 0; for y in 0..matrix.size.y() { @@ -44,7 +44,7 @@ const MAS_DIRECTIONS: [[Direction; 2]; 2] = [ ]; fn part_b(input: &str) -> Answer { - let matrix = Grid::new(input, identity); + let matrix = Grid::parse(input, identity); let mut count = 0; for y in 0..matrix.size.y() { diff --git a/aoc_2024/src/day_06.rs b/aoc_2024/src/day_06.rs index 5c3e9b7..632a14d 100644 --- a/aoc_2024/src/day_06.rs +++ b/aoc_2024/src/day_06.rs @@ -36,7 +36,7 @@ struct Map { impl Map { fn new(input: &str) -> Self { - let map = Grid::new(input, |x| match x { + let map = Grid::parse(input, |x| match x { '#' => Tile::Obstacle, '^' => Tile::Start, _ => Tile::None, diff --git a/aoc_2024/src/day_08.rs b/aoc_2024/src/day_08.rs index 60ae0f8..b0c1a66 100644 --- a/aoc_2024/src/day_08.rs +++ b/aoc_2024/src/day_08.rs @@ -63,7 +63,7 @@ enum Tile { impl AntennaMap { fn parse(input: &str) -> Self { - let world = Grid::new(input, |x| match x { + let world = Grid::parse(input, |x| match x { 'a'..='z' | 'A'..='Z' | '0'..='9' => Tile::Emitter(x), _ => Tile::Empty, }); diff --git a/aoc_2024/src/day_10.rs b/aoc_2024/src/day_10.rs index 42e28fd..9757b07 100644 --- a/aoc_2024/src/day_10.rs +++ b/aoc_2024/src/day_10.rs @@ -27,7 +27,7 @@ struct Map { impl Map { fn parse(input: &str) -> Self { - let board = Grid::new(input, |x| x.to_digit(10).unwrap()); + let board = Grid::parse(input, |x| x.to_digit(10).unwrap()); Self { board } } diff --git a/aoc_2024/src/day_12.rs b/aoc_2024/src/day_12.rs index 0d7ce6c..85bd80d 100644 --- a/aoc_2024/src/day_12.rs +++ b/aoc_2024/src/day_12.rs @@ -58,7 +58,7 @@ struct Garden { impl Garden { fn parse(input: &str) -> Self { - let matrix = Grid::new(input, identity); + let matrix = Grid::parse(input, identity); Self { matrix, seen: HashSet::new(), diff --git a/aoc_2024/src/day_15.rs b/aoc_2024/src/day_15.rs index 051198f..bbd1b0b 100644 --- a/aoc_2024/src/day_15.rs +++ b/aoc_2024/src/day_15.rs @@ -36,7 +36,7 @@ enum Tile { impl Problem { fn parse(input: &str, part_b: bool) -> Self { let (board, instructions) = input.split_once("\n\n").unwrap(); - let mut board = Grid::new(board, |chr| match chr { + let mut board = Grid::parse(board, |chr| match chr { '@' => Tile::Robot, '#' => Tile::Wall, 'O' => Tile::Box, diff --git a/aoc_2024/src/day_16.rs b/aoc_2024/src/day_16.rs index 660395f..8d9903c 100644 --- a/aoc_2024/src/day_16.rs +++ b/aoc_2024/src/day_16.rs @@ -45,7 +45,7 @@ struct Item { impl Maze { fn parse(input: &str) -> Self { - let map = Grid::new(input, |c| match c { + let map = Grid::parse(input, |c| match c { '.' => Tile::Empty, '#' => Tile::Wall, 'S' => Tile::Start, @@ -64,7 +64,7 @@ impl Maze { fn foreword(&self) -> (Grid<[u32; 4]>, u32) { let mut queue = BinaryHeap::new(); let mut seen = HashSet::new(); - let mut costs = Grid::parse(self.map.size, [u32::MAX; 4]); + let mut costs = Grid::new(self.map.size, [u32::MAX; 4]); queue.push(Item::new(self.start, Direction::Right, 0)); diff --git a/aoc_2024/src/day_18.rs b/aoc_2024/src/day_18.rs index 6656598..2c05dc2 100644 --- a/aoc_2024/src/day_18.rs +++ b/aoc_2024/src/day_18.rs @@ -55,7 +55,7 @@ impl Map { }) .collect::>(); - let board = Grid::parse(size, false); + let board = Grid::new(size, false); Self { falling, board } } diff --git a/aoc_lib/src/matrix.rs b/aoc_lib/src/matrix.rs index f4c1716..e0a3c46 100644 --- a/aoc_lib/src/matrix.rs +++ b/aoc_lib/src/matrix.rs @@ -13,7 +13,7 @@ pub struct Grid { } impl Grid { - pub fn parse(size: Vec2, default: T) -> Self + pub fn new(size: Vec2, default: T) -> Self where T: Clone, { @@ -23,7 +23,7 @@ impl Grid { } } - pub fn new(input: &str, parse: fn(char) -> T) -> Self { + pub fn parse(input: &str, parse: fn(char) -> T) -> Self { let mut data = Vec::with_capacity(input.len()); let mut size = vector!(0, 0);