Compare commits

...

3 Commits

Author SHA1 Message Date
Mathis 20737cb432 2023-10: Implement part one 2023-12-21 23:16:30 +01:00
Mathis 35728df923 2023-10: Add day 10 2023-12-21 19:56:09 +01:00
Mathis 100fd47491 Change Solution trait 2023-12-21 19:55:51 +01:00
15 changed files with 430 additions and 23 deletions

140
input/2023/day_10/input.txt Normal file
View File

@ -0,0 +1,140 @@
FF-7F-7.|FJ7L-7-.FL-F7|-7FFF77J.|7F--J-FF7-L..-7FF-LF7F|-F|7-L-FLJ7-FF-JFF-7-7.-J-.--7.-F---FJ-|..-J7.|J-77-F7---77FFLJ7.LFJF7.FL|-J--7-LJ-|
J.-L-JF-L7J|LL|7FL7LL||.LJ--J7JFL|J7|7.JLJ|L-L7L7-7J|L7|L||..|7L.L7.FL7-L--L-JLJ..FLJ|F7L|7-JJ-LLLJJLF..F77FLJ7FF7-L7|-L7-|7|.FFJJJ7L-LJ|..J
||..L7.LL-7J-.F77F7JF|--L.|7LJ-J.L-FF7J...|||JFJLJ7.L-L77L|.7.||7-J7J7LFJ.7F||-|.7LL77.JLJJ7|F|F|..F.|.FLLL-.---F-7.F7J.7-JLL7--77.|FFJ.7F7J
F-7J.L-7LFJJ7.LF-F77.|LFLFFJ|JJL7JLL|JLF--7J7-L.|FJ.LF-J--L-|.L7LL|7.-J|L|--F7JL7L.LLJFL-J7.77-7777F-F7F7F-J7F|.J|L7L|LFJLJ7L77|-|77-F-F-7L|
.-7||7J7.JJFF-.|FJ|.LL.J.|LFJ.L-LJFFL7FJF-J|F7|-77J.F7LF-F|77-F|7..F-JFL.J|||7.FFJ.FJFFJLJ7FLJJ||FF7FJL--7J.||-FL-JL-JFL.LJ|J.L.|.L777|.FL77
JJ.J-L-77.L||L7|LJF-7|F.FJ7|L-7LL7..LFJFJF7FJ|F--777F7JJJLF7--JJ.F.FL-|7-LFFJL7LJ..J-JL7F7L|7|-7-J|LJF-7FJ-F7J|LFJF7|.|FJ.FL7FF|-F.J7---7LFJ
LLL|.FLJF-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.JJ|-J
|7LLJL-JFJ|LJL-7|LLJF||F-7L-J-||LF-----JF7FJL7||L7F-J|F7L7FJL--7FL7FJ|L-7JF-J|L-7F7F7FJL--7L--7|F-JLLJF--------JF7LL-J|F7LJF7F7F7FJ.J.L-FL-7
LL77.L|JL7|7F--J|F7F7LJL7|F7F-JL7|F7F7F7|||F-JLJFJL-7||L7||F7F7|F-J|FJF7|FJF7|F-J||||L-7F-JF7FJ||F---7L---------JL-7F-J|L-7|LJLJ||L7|7|FL-LJ
FJ--F-JLLLJFJF7FJ|LJL---JLJLJF--JLJLJLJLJ|LJFF-7L7F-J||FJ|||LJ||L7FJL7||||FJ|||F7|||L--JL-7||||LJL--7L----7F7F-----JL7FJF7|L-7F-J|7L--FL-77|
-|J|F-7||F-JFJLJJL--7F7F7F7F7|F---------7L---JFJJ|L-7LJL7||L-7||FJL7FJ|||||FJ|||LJ|L--7F--J|||F7F7F7L--7F7LJ|L------7LJ|||L--JL-7L7.L-7JF|FF
L|.FL||-7L7FJF7F7F7.LJ||||||LJL7F------7L7F---JF-JF7L7F7||L7FJ|||F7|L7|LJ||L7||L77L7F7|L7F7|LJ|LJLJL---J||F7L-------JF-7|L--7LLLL-JJ.|JLFLJL
-7-L-JJJF-J|FJLJLJL7F7LJ||||F-7||F-----JF||F7|FJF7|L7LJ||L7||F||LJ|L7||F-J|FJ|L7L-7LJLJFJ|||F-JF----7F7FJLJL-7F---7F7L7||F--J7J-F|FLF.FFL-L.
FJFJ7L-.L7FJL-7F--7|||F-J|LJL7LJ|L---7F-7|LJL7L-J|L7|F7||FJ|L7|L7FJFJLJL-7||FJFJF7L--7.L-JLJL--JFF--J|LJF-7F7LJF-7LJL-JLJL7F7FF77LLJ|F7J77|.
|L7F-JL-J|L77L||F-JLJ|L7FJF--JF-JF7F-J|FJL---JF-7L-JLJLJ||-L7||FJL7L---7FJ|LJ-L7||F--JF-77F7F7F-7L--SJF7L7LJ|F7|F|F---7F-7LJL-J|7.|--J.F7777
L.FJF|7|7L7L7FLJL---7|FLJJL7F7L7FJLJJFJL7F--7FJFJF----7FJL-7||||F-JF---JL7|F--7|||L--7L7L-JLJ|L7|7F---JL-JF7LJLJFJL-77||||F----J-.F.FJ-7LL-7
|LJ|-|--7LL-JF7F----JL7F-7FJ||FJL----JF7||F-JL7L7L7F--J|F--J||||L-7L----7|||F7LJ||F--J7L----7L-JL-JF------JL7F-7L7F7L7|L7|L----777FFLJ7L-J|J
|J7JFJJJ|FF7.||L7F---7||FJL-JLJF------J|LJL-7.|FJFJL-7.LJJF7LJ|L7FJF-7F7|LJLJL-7||L--7F7F7F-JF7F7F7|F------7||FJ-LJL7|L-JL-----JF--7LL777.L|
.F--L7F-7L|L-JL7LJ7F-J|||F7F7F-JF7F7F7.L---7L7|L7|F7FJF7F7|L-7|FJL7L7||||FF----J||F--J||||L--JLJLJLJL----7FJLJL7F7|-LJ-F-----7F7L-7L77F7J-77
F7|.LL-L|||F--7L-7FJF7LJLJ|||L--J||LJL7F7F7L-J|FJ||LJFJLJ|L-7||L7FJFJLJ||FJF-7F7|||JF-J|||F-7F--7F-------J|F7F7LJL7F7FFJF7F-7|||F7|FJF||||LL
7L7FJFF-LFJ|F-JF7LJFJL7F-7||L7F77LJF-7LJLJL7F7|L-JL77|F-7|F7||L-JL7L--7||L-JLLJ|||L7|F7LJLJFJL7FJL----7F-7LJLJ|F-7LJ|FJFJLJ||||||LJL7FJL7J7J
|.L7|LJ|JL-JL--JL7FJ7FLJ||LJFJ||F--J.L7F7F7LJLJF7F7L7||||LJLJL---7|F-7|LJFF7.F-J|L-JLJL---7|F7|L7LF---JL7L---7|L7|F-JL7L-7F7LJ||L-7FJ|F-J-|7
JFFJLJ|LFJLLLF---J|F7F7F7L-7|7||L--7F7LJ||L7F7FJLJL7LJL7L-7F-7F7FJ||LLJ-LFJ|FJF7|F--7F-7F-JLJ|L7L7L--7F-JF---JL-JLJF7FJF-J||F7||F-J|FJL-7J||
|7LF|.|-F7J-FL----J|LJLJL--JL7||.F7LJL7FJL7LJ|L7JF7|F-7L-7||JLJ|L7LJ||7.LL7LJFJLJL-7|L7|L---7|7L7|LF7|L7FJF-------7||L7L-7||||||L-7LJF--J.FJ
F7L7JL.LLLF7F7F----JF7F7F7F-7LJL-JL---JL7FJF-JFJFJ||L7L7FJLJ7|7|FJJLFJ7L-LL7FJF----JL-JL----JL--J|FJLJFJL7|F------J||L|F-J|||||L7LL7FJFF7JJJ
.LJL.|L-7.|LJ|L--7F-JLJLJLJ7L---------7FLJFL--JLL7|L-JFJ|F7||F-||JF.|FJJLLLLJ-|F--7F7F7F7F--7F7F7LJF-7L-7LJ|7F---7L||FJ|F7|||||FJF-J|F7||..F
|....-7FJ7L-7L---JL7F----------------7L---7F7JF7FJL--7L7LJL7-|.LJJL-.L7JF77.|JLJF-J|LJLJLJF7||||L7FJFL--JF7L7L7F-JFJ|L7LJLJLJLJL-JF7LJLJL-7J
7.F77.L-L7|.|F7F7F7|L7F7F7F7F--7F---7L7F--J||FJLJF7F7L7L7F7L7-7LJJF|-7F-JL7...|JL-7|F-7F--JLJ|||FJL7F7F7FJL7L-J|F7L7|FJF------7F7FJ|F7F7F7|7
J7.|J..||L7-LJ||||||.LJLJLJ||F-J|F7FJ.LJFF-JLJF-7|LJL-JL||L7|.L.L-7.L7JF|-LJF|J7|LLJL7|L-7F-7|LJL-7||LJ|L-7|F--J|L7|||FJF7F7F7LJLJFLJ||LJLJ7
L7F7|FLF7.LFJL||LJLJF7F7JF7LJL--J|LJF7JF-JF-7FJF|L----7FJL7LJ--J|F7-F777|7|LF77LF7F--JL--J|FJL7F-7LJL-7L--J|L---JFJ|LJL-JLJLJL7F----7|L-7F|J
LL|LJ7-|7F-J..||F-7FJLJL7||F7F7F7L--JL-JF7L7|L-7L--7F-JL--JJ-|7|F|.LLLLLLF7.|L7-||L7F----7|L7FJL7L-7F-JF--7L7F7F7L-JF--7F7F7F7LJF7F7|L-7|J.|
-JJF|JF-JJ.F7-LJL7LJF7F7LJLJLJ||L---7F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F7||L---7|||||L7L-JL---7FJLJ|L7|L7FJF-7||FJJ||L--7|F7FJ|F-JFJL7L-7F-J|L-7|L7|||F--J|L----7F7F7F7F7L-JFJF-J|||||L-7FF7LJ7|.-.|J
|--7FL-7L7|L7||||L7LF-JLJLJL7L-7F7F7||L---JFJL7|L-JFJLJ|F7||LF-JLJ|L7|L-7L7FJF-JL-7|F-J|FJ|||L--7|FF7F7LJLJLJLJ|F-7|FJF7||||L--JFJL7F7JFJFJ.
7--LLJ.F-JL-JLJ|L7L7L---7F-7|F7LJLJL7L7F-7FJF-JL--7L7F-J|||L7|F7F-JL|L7FL7|L7L7F7FJ|L7FJL7LJL7F7|L7|LJL--------J|FJ||FJLJLJL-7F-JF-J||L||-J7
LFFJ.L-L-7F--7FJLL7|F7F-J|FJLJL-----JJLJFJL7L-----JFJL-7||L7|||LJF7FJFJF-J|-L7LJ||FJFJ|F7L-7FJ||L7|L7F-----7F7F7|L-JLJF-7F---JL7FJF-JL--7-7.
-7F7-.LJ-LJF-JL---JLJ|L--JL---7F-----7F7L-7|F7F--7FJF--J|L7|LJL7||||FJ7L-7|F7|F-J|L7L7||L7FJ|FJ|FJL7LJFF---J|LJLJF----JLLJLF-7FJL-JF-7F7|.FF
FLL---7|.LJL7F7F7F7F7L------7JLJF---7LJL-7LJ||L-7|L7||F7L7||F-7L7||||F7F7|LJLJL-7L7|FJ|L7||FJ|FJL7FJF7FJF7F7|F---JF7|F7FF7FJFJL7F--J7LJLJ--|
L7L7||J|..|FJ|LJ||||L--7F7F7L--7L--7L----JF7||F-JL-JL7||FJ|LJJ|FJ|LJ|||||L7F-7F7|FJLJFJFJLJL7||.FJL7||L-JLJLJL----JL-J|FJ|L7|F7|L----7J.FF7|
LJ.LJL-|7FFL7|F-J|LJ|F-J|||L7F7L--7L----7L||||L-----7|||L7|FF7|L7L-7||||L-JL7||LJL--7L7L7F--J|L7L-7LJL7F---7F7F--7F---J|FJFJ||||F----JJ|-|-7
.|-|7|JL77.FLJL--J|F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77-7JJLL-7----JLL--7-|J.LL-7JJJ.LL|JLL-|JLL7JJ

View File

@ -0,0 +1,5 @@
-L|F7
7S-7|
L|7||
-L-J|
L|-JF

View File

@ -0,0 +1,5 @@
..F7.
.FJ|.
SJ.L7
|F--J
LJ...

View File

@ -1,4 +1,5 @@
pub trait Solution {
fn part_one(&self) -> String;
fn part_two(&self) -> String;
fn input_path(&self) -> &'static str;
}

View File

@ -3,9 +3,14 @@ pub mod part_two;
use crate::utils::solution::Solution;
pub struct Day1Solution;
pub struct DaySolution;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"Not implemented"
}
impl Solution for Day1Solution {
fn part_one(&self) -> String {
// Implementation for part one of day 1
// ...

View File

@ -3,9 +3,14 @@ pub mod part_two;
use crate::utils::solution::Solution;
pub struct Day2Solution;
pub struct DaySolution;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"Not implemented"
}
impl Solution for Day2Solution {
fn part_one(&self) -> String {
// Implementation for part one of day 1
// ...

View File

@ -2,9 +2,14 @@ pub mod part_one;
use crate::utils::solution::Solution;
pub struct Day3Solution;
pub struct DaySolution;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"Not implemented"
}
impl Solution for Day3Solution {
fn part_one(&self) -> String {
// Implementation for part one of day 1
// ...

View File

@ -2,9 +2,14 @@ pub mod part_one;
use crate::utils::solution::Solution;
pub struct Day4Solution;
pub struct DaySolution;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"Not implemented"
}
impl Solution for Day4Solution {
fn part_one(&self) -> String {
// Implementation for part one of day 1
// ...

View File

@ -3,9 +3,14 @@ pub mod part_two;
use crate::utils::solution::Solution;
pub struct Day6Solution;
pub struct DaySolution;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"Not implemented"
}
impl Solution for Day6Solution {
fn part_one(&self) -> String {
// Implementation for part one of day 1
// ...

View File

@ -4,9 +4,14 @@ pub mod part_two;
use crate::utils::solution::Solution;
pub struct Day8Solution;
pub struct DaySolution;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"Not implemented"
}
impl Solution for Day8Solution {
fn part_one(&self) -> String {
// Implementation for part one of day 1
// ...

View File

@ -6,15 +6,19 @@ use crate::utils::solution::Solution;
use crate::utils::input_reader;
pub struct Day9Solution;
pub struct DaySolution;
impl Solution for Day9Solution {
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"input/2023/day_09/input.txt"
}
fn part_one(&self) -> String {
input_reader::read_input_file("input/2023/day_09/input.txt", part_one::part_one)
input_reader::read_input_file(self.input_path(), part_one::part_one)
}
fn part_two(&self) -> String {
input_reader::read_input_file("input/2023/day_09/input.txt", part_two::part_two)
input_reader::read_input_file(self.input_path(), part_two::part_two)
}
}

View File

@ -0,0 +1,25 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Pipe {
NorthSouth,
NorthWest,
NorthEast,
EastWest,
SouthWest,
SouthEast,
None,
Start,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Point {
pub x: usize,
pub y: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Direction {
North,
South,
West,
East,
}

View File

@ -0,0 +1,25 @@
pub mod part_one;
//pub mod part_two;
pub mod common;
use crate::utils::solution::Solution;
use crate::utils::input_reader;
pub struct DaySolution ;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"input/2023/day_10/input.txt"
}
fn part_one(&self) -> String {
input_reader::read_input_file(self.input_path(), part_one::part_one)
}
fn part_two(&self) -> String {
//input_reader::read_input_file(self.input_path, part_two::part_two)
String::from("Not implemented")
}
}

View File

@ -0,0 +1,170 @@
use super::common::Pipe;
use super::common::Point;
use super::common::Direction;
pub fn part_one(input_lines: Vec<String>) -> String {
let vert_dim = input_lines.len();
let horz_dim = input_lines[0].len();
let mut matrix = vec![vec![Pipe::None; horz_dim]; vert_dim];
let mut start_pos: Point = Point { x: 0, y: 0 };
for (y, line) in input_lines.iter().enumerate() {
for (x, c) in line.chars().enumerate() {
match c {
'|' => {
matrix[x][y] = Pipe::NorthSouth;
}
'J' => {
matrix[x][y] = Pipe::NorthWest;
}
'L' => {
matrix[x][y] = Pipe::NorthEast;
}
'-' => {
matrix[x][y] = Pipe::EastWest;
}
'7' => {
matrix[x][y] = Pipe::SouthWest;
}
'F' => {
matrix[x][y] = Pipe::SouthEast;
}
'.' => {
matrix[x][y] = Pipe::None;
}
'S' => {
matrix[x][y] = Pipe::Start;
start_pos = Point { x, y };
}
_ => panic!("Invalid character in input"),
}
}
}
let mut next: Option<Point> = None;
if start_pos.x > 0 {
let pos = matrix[start_pos.x - 1][start_pos.y];
match pos {
Pipe::NorthEast => next = Some(Point { x: start_pos.x - 1, y: start_pos.y }),
Pipe::SouthEast => next = Some(Point { x: start_pos.x - 1, y: start_pos.y }),
Pipe::EastWest => next = Some(Point { x: start_pos.x - 1, y: start_pos.y }),
_ => {}
}
}
if next.is_none() && start_pos.x < horz_dim - 1 {
let pos = matrix[start_pos.x + 1][start_pos.y];
match pos {
Pipe::NorthWest => next = Some(Point { x: start_pos.x + 1, y: start_pos.y }),
Pipe::SouthWest => next = Some(Point { x: start_pos.x + 1, y: start_pos.y }),
Pipe::EastWest => next = Some(Point { x: start_pos.x + 1, y: start_pos.y }),
_ => {}
}
}
if next.is_none() && start_pos.y > 0 {
let pos = matrix[start_pos.x][start_pos.y - 1];
match pos {
Pipe::NorthWest => next = Some(Point { x: start_pos.x, y: start_pos.y - 1 }),
Pipe::NorthEast => next = Some(Point { x: start_pos.x, y: start_pos.y - 1 }),
Pipe::NorthSouth => next = Some(Point { x: start_pos.x, y: start_pos.y - 1 }),
_ => {}
}
}
if next.is_none() && start_pos.y < vert_dim - 1 {
let pos = matrix[start_pos.x][start_pos.y + 1];
match pos {
Pipe::SouthWest => next = Some(Point { x: start_pos.x, y: start_pos.y + 1 }),
Pipe::SouthEast => next = Some(Point { x: start_pos.x, y: start_pos.y + 1 }),
Pipe::NorthSouth => next = Some(Point { x: start_pos.x, y: start_pos.y + 1 }),
_ => {}
}
}
let diff_x = start_pos.x as i32 - next.unwrap().x as i32;
let diff_y = start_pos.y as i32 - next.unwrap().y as i32;
// println!("Start: ({}, {})", start_pos.x, start_pos.y);
// println!("Next: ({}, {})", next.unwrap().x, next.unwrap().y);
// println!("Diff: ({}, {})", diff_x, diff_y);
let mut direction_from = match (diff_x, diff_y) {
(1, 0) => Direction::East,
(-1, 0) => Direction::West,
(0, 1) => Direction::South,
(0, -1) => Direction::North,
_ => panic!("Invalid direction"),
};
let mut count = 1;
while next.unwrap() != start_pos {
let x = next.unwrap().x;
let y = next.unwrap().y;
let pos = matrix[x][y];
// println!("X, Y: ({}, {})", x, y);
// println!("Direction: {:?}", direction_from);
// println!("Pos: {:?}", pos);
// println!();
let mut next_direction_from = direction_from;
match (direction_from, pos) {
(Direction::North, Pipe::NorthSouth) => {
next = Some(Point { x: x, y: y + 1 });
}
(Direction::North, Pipe::NorthEast) => {
next = Some(Point { x: x + 1, y: y });
next_direction_from = Direction::West;
}
(Direction::North, Pipe::NorthWest) => {
next = Some(Point { x: x - 1, y: y });
next_direction_from = Direction::East;
}
(Direction::East, Pipe::EastWest) => {
next = Some(Point { x: x - 1, y: y });
}
(Direction::East, Pipe::NorthEast) => {
next = Some(Point { x: x, y: y - 1 });
next_direction_from = Direction::South;
}
(Direction::East, Pipe::SouthEast) => {
next = Some(Point { x: x, y: y + 1 });
next_direction_from = Direction::North;
}
(Direction::South, Pipe::SouthWest) => {
next = Some(Point { x: x - 1, y: y });
next_direction_from = Direction::East;
}
(Direction::South, Pipe::NorthSouth) => {
next = Some(Point { x: x, y: y - 1 });
}
(Direction::South, Pipe::SouthEast) => {
next = Some(Point { x: x + 1, y: y });
next_direction_from = Direction::West;
}
(Direction::West, Pipe::EastWest) => {
next = Some(Point { x: x + 1, y: y });
}
(Direction::West, Pipe::SouthWest) => {
next = Some(Point { x: x, y: y + 1 });
next_direction_from = Direction::North;
}
(Direction::West, Pipe::NorthWest) => {
next = Some(Point { x: x, y: y - 1 });
next_direction_from = Direction::South;
}
_ => panic!("Invalid direction"),
};
direction_from = next_direction_from;
count += 1;
}
let result = count / 2 + count % 2;
result.to_string()
}

View File

@ -7,16 +7,18 @@ pub mod day_04_scratchcards;
pub mod day_06_wait_for_it;
pub mod day_08_haunted_wasteland;
pub mod day_09_mirage_maintenance;
pub mod day_10_pipe_maze;
pub fn run(day: &str) {
let solution: Box<dyn Solution> = match day {
"1" => Box::new(day_01_trebuchet::Day1Solution),
"2" => Box::new(day_02_cube_conundrum::Day2Solution),
"3" => Box::new(day_03_gear_ratios::Day3Solution),
"4" => Box::new(day_04_scratchcards::Day4Solution),
"6" => Box::new(day_06_wait_for_it::Day6Solution),
"8" => Box::new(day_08_haunted_wasteland::Day8Solution),
"9" => Box::new(day_09_mirage_maintenance::Day9Solution),
"1" => Box::new(day_01_trebuchet::DaySolution),
"2" => Box::new(day_02_cube_conundrum::DaySolution),
"3" => Box::new(day_03_gear_ratios::DaySolution),
"4" => Box::new(day_04_scratchcards::DaySolution),
"6" => Box::new(day_06_wait_for_it::DaySolution),
"8" => Box::new(day_08_haunted_wasteland::DaySolution),
"9" => Box::new(day_09_mirage_maintenance::DaySolution),
"10" => Box::new(day_10_pipe_maze::DaySolution),
_ => panic!("Invalid day specified"),
};