From 5030dfa2a48ae4e781e7de2434b38bdcb62c9c69 Mon Sep 17 00:00:00 2001 From: gabe Date: Mon, 5 Dec 2022 01:48:20 -0600 Subject: [PATCH] Solved day 5 --- Cargo.toml | 4 + src/day05/input.txt | 514 +++++++++++++++++++++++++++++++++++++++++ src/day05/part1.rs | 39 +++- src/day05/part2.rs | 39 +++- src/day05/solve.rs | 4 +- src/day05/utilities.rs | 140 ++++++++++- src/day06/input.txt | 0 src/day06/part1.rs | 15 ++ src/day06/part2.rs | 15 ++ src/day06/solve.rs | 14 ++ src/day06/utilities.rs | 16 ++ 11 files changed, 786 insertions(+), 14 deletions(-) create mode 100644 src/day06/input.txt create mode 100644 src/day06/part1.rs create mode 100644 src/day06/part2.rs create mode 100644 src/day06/solve.rs create mode 100644 src/day06/utilities.rs diff --git a/Cargo.toml b/Cargo.toml index cf51b81..f587e00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,10 @@ path="src/day04/solve.rs" name="day05" path="src/day05/solve.rs" +[[bin]] +name="day06" +path="src/day06/solve.rs" + [dependencies] regex="1" once_cell = "1.16.0" diff --git a/src/day05/input.txt b/src/day05/input.txt index e69de29..f3e1ad7 100644 --- a/src/day05/input.txt +++ b/src/day05/input.txt @@ -0,0 +1,514 @@ + [S] [C] [Z] +[F] [J] [P] [T] [N] +[G] [H] [G] [Q] [G] [D] +[V] [V] [D] [G] [F] [D] [V] +[R] [B] [F] [N] [N] [Q] [L] [S] +[J] [M] [M] [P] [H] [V] [B] [B] [D] +[L] [P] [H] [D] [L] [F] [D] [J] [L] +[D] [T] [V] [M] [J] [N] [F] [M] [G] + 1 2 3 4 5 6 7 8 9 + +move 3 from 4 to 6 +move 1 from 5 to 8 +move 3 from 7 to 3 +move 4 from 5 to 7 +move 1 from 7 to 8 +move 3 from 9 to 4 +move 2 from 8 to 2 +move 4 from 4 to 5 +move 2 from 5 to 1 +move 2 from 5 to 6 +move 7 from 8 to 1 +move 9 from 3 to 9 +move 11 from 6 to 5 +move 2 from 6 to 7 +move 12 from 1 to 4 +move 10 from 2 to 9 +move 2 from 3 to 9 +move 1 from 7 to 5 +move 4 from 7 to 6 +move 2 from 6 to 1 +move 5 from 1 to 6 +move 10 from 9 to 1 +move 9 from 9 to 8 +move 13 from 4 to 3 +move 7 from 6 to 2 +move 2 from 8 to 5 +move 9 from 3 to 9 +move 8 from 9 to 8 +move 4 from 8 to 4 +move 1 from 7 to 5 +move 3 from 9 to 1 +move 7 from 2 to 1 +move 1 from 3 to 1 +move 1 from 3 to 6 +move 1 from 6 to 1 +move 2 from 3 to 6 +move 5 from 4 to 1 +move 1 from 6 to 1 +move 3 from 8 to 7 +move 8 from 8 to 4 +move 3 from 5 to 4 +move 1 from 6 to 7 +move 1 from 5 to 8 +move 4 from 5 to 2 +move 7 from 5 to 8 +move 3 from 2 to 7 +move 7 from 4 to 8 +move 11 from 8 to 4 +move 15 from 4 to 1 +move 25 from 1 to 6 +move 4 from 8 to 7 +move 1 from 2 to 4 +move 11 from 6 to 4 +move 12 from 6 to 3 +move 1 from 1 to 9 +move 1 from 9 to 8 +move 16 from 1 to 3 +move 1 from 8 to 7 +move 12 from 4 to 6 +move 9 from 6 to 5 +move 3 from 6 to 5 +move 6 from 7 to 5 +move 3 from 3 to 5 +move 2 from 6 to 3 +move 11 from 5 to 8 +move 2 from 8 to 3 +move 2 from 1 to 4 +move 7 from 3 to 1 +move 2 from 4 to 6 +move 2 from 6 to 2 +move 5 from 7 to 3 +move 1 from 1 to 6 +move 1 from 1 to 8 +move 2 from 2 to 5 +move 1 from 7 to 4 +move 1 from 1 to 2 +move 10 from 3 to 5 +move 11 from 3 to 6 +move 1 from 4 to 9 +move 1 from 9 to 4 +move 1 from 4 to 2 +move 2 from 5 to 9 +move 2 from 2 to 8 +move 2 from 1 to 6 +move 2 from 1 to 2 +move 2 from 3 to 6 +move 3 from 8 to 1 +move 3 from 1 to 4 +move 7 from 8 to 3 +move 2 from 9 to 5 +move 2 from 4 to 9 +move 7 from 5 to 6 +move 2 from 8 to 6 +move 1 from 4 to 8 +move 2 from 2 to 4 +move 21 from 6 to 3 +move 10 from 5 to 7 +move 7 from 7 to 6 +move 1 from 9 to 3 +move 1 from 4 to 9 +move 1 from 9 to 4 +move 1 from 8 to 4 +move 8 from 6 to 4 +move 1 from 4 to 5 +move 1 from 5 to 8 +move 4 from 3 to 6 +move 1 from 8 to 2 +move 1 from 4 to 2 +move 2 from 7 to 3 +move 2 from 2 to 7 +move 22 from 3 to 5 +move 4 from 6 to 2 +move 2 from 6 to 9 +move 7 from 3 to 9 +move 6 from 9 to 1 +move 18 from 5 to 3 +move 2 from 5 to 4 +move 20 from 3 to 5 +move 3 from 7 to 3 +move 5 from 1 to 2 +move 11 from 5 to 7 +move 1 from 1 to 7 +move 3 from 9 to 3 +move 16 from 5 to 8 +move 7 from 8 to 7 +move 1 from 9 to 2 +move 8 from 2 to 3 +move 2 from 2 to 4 +move 3 from 3 to 1 +move 9 from 3 to 8 +move 1 from 6 to 3 +move 9 from 7 to 3 +move 3 from 1 to 8 +move 1 from 7 to 9 +move 1 from 9 to 4 +move 1 from 7 to 5 +move 10 from 4 to 5 +move 2 from 4 to 2 +move 19 from 8 to 5 +move 1 from 8 to 3 +move 4 from 3 to 5 +move 2 from 4 to 8 +move 4 from 7 to 8 +move 4 from 3 to 9 +move 4 from 7 to 6 +move 2 from 2 to 5 +move 2 from 3 to 2 +move 6 from 8 to 7 +move 1 from 8 to 4 +move 2 from 6 to 4 +move 3 from 4 to 8 +move 3 from 9 to 2 +move 4 from 7 to 8 +move 28 from 5 to 8 +move 16 from 8 to 4 +move 11 from 8 to 4 +move 3 from 3 to 4 +move 7 from 5 to 8 +move 13 from 8 to 7 +move 1 from 5 to 6 +move 1 from 6 to 7 +move 1 from 9 to 2 +move 2 from 6 to 2 +move 12 from 4 to 9 +move 4 from 4 to 1 +move 2 from 9 to 8 +move 4 from 8 to 3 +move 3 from 4 to 5 +move 4 from 4 to 1 +move 4 from 4 to 7 +move 3 from 7 to 9 +move 5 from 9 to 7 +move 7 from 2 to 3 +move 1 from 5 to 7 +move 8 from 1 to 5 +move 1 from 2 to 4 +move 11 from 3 to 1 +move 10 from 5 to 3 +move 3 from 9 to 1 +move 3 from 9 to 6 +move 5 from 1 to 6 +move 7 from 6 to 9 +move 8 from 9 to 7 +move 9 from 3 to 4 +move 1 from 6 to 9 +move 8 from 7 to 1 +move 9 from 4 to 2 +move 2 from 1 to 6 +move 3 from 2 to 6 +move 4 from 4 to 6 +move 2 from 9 to 8 +move 2 from 1 to 2 +move 1 from 3 to 8 +move 2 from 8 to 4 +move 1 from 6 to 8 +move 11 from 1 to 6 +move 1 from 1 to 5 +move 3 from 2 to 9 +move 2 from 9 to 3 +move 1 from 1 to 7 +move 2 from 4 to 9 +move 4 from 2 to 9 +move 2 from 8 to 5 +move 10 from 6 to 1 +move 2 from 5 to 6 +move 5 from 9 to 8 +move 5 from 8 to 7 +move 1 from 2 to 1 +move 7 from 1 to 2 +move 2 from 9 to 4 +move 1 from 3 to 5 +move 15 from 7 to 2 +move 8 from 6 to 3 +move 2 from 4 to 3 +move 2 from 6 to 4 +move 4 from 7 to 1 +move 4 from 7 to 5 +move 1 from 6 to 4 +move 3 from 1 to 7 +move 5 from 7 to 6 +move 4 from 7 to 5 +move 18 from 2 to 4 +move 5 from 6 to 4 +move 4 from 1 to 2 +move 8 from 3 to 8 +move 2 from 8 to 4 +move 2 from 3 to 7 +move 1 from 5 to 7 +move 3 from 8 to 4 +move 2 from 7 to 2 +move 1 from 3 to 8 +move 9 from 2 to 6 +move 2 from 8 to 6 +move 1 from 7 to 3 +move 1 from 3 to 5 +move 3 from 6 to 8 +move 1 from 8 to 5 +move 1 from 5 to 9 +move 1 from 1 to 2 +move 5 from 4 to 6 +move 10 from 6 to 2 +move 5 from 2 to 6 +move 5 from 6 to 4 +move 1 from 6 to 3 +move 6 from 4 to 6 +move 3 from 2 to 6 +move 2 from 2 to 3 +move 11 from 4 to 6 +move 1 from 9 to 5 +move 4 from 6 to 7 +move 1 from 4 to 3 +move 12 from 4 to 3 +move 1 from 8 to 6 +move 9 from 5 to 7 +move 1 from 5 to 2 +move 1 from 8 to 5 +move 1 from 4 to 9 +move 9 from 7 to 9 +move 1 from 3 to 4 +move 2 from 3 to 6 +move 2 from 5 to 6 +move 2 from 8 to 5 +move 11 from 3 to 4 +move 2 from 3 to 1 +move 1 from 2 to 3 +move 1 from 3 to 8 +move 3 from 7 to 9 +move 5 from 4 to 2 +move 2 from 5 to 8 +move 6 from 4 to 2 +move 1 from 1 to 3 +move 12 from 9 to 1 +move 6 from 1 to 6 +move 1 from 8 to 4 +move 1 from 8 to 3 +move 5 from 2 to 7 +move 2 from 3 to 9 +move 5 from 7 to 1 +move 1 from 7 to 5 +move 2 from 9 to 1 +move 14 from 1 to 7 +move 2 from 4 to 7 +move 7 from 2 to 4 +move 1 from 2 to 1 +move 1 from 1 to 3 +move 1 from 5 to 4 +move 1 from 9 to 6 +move 16 from 6 to 5 +move 2 from 5 to 4 +move 12 from 6 to 8 +move 10 from 4 to 8 +move 9 from 7 to 3 +move 4 from 7 to 6 +move 11 from 5 to 8 +move 2 from 5 to 2 +move 14 from 8 to 9 +move 1 from 5 to 1 +move 3 from 9 to 4 +move 2 from 2 to 1 +move 7 from 8 to 3 +move 6 from 3 to 5 +move 8 from 9 to 8 +move 1 from 6 to 1 +move 1 from 4 to 2 +move 4 from 3 to 8 +move 1 from 7 to 2 +move 3 from 1 to 5 +move 2 from 5 to 7 +move 3 from 9 to 2 +move 1 from 1 to 8 +move 5 from 5 to 4 +move 2 from 7 to 8 +move 4 from 2 to 5 +move 1 from 2 to 4 +move 2 from 7 to 8 +move 4 from 6 to 2 +move 6 from 5 to 3 +move 1 from 6 to 5 +move 1 from 5 to 3 +move 1 from 3 to 8 +move 8 from 8 to 3 +move 9 from 8 to 5 +move 9 from 8 to 2 +move 2 from 8 to 9 +move 2 from 3 to 8 +move 5 from 5 to 8 +move 1 from 3 to 7 +move 2 from 9 to 5 +move 7 from 2 to 4 +move 14 from 4 to 6 +move 2 from 2 to 7 +move 1 from 7 to 3 +move 1 from 7 to 9 +move 3 from 5 to 2 +move 1 from 7 to 1 +move 3 from 2 to 4 +move 7 from 8 to 2 +move 3 from 6 to 1 +move 17 from 3 to 1 +move 2 from 8 to 3 +move 6 from 2 to 7 +move 2 from 7 to 9 +move 3 from 6 to 8 +move 2 from 8 to 6 +move 4 from 2 to 1 +move 3 from 4 to 7 +move 1 from 8 to 7 +move 1 from 8 to 9 +move 1 from 4 to 2 +move 3 from 5 to 7 +move 2 from 3 to 1 +move 2 from 3 to 5 +move 5 from 7 to 4 +move 5 from 7 to 3 +move 1 from 4 to 8 +move 3 from 3 to 1 +move 6 from 1 to 3 +move 1 from 7 to 5 +move 2 from 9 to 2 +move 3 from 5 to 8 +move 1 from 8 to 1 +move 8 from 3 to 5 +move 1 from 4 to 9 +move 3 from 6 to 5 +move 3 from 6 to 3 +move 2 from 3 to 7 +move 1 from 4 to 7 +move 3 from 6 to 4 +move 2 from 7 to 2 +move 1 from 7 to 8 +move 2 from 5 to 4 +move 1 from 6 to 1 +move 7 from 4 to 7 +move 7 from 5 to 2 +move 10 from 2 to 3 +move 3 from 2 to 6 +move 3 from 8 to 1 +move 1 from 8 to 7 +move 2 from 6 to 3 +move 1 from 6 to 9 +move 4 from 7 to 5 +move 16 from 1 to 5 +move 1 from 9 to 7 +move 3 from 7 to 6 +move 11 from 5 to 6 +move 2 from 7 to 9 +move 12 from 6 to 4 +move 2 from 6 to 9 +move 6 from 3 to 2 +move 1 from 5 to 7 +move 5 from 9 to 5 +move 1 from 9 to 6 +move 4 from 3 to 7 +move 1 from 4 to 2 +move 7 from 2 to 5 +move 3 from 5 to 2 +move 6 from 5 to 6 +move 3 from 2 to 6 +move 9 from 6 to 8 +move 5 from 5 to 9 +move 5 from 7 to 1 +move 4 from 1 to 9 +move 2 from 9 to 4 +move 1 from 6 to 7 +move 9 from 4 to 1 +move 7 from 5 to 9 +move 18 from 1 to 3 +move 9 from 9 to 5 +move 8 from 8 to 2 +move 1 from 2 to 5 +move 4 from 2 to 3 +move 4 from 9 to 6 +move 1 from 4 to 8 +move 2 from 5 to 7 +move 2 from 9 to 2 +move 10 from 3 to 9 +move 5 from 5 to 9 +move 1 from 7 to 2 +move 2 from 8 to 7 +move 2 from 3 to 5 +move 2 from 9 to 1 +move 2 from 7 to 3 +move 1 from 2 to 1 +move 5 from 5 to 8 +move 1 from 2 to 1 +move 15 from 3 to 6 +move 1 from 7 to 6 +move 10 from 6 to 5 +move 1 from 7 to 8 +move 4 from 1 to 6 +move 1 from 8 to 3 +move 2 from 1 to 5 +move 3 from 8 to 1 +move 1 from 4 to 6 +move 1 from 4 to 2 +move 4 from 9 to 7 +move 6 from 5 to 7 +move 3 from 1 to 9 +move 10 from 6 to 8 +move 2 from 1 to 3 +move 8 from 7 to 9 +move 1 from 9 to 6 +move 2 from 7 to 9 +move 3 from 3 to 5 +move 1 from 2 to 6 +move 2 from 6 to 5 +move 5 from 9 to 4 +move 4 from 8 to 2 +move 1 from 1 to 3 +move 4 from 5 to 9 +move 3 from 6 to 1 +move 2 from 1 to 5 +move 3 from 5 to 2 +move 8 from 8 to 3 +move 11 from 9 to 4 +move 13 from 4 to 8 +move 2 from 9 to 2 +move 2 from 3 to 1 +move 1 from 4 to 1 +move 1 from 3 to 8 +move 2 from 6 to 9 +move 7 from 8 to 1 +move 3 from 2 to 5 +move 7 from 2 to 5 +move 3 from 4 to 6 +move 4 from 9 to 2 +move 2 from 3 to 5 +move 9 from 5 to 6 +move 5 from 2 to 7 +move 2 from 9 to 2 +move 2 from 9 to 7 +move 12 from 6 to 8 +move 5 from 5 to 7 +move 1 from 9 to 8 +move 3 from 1 to 6 +move 5 from 5 to 8 +move 6 from 1 to 9 +move 2 from 1 to 5 +move 1 from 6 to 9 +move 5 from 9 to 7 +move 2 from 5 to 8 +move 11 from 7 to 6 +move 20 from 8 to 1 +move 2 from 9 to 8 +move 4 from 7 to 6 +move 6 from 8 to 3 +move 13 from 6 to 9 +move 4 from 3 to 2 +move 4 from 6 to 3 +move 2 from 3 to 6 +move 5 from 9 to 8 +move 2 from 7 to 1 +move 2 from 6 to 9 +move 6 from 8 to 3 +move 6 from 3 to 6 +move 5 from 2 to 9 +move 22 from 1 to 3 +move 3 from 2 to 1 +move 5 from 9 to 3 +move 1 from 1 to 6 +move 3 from 6 to 2 +move 1 from 2 to 4 +move 33 from 3 to 5 +move 1 from 8 to 7 diff --git a/src/day05/part1.rs b/src/day05/part1.rs index 4074daf..613a679 100644 --- a/src/day05/part1.rs +++ b/src/day05/part1.rs @@ -1,7 +1,15 @@ use crate::utilities::*; -pub fn part1() -> usize { - unimplemented!() +pub fn part1(input: &(WorkArea, Vec)) -> Vec { + let (mut work_area, moves) = input.to_owned(); + for r#move in moves { + work_area.apply_move_cratemover9000(&r#move) + } + work_area + .get_stacks() + .iter() + .map(|stack| stack.last().unwrap().to_owned()) + .collect() } #[cfg(test)] @@ -10,6 +18,31 @@ mod tests { #[test] fn test_part1() { - assert_eq!(part1(), 0); + let input = ( + WorkArea::new(vec![vec!['Z', 'N'], vec!['M', 'C', 'D'], vec!['P']]), + vec![ + Move { + to: 1, + from: 2, + number: 1, + }, + Move { + to: 3, + from: 1, + number: 3, + }, + Move { + to: 1, + from: 2, + number: 2, + }, + Move { + to: 2, + from: 1, + number: 1, + }, + ], + ); + assert_eq!(part1(&input), vec!['C', 'M', 'Z']); } } diff --git a/src/day05/part2.rs b/src/day05/part2.rs index 246b113..523fe2c 100644 --- a/src/day05/part2.rs +++ b/src/day05/part2.rs @@ -1,7 +1,15 @@ use crate::utilities::*; -pub fn part2() -> usize { - unimplemented!() +pub fn part2(input: &(WorkArea, Vec)) -> Vec { + let (mut work_area, moves) = input.to_owned(); + for r#move in moves { + work_area.apply_move_cratemover9001(&r#move) + } + work_area + .get_stacks() + .iter() + .map(|stack| stack.last().unwrap().to_owned()) + .collect() } #[cfg(test)] @@ -10,6 +18,31 @@ mod tests { #[test] fn test_part2() { - assert_eq!(part2(), 0); + let input = ( + WorkArea::new(vec![vec!['Z', 'N'], vec!['M', 'C', 'D'], vec!['P']]), + vec![ + Move { + to: 1, + from: 2, + number: 1, + }, + Move { + to: 3, + from: 1, + number: 3, + }, + Move { + to: 1, + from: 2, + number: 2, + }, + Move { + to: 2, + from: 1, + number: 1, + }, + ], + ); + assert_eq!(part2(&input), vec!['M', 'C', 'D']); } } diff --git a/src/day05/solve.rs b/src/day05/solve.rs index c613d23..27ac4d5 100644 --- a/src/day05/solve.rs +++ b/src/day05/solve.rs @@ -7,8 +7,8 @@ fn main() { let _structured_input = utilities::parse(_input); println!("Part One"); - println!("Result: {}", part1::part1()); + println!("Result: {:?}", part1::part1(&_structured_input)); println!("Part Two"); - println!("Result: {}", part2::part2()); + println!("Result: {:?}", part2::part2(&_structured_input)); } diff --git a/src/day05/utilities.rs b/src/day05/utilities.rs index be3e53c..30206df 100644 --- a/src/day05/utilities.rs +++ b/src/day05/utilities.rs @@ -1,16 +1,144 @@ -pub fn parse(input: &str) -> usize { - unimplemented!() +use once_cell::sync::Lazy; +use regex::Regex; +#[derive(Debug, PartialEq, Eq, Clone)] +pub struct Move { + pub to: usize, + pub from: usize, + pub number: u8, +} + +#[derive(Debug, PartialEq, Eq, Clone)] +pub struct WorkArea { + stacks: Vec>, +} + +impl WorkArea { + pub fn new(stacks: Vec>) -> Self { + Self { stacks } + } + pub fn apply_move_cratemover9000(&mut self, action: &Move) { + for _ in 0..action.number { + let cargo = self.stacks.get_mut(action.from - 1).unwrap().pop().unwrap(); + self.stacks.get_mut(action.to - 1).unwrap().push(cargo); + } + } + pub fn apply_move_cratemover9001(&mut self, action: &Move) { + let mut crane_holder: Vec = Vec::new(); + for _ in 0..action.number { + let cargo = self.stacks.get_mut(action.from - 1).unwrap().pop().unwrap(); + crane_holder.push(cargo); + } + for cargo in crane_holder.iter().rev() { + self.stacks.get_mut(action.to - 1).unwrap().push(*cargo); + } + } + pub fn get_stacks(&self) -> &Vec> { + &self.stacks + } +} + +pub fn parse(input: &str) -> (WorkArea, Vec) { + let mut input = input.split("\n\n"); + let work_area = parse_work_area(input.next().unwrap()); + let moves = parse_moves(input.next().unwrap()); + (work_area, moves) +} + +pub fn parse_work_area(input: &str) -> WorkArea { + //decode those bottom index numbers + let index_row = input.lines().rev().next().unwrap(); + //some ascii math and array math to get the second to last char and convert it into a number. + let index_max: usize = (index_row.as_bytes()[index_row.len() - 2] - b'0') as usize; + //initalize the work area: + let mut work_area: Vec> = Vec::new(); + for _ in 0..index_max { + work_area.push(Vec::new()) + } + + //now parse the rest + for line in input.lines().rev() { + for (y, cargo_crate) in line.as_bytes().chunks(4).enumerate() { + let cargo = cargo_crate[1] as char; + //easiest way to filter out that last line is just to filter out digits. + if cargo != ' ' && !cargo.is_ascii_digit() { + work_area.get_mut(y).unwrap().push(cargo) + } + } + } + + WorkArea::new(work_area) +} + +pub fn parse_moves(input: &str) -> Vec { + static PARSE_MOVES_REGEX: Lazy = + Lazy::new(|| Regex::new(r"^move (\d+) from (\d+) to (\d+)$").unwrap()); + input + .lines() + .map(|line| { + let cap = PARSE_MOVES_REGEX.captures(line).unwrap(); + Move { + to: cap.get(3).unwrap().as_str().parse().unwrap(), + from: cap.get(2).unwrap().as_str().parse().unwrap(), + number: cap.get(1).unwrap().as_str().parse().unwrap(), + } + }) + .collect() } #[cfg(test)] mod tests { use super::*; + #[test] + fn test_parse_work_area() { + let input = " [D] +[N] [C] +[Z] [M] [P] + 1 2 3 "; + assert_eq!( + parse_work_area(input), + WorkArea::new(vec![vec!['Z', 'N'], vec!['M', 'C', 'D'], vec!['P'],],) + ) + } + #[test] fn test_parse() { - let input = -"test" -; - assert_eq!(parse(input), 0); + let input = " [D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +move 1 from 2 to 1 +move 3 from 1 to 3 +move 2 from 2 to 1 +move 1 from 1 to 2"; + assert_eq!( + parse(input), + ( + WorkArea::new(vec![vec!['Z', 'N'], vec!['M', 'C', 'D'], vec!['P'],],), + vec![ + Move { + to: 1, + from: 2, + number: 1 + }, + Move { + to: 3, + from: 1, + number: 3 + }, + Move { + to: 1, + from: 2, + number: 2 + }, + Move { + to: 2, + from: 1, + number: 1 + }, + ] + ) + ); } } diff --git a/src/day06/input.txt b/src/day06/input.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/day06/part1.rs b/src/day06/part1.rs new file mode 100644 index 0000000..4074daf --- /dev/null +++ b/src/day06/part1.rs @@ -0,0 +1,15 @@ +use crate::utilities::*; + +pub fn part1() -> usize { + unimplemented!() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_part1() { + assert_eq!(part1(), 0); + } +} diff --git a/src/day06/part2.rs b/src/day06/part2.rs new file mode 100644 index 0000000..246b113 --- /dev/null +++ b/src/day06/part2.rs @@ -0,0 +1,15 @@ +use crate::utilities::*; + +pub fn part2() -> usize { + unimplemented!() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_part2() { + assert_eq!(part2(), 0); + } +} diff --git a/src/day06/solve.rs b/src/day06/solve.rs new file mode 100644 index 0000000..c613d23 --- /dev/null +++ b/src/day06/solve.rs @@ -0,0 +1,14 @@ +mod part1; +mod part2; +mod utilities; + +fn main() { + let _input = include_str!("./input.txt"); + let _structured_input = utilities::parse(_input); + + println!("Part One"); + println!("Result: {}", part1::part1()); + + println!("Part Two"); + println!("Result: {}", part2::part2()); +} diff --git a/src/day06/utilities.rs b/src/day06/utilities.rs new file mode 100644 index 0000000..be3e53c --- /dev/null +++ b/src/day06/utilities.rs @@ -0,0 +1,16 @@ +pub fn parse(input: &str) -> usize { + unimplemented!() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse() { + let input = +"test" +; + assert_eq!(parse(input), 0); + } +}