diff --git a/y2024/resources/15_input.txt b/y2024/resources/15_input.txt new file mode 100644 index 0000000..c153d58 --- /dev/null +++ b/y2024/resources/15_input.txt @@ -0,0 +1,71 @@ +################################################## +#OOO#..O.O#O#...#.O.OO...............OO.....O....# +#O#O...#...#...O............OO.#...OO..O..OO...O.# +#..O....O#.O..O.O..O#O##.OO..O..........#O....OO.# +#...O#.OOO.O.O.O......O.OO.O..#.O.OO#O.#OO.O.O#..# +#OO..O....O....#....OO#OO..O..OO..O.....#O.O..O.O# +#O.....#.O.O...#..OO.......OO....O.#O.O..#..O..O.# +#..OO.O.#O.O.O..##O..O#OO....#.O..O...O.OO..#OOO## +#....OO...OO..O..O.#.OOO..O..#O....OO#O..O..#.O..# +#....OO.#...O#..O...#.....O......#.....#.....#.O.# +#..O.....O.O.O..O....OO#.O.#.O......#..#O.O..OO..# +#.#..OO....O........O.#....OO...#.O.OO...O.......# +#OO...OO.OO...#.OOO........O#...O.#.OO....OO...OO# +#.O..O..OO.OOOO....#..O.#OO.O..O#.......O.#....### +#O...O.......OO....#......OO.O.#O.O..O.O.O.#..O.O# +#OO#OO....#O...O#....#...OOO.O.O..O..#...O.O#O..O# +#....OOO#OO.......#.OO....#...O..#.O...#.O.......# +#OOOO....O...O.OOOO.....OO.......O#..O.OO.....O.O# +#..#..O.#.O..OO.OOOO...OO#...OOO...O.##.O#.O..OOO# +#O......O..O#...#....O...O.OO....O.O....OO..#....# +#.....OOO..O.O......O...#...O...........#.OO..#O.# +#...#.....O.O..#O#....O.#O#..O#....O..O....#OOO### +####O.....O...O.#.......O.O.O...O.....O.O...O...O# +#O...O...O.OO.O.....O.O......O.##.#O#.O.....O..OO# +#...#..#...#...OO..#OO.O@.O......O............OO.# +#O........OOO.O.O.O..#..#O...O.O..#.OO...#.OO..#.# +#.O.#..O...O...OO...#..OOO......OO.#O#......O.OO.# +#.O...OO#O...O..O......O..#O....O.....O..O..O.O..# +#.O..O...O..#..OO.....O..O.........O#...#O#..OO.## +#.....O..#..##........O.#..#...O..##..OO.....O...# +#.O..O#...#.....O.O#....OOO.#..#.OO..O..OO.OOO...# +#.#OO..O...O.....O.O#.....##..O.O#.O.O....O....#.# +#....#..#.....#O.#..O..#......O..O.....OO#..O#.OO# +#....O.O...#OO...#O.O..O..........OO..#O....O..O## +#O...#..#.....O.......O.O.O....O.O.O..O.O.#...#### +#.OO........#.#..........#..O....OO#..#O.O.....O.# +#.#..O.O....OO....#O.......#.O..O.#O.O..OO#......# +#O...O.....O.OO#...#O.O.O.....O..OOO..O##.O...O..# +#O...OO.#O#.O..O..O...O.O......O..##............## +#O.O.#...........OO.....OO...O.O......#O.OO....OO# +#...OO...OO#.O..O.O...O..OO......O.......O.O.OO..# +#.#....O..O..O...O.......#...O.#O..O..O.O.O......# +#O....O......O#.O......##.....#.....O.O.O#O......# +#.OO.OO..O......OOOO..O#.O...O.O......#.....OO..O# +#.O......O.O.OO.O..#..O....O.....#....O.#.OO#...O# +#.O..#....#...O......#.O.....OO.O.....O.....O....# +#.#..OO.....#.....#O.O.#O......O......OO....OOO.O# +#..OO.O....O...O.O......O.O.OO...#.....O.......O.# +#..O..O...#.O.O#........OO....O...O.OO...#.......# +################################################## + +^>v<>^<>v^v<><>^^v>^^<<^v<>v^<^<^v^v^>>v<><>^<^^^^v>vv>v^><>^>v>>^><>^^vv^<<<>v>v>>vvvv^<^>^^><>v>^v^^<>>^<^<<>>>v^<<>>^^^<^>>>v>^>>v^^v^^^>>^v>vvv<<>vv<^>>>^^^v<<<^^v><><>>>^v>^vv>^><^>>vv^^<^>v^^vv^v^^v<>>>>v><<^vv^vv><^^^vv>><<v><>>v^^<^^>><>^vvv<<><<^v<<^>^v^^v><^<^vvv>v<^^vv^<><>>>>v<^^v^^v>vv^v>><<<><<>^v>>><^<^^^^v><^>vv>>v<^<vv<<>>^>v<>^^<^<><^<>vvv><>><>>v^>^<<^^>v^>>>vv<^v><>v<<^>>><<><<<<>^>^^v^<>^>v>v><<<>><<>>vv>v><<^><<>vvvv<v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^v^^v>^^<^^<>>^<>>><><<<^<<^<^<<<^vvv^v<<>>^>>^v<^v^v^vvv^<^v<<<^<>>^^>^>>^^>^>v^^<><^vvv^<<^<><<<^^<<>><vv><>><<^<<^>>^^vv^>>>>vv<^<<<>v<<<>>>>vv>^^^>^<>>^^v><><^><^>>> +v><>>v^^vv<>>^^vv^>v^<>vvv>vv<>^v>>v<^<>>^v><^<>v>v^<<>^v>^^><^^>>vv^v^<><^<>v<^><^v>vv<^vv^<v<>v^v^>>^>^<^>>^v<^vvv>><>vv>^v<^v<^><^^^>v^^>>><<<>><>^vv^<>^<>^^v^^<<>^<^>v^^>vv<<><<^<<<v<^v^<>v<>vvv<^^vv><<>><>v><>>^>>v<^vv^v<<^v^^>v>v>vv^^v>><<<^vvvv>^^^^<<<><^<^>^v^<^v<^v^^><^<<^^>v^vv<><^>^vv^v<<<>^vvv<<>>^vv^vvv^^>><>v^^<^v^^^>^>v^<><><>>>^v>v^<>>>vv<><^>v>^v<<<^>v^<>><^v<>^><^^v><^^><>^^>vv^vv<<^^v<^^><>v^>v^<^^<^v>^^^>v^vv>^>v^<^^><^<<<>v>^><^>>vvv^^>>>>^>^<^><>^^v<<>v^>^^^<>><>vv^^^v>>v^^v<^v<<^^<<>v>v>>v<><>^>^^^>vvv<><<>><^<^v<<<^<>^^>>v^><<>>^^^^^^vvv<><^^>^v>>>^^>>>^<<<>^vv<^><<<<>^v^>>>v<>>v>><<^<^^<><><>^^vv^^v^v<>>^v<<^v^^>^vv^v>vv<>v^^<<<>>vvv^><>v^^<^><><>>v>^><^<^^>v>vv<^v^^>^>^v^^>vv>>>>vvv^^v^>v>>^^<<<v>v<<>^^v diff --git a/y2024/src/bin/d15.rs b/y2024/src/bin/d15.rs new file mode 100644 index 0000000..fe7397d --- /dev/null +++ b/y2024/src/bin/d15.rs @@ -0,0 +1,27 @@ +use std::{fs, time::Instant}; + +use utils::time::get_elapsed_string; +use y2024::days::d15; + +fn main() { + let now = Instant::now(); + println!("Part 1:"); + part1(); + println!("Ran in {}", get_elapsed_string(now.elapsed())); + let now = Instant::now(); + println!("Part 2:"); + part2(); + println!("Ran in {}", get_elapsed_string(now.elapsed())); +} + +fn part1() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/15_input.txt")).unwrap(); + println!("{}", d15::process_part1(&content)); +} + +fn part2() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/15_input.txt")).unwrap(); + println!("{}", d15::process_part2(&content)); +} diff --git a/y2024/src/days/d15.rs b/y2024/src/days/d15.rs new file mode 100644 index 0000000..6e60854 --- /dev/null +++ b/y2024/src/days/d15.rs @@ -0,0 +1,176 @@ +use std::error::Error; + +use itertools::Itertools; + +pub fn process_part1(input: &str) -> u32 { + let (grid, movements) = input.split_once("\n").unwrap(); + let grid = parse_grid(grid); + let movements = parse_movements(movements); + for movement in movements {} +} + +pub fn process_part2(input: &str) -> u32 { + 0 +} + +fn parse_grid(input: &str) -> Vec> { + let mut grid_entities = Vec::new(); + let mut robot = GridTile { + entity: GridTileType::Robot, + ..Default::default() + }; + input.lines().enumerate().for_each(|(yidx, line)| { + let mut row_entities = Vec::new(); + line.chars().enumerate().for_each(|(xidx, chara)| { + if let Ok(entity) = GridTileType::from_character(chara) { + match entity {} + } + }); + grid_entities.push(row_entities); + }); + grid_entities +} + +fn parse_movements(input: &str) -> Vec { + input + .lines() + .map(|line| { + line.chars() + .map(|chara| Movement::try_from(chara).unwrap()) + .collect_vec() + }) + .concat() +} + +fn move_up(robot: &mut GridTile, grid: &mut Vec>) {} + +fn move_down(robot: &mut GridTile, grid: &mut Vec>) {} + +fn move_left(robot: &mut GridTile, grid: &mut Vec>) {} + +fn move_right(robot: &mut GridTile, grid: &mut Vec>) {} + +#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)] +enum GridTileType { + Robot, + Crate, + Wall, + #[default] + Nothing, +} + +impl GridTileType { + fn from_character(value: char) -> Result> { + match value { + '#' => Ok(Self::Wall), + 'O' => Ok(Self::Crate), + '@' => Ok(Self::Robot), + '.' => Ok(Self::Nothing), + _ => Err(Box::from(format!("{value} is not a valid entity"))), + } + } +} + +#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)] +struct GridTile { + entity: GridTileType, + coords: (u32, u32), +} + +impl GridTile { + fn get_gps(&self) -> u32 { + if self.entity == GridTileType::Crate { + self.coords.0 + self.coords.1 * 100 + } else { + 0 + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +enum Movement { + Up, + Down, + Left, + Right, +} + +impl TryFrom for Movement { + type Error = Box; + + fn try_from(value: char) -> std::result::Result> { + match value { + '^' => Ok(Self::Up), + 'v' => Ok(Self::Down), + '<' => Ok(Self::Left), + '>' => Ok(Self::Right), + _ => Err(Box::from(format!("{value} is not a valid direction"))), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + const INPUT_SMALL: &str = "####### +#...O.. +#......"; + + const INPUT_MEDIUM: &str = "######## +#..O.O.# +##@.O..# +#...O..# +#.#.O..# +#...O..# +#......# +######## + +<^^>>>vv>v<<"; + + const INPUT_LARGE: &str = "########## +#..O..O.O# +#......O.# +#.OO..O.O# +#..O@..O.# +#O#..O...# +#O..O..O.# +#.OO.O.OO# +#....O...# +########## + +^v>^vv^v>v<>v^v<<><>>v^v^>^<<<><^ +vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<>><^^v>^>vv<>v<<<^<^^>>>^<>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v^<^^>v^^>v^<^v>v<>>v^v^v^^<^^vv< +<>^^^^>>>v^<>vvv^>^^^vv^^>v<^^^^v<>^>vvvv><>>v^<<^^^^^ +^><^><>>><>^^<<^^v>>><^^>v>>>^v><>^v><<<>vvvv>^<><<>^>< +^>><>^v<><^vvv<^^<><^v<<<><<<^^<^>>^<<<^>>^v^>>^v>vv>^<<^v<>><<><<>v<^vv<<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^ +<><^^>^^^<>^vv<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<> +^^>vv<^v^v^<>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<>< +v^^>>><<^^<>>^v^v^<<>^<^v^v><^<<<><<^vv>>v>v^<<^"; + + #[test] + fn part1_small() { + let result = process_part1(INPUT_SMALL); + assert_eq!(result, 104); + } + + #[test] + fn part1_medium() { + let result = process_part1(INPUT_MEDIUM); + assert_eq!(result, 2028); + } + + #[test] + fn part1_large() { + let result = process_part1(INPUT_LARGE); + assert_eq!(result, 10092); + } + + #[test] + fn part2() { + let result = process_part2(INPUT_SMALL); + assert_eq!(result, 0); + } +} diff --git a/y2024/src/days/mod.rs b/y2024/src/days/mod.rs index 441df06..7e99654 100644 --- a/y2024/src/days/mod.rs +++ b/y2024/src/days/mod.rs @@ -17,3 +17,5 @@ pub mod d12; pub mod d13; pub mod d14; + +pub mod d15;