diff --git a/Cargo.lock b/Cargo.lock index 316f05f..e2cfc24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,12 +69,36 @@ dependencies = [ "regex", ] +[[package]] +name = "day10" +version = "0.1.0" +dependencies = [ + "aoc_libs", + "nom", +] + [[package]] name = "memchr" version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -142,6 +166,9 @@ dependencies = [ [[package]] name = "template" version = "0.1.0" +dependencies = [ + "aoc_libs", +] [[package]] name = "thiserror" diff --git a/days/day09/src/main.rs b/days/day09/src/main.rs index f92bdf7..5c07519 100644 --- a/days/day09/src/main.rs +++ b/days/day09/src/main.rs @@ -1,5 +1,3 @@ -//TODO: -#![allow(dead_code)] mod part1; mod part2; mod parse; diff --git a/days/day10/Cargo.toml b/days/day10/Cargo.toml new file mode 100644 index 0000000..529f9e5 --- /dev/null +++ b/days/day10/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day10" +authors.workspace = true +description.workspace = true +version.workspace = true +edition.workspace = true + +[dependencies] +aoc_libs.workspace = true +nom.workspace = true diff --git a/days/day10/src/input.txt b/days/day10/src/input.txt new file mode 100644 index 0000000..c26a664 --- /dev/null +++ b/days/day10/src/input.txt @@ -0,0 +1,139 @@ +noop +addx 12 +addx -5 +addx -1 +noop +addx 4 +noop +addx 1 +addx 4 +noop +addx 13 +addx -8 +noop +addx -19 +addx 24 +addx 1 +noop +addx 4 +noop +addx 1 +addx 5 +addx -1 +addx -37 +addx 16 +addx -13 +addx 18 +addx -11 +addx 2 +addx 23 +noop +addx -18 +addx 9 +addx -8 +addx 2 +addx 5 +addx 2 +addx -21 +addx 26 +noop +addx -15 +addx 20 +noop +addx 3 +noop +addx -38 +addx 3 +noop +addx 26 +addx -4 +addx -19 +addx 3 +addx 1 +addx 5 +addx 3 +noop +addx 2 +addx 3 +noop +addx 2 +noop +noop +noop +noop +addx 5 +noop +noop +noop +addx 3 +noop +addx -30 +addx -4 +addx 1 +addx 18 +addx -8 +addx -4 +addx 2 +noop +addx 7 +noop +noop +noop +noop +addx 5 +noop +noop +addx 5 +addx -2 +addx -20 +addx 27 +addx -20 +addx 25 +addx -2 +addx -35 +noop +noop +addx 4 +addx 3 +addx -2 +addx 5 +addx 2 +addx -11 +addx 1 +addx 13 +addx 2 +addx 5 +addx 6 +addx -1 +addx -2 +noop +addx 7 +addx -2 +addx 6 +addx 1 +addx -21 +addx 22 +addx -38 +addx 5 +addx 3 +addx -1 +noop +noop +addx 5 +addx 1 +addx 4 +addx 3 +addx -2 +addx 2 +noop +addx 7 +addx -1 +addx 2 +addx 4 +addx -10 +addx -19 +addx 35 +addx -1 +noop +noop +noop diff --git a/days/day10/src/machine.rs b/days/day10/src/machine.rs new file mode 100644 index 0000000..9b2fbbe --- /dev/null +++ b/days/day10/src/machine.rs @@ -0,0 +1,256 @@ +use std::{collections::VecDeque, fmt}; + +use crate::parse::*; + +pub struct Machine { + instructions: VecDeque, + current_instruction: Option<(Instruction, usize)>, + cycle: usize, + x: i32, +} + +impl Machine { + pub fn load_program(instructions: VecDeque) -> Self { + let mut res = Machine { + instructions, + current_instruction: None, + cycle: 0, + x: 1, + }; + res.fetch_next_instruction(); + res + } + + pub fn step(&mut self) -> bool { + if self.current_instruction.is_none() { + return false; + } + + let (instruction, cycles_left) = self.current_instruction.as_mut().unwrap(); + *cycles_left -= 1; + if *cycles_left == 0 { + if let Instruction::Addx(i) = instruction { + self.x += *i + } + + self.fetch_next_instruction(); + }; + + self.cycle += 1; + true + } + + fn fetch_next_instruction(&mut self) { + self.current_instruction = self.instructions.pop_front().map(|i| (i, i.cycles())); + } + + //returns the signal strength during the middle of the 20th cycle. + pub fn step20(&mut self) -> i32 { + for _ in 0..19 { + if !self.step() { + break; + } + } + let ret = self.x*(self.cycle as i32 +1); + self.step(); + ret + } + + pub fn signal_strength(&self) -> i32 { + self.x * (self.cycle as i32) + } +} + +impl fmt::Debug for Machine { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "cycle={} x={} current instruction: {:?} ({} instructions left)", + self.cycle, + self.x, + self.current_instruction, + self.instructions.len() + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_machine() { + let input = vec![ + Instruction::Addx(15), + Instruction::Addx(-11), + Instruction::Addx(6), + Instruction::Addx(-3), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(-8), + Instruction::Addx(13), + Instruction::Addx(4), + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(-35), + Instruction::Addx(1), + Instruction::Addx(24), + Instruction::Addx(-19), + Instruction::Addx(1), + Instruction::Addx(16), + Instruction::Addx(-11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(21), + Instruction::Addx(-15), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-3), + Instruction::Addx(9), + Instruction::Addx(1), + Instruction::Addx(-3), + Instruction::Addx(8), + Instruction::Addx(1), + Instruction::Addx(5), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-36), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::Addx(7), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(2), + Instruction::Addx(6), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(7), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(-13), + Instruction::Addx(13), + Instruction::Addx(7), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::Addx(-33), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(2), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(8), + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(2), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(17), + Instruction::Addx(-9), + Instruction::Addx(1), + Instruction::Addx(1), + Instruction::Addx(-3), + Instruction::Addx(11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-13), + Instruction::Addx(-19), + Instruction::Addx(1), + Instruction::Addx(3), + Instruction::Addx(26), + Instruction::Addx(-30), + Instruction::Addx(12), + Instruction::Addx(-1), + Instruction::Addx(3), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-9), + Instruction::Addx(18), + Instruction::Addx(1), + Instruction::Addx(2), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(9), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(2), + Instruction::Addx(-37), + Instruction::Addx(1), + Instruction::Addx(3), + Instruction::NoOp, + Instruction::Addx(15), + Instruction::Addx(-21), + Instruction::Addx(22), + Instruction::Addx(-6), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(2), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(-10), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(20), + Instruction::Addx(1), + Instruction::Addx(2), + Instruction::Addx(2), + Instruction::Addx(-6), + Instruction::Addx(-11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + ]; + let mut machine = Machine::load_program(input.into()); + + //20th + assert_eq!(machine.step20(), 420); + + machine.step20(); + //60th + assert_eq!(machine.step20(), 1140); + + machine.step20(); + //100th + assert_eq!(machine.step20(), 1800); + + machine.step20(); + //140th + assert_eq!(machine.step20(), 2940); + + machine.step20(); + //180th + assert_eq!(machine.step20(), 2880); + + machine.step20(); + //220th + assert_eq!(machine.step20(), 3960); + } +} diff --git a/days/day10/src/main.rs b/days/day10/src/main.rs new file mode 100644 index 0000000..72815fb --- /dev/null +++ b/days/day10/src/main.rs @@ -0,0 +1,15 @@ +mod part1; +mod part2; +mod parse; +mod machine; + +fn main() { + let input = include_str!("./input.txt"); + let structured_input = parse::parse(input); + + println!("Part One"); + println!("Result: {}", part1::part1(structured_input)); + + println!("Part Two"); + println!("Result: {}", part2::part2()); +} diff --git a/days/day10/src/parse.rs b/days/day10/src/parse.rs new file mode 100644 index 0000000..1fdbb02 --- /dev/null +++ b/days/day10/src/parse.rs @@ -0,0 +1,344 @@ +use std::collections::VecDeque; + +use nom::{ + branch::alt, + bytes::complete::tag, + combinator::{all_consuming, map, value}, + sequence::preceded, + Finish, IResult, +}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Instruction { + NoOp, + Addx(i32), +} + +impl Instruction { + fn parse(i: &str) -> IResult<&str, Self> { + let noop = tag("noop"); + let addx = preceded(tag("addx "), nom::character::complete::i32); + alt((value(Self::NoOp, noop), map(addx, Self::Addx)))(i) + } + pub fn cycles(self) -> usize { + match self { + Self::NoOp => 1, + Self::Addx(_) => 2, + } + } +} + +pub fn parse(input: &str) -> VecDeque { + input + .lines() + .map(|l| all_consuming(Instruction::parse)(l).finish().unwrap().1) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse() { + let input = concat!( + "addx 15\n", + "addx -11\n", + "addx 6\n", + "addx -3\n", + "addx 5\n", + "addx -1\n", + "addx -8\n", + "addx 13\n", + "addx 4\n", + "noop\n", + "addx -1\n", + "addx 5\n", + "addx -1\n", + "addx 5\n", + "addx -1\n", + "addx 5\n", + "addx -1\n", + "addx 5\n", + "addx -1\n", + "addx -35\n", + "addx 1\n", + "addx 24\n", + "addx -19\n", + "addx 1\n", + "addx 16\n", + "addx -11\n", + "noop\n", + "noop\n", + "addx 21\n", + "addx -15\n", + "noop\n", + "noop\n", + "addx -3\n", + "addx 9\n", + "addx 1\n", + "addx -3\n", + "addx 8\n", + "addx 1\n", + "addx 5\n", + "noop\n", + "noop\n", + "noop\n", + "noop\n", + "noop\n", + "addx -36\n", + "noop\n", + "addx 1\n", + "addx 7\n", + "noop\n", + "noop\n", + "noop\n", + "addx 2\n", + "addx 6\n", + "noop\n", + "noop\n", + "noop\n", + "noop\n", + "noop\n", + "addx 1\n", + "noop\n", + "noop\n", + "addx 7\n", + "addx 1\n", + "noop\n", + "addx -13\n", + "addx 13\n", + "addx 7\n", + "noop\n", + "addx 1\n", + "addx -33\n", + "noop\n", + "noop\n", + "noop\n", + "addx 2\n", + "noop\n", + "noop\n", + "noop\n", + "addx 8\n", + "noop\n", + "addx -1\n", + "addx 2\n", + "addx 1\n", + "noop\n", + "addx 17\n", + "addx -9\n", + "addx 1\n", + "addx 1\n", + "addx -3\n", + "addx 11\n", + "noop\n", + "noop\n", + "addx 1\n", + "noop\n", + "addx 1\n", + "noop\n", + "noop\n", + "addx -13\n", + "addx -19\n", + "addx 1\n", + "addx 3\n", + "addx 26\n", + "addx -30\n", + "addx 12\n", + "addx -1\n", + "addx 3\n", + "addx 1\n", + "noop\n", + "noop\n", + "noop\n", + "addx -9\n", + "addx 18\n", + "addx 1\n", + "addx 2\n", + "noop\n", + "noop\n", + "addx 9\n", + "noop\n", + "noop\n", + "noop\n", + "addx -1\n", + "addx 2\n", + "addx -37\n", + "addx 1\n", + "addx 3\n", + "noop\n", + "addx 15\n", + "addx -21\n", + "addx 22\n", + "addx -6\n", + "addx 1\n", + "noop\n", + "addx 2\n", + "addx 1\n", + "noop\n", + "addx -10\n", + "noop\n", + "noop\n", + "addx 20\n", + "addx 1\n", + "addx 2\n", + "addx 2\n", + "addx -6\n", + "addx -11\n", + "noop\n", + "noop\n", + "noop\n", + ); + assert_eq!( + parse(input), + vec![ + Instruction::Addx(15), + Instruction::Addx(-11), + Instruction::Addx(6), + Instruction::Addx(-3), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(-8), + Instruction::Addx(13), + Instruction::Addx(4), + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(-35), + Instruction::Addx(1), + Instruction::Addx(24), + Instruction::Addx(-19), + Instruction::Addx(1), + Instruction::Addx(16), + Instruction::Addx(-11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(21), + Instruction::Addx(-15), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-3), + Instruction::Addx(9), + Instruction::Addx(1), + Instruction::Addx(-3), + Instruction::Addx(8), + Instruction::Addx(1), + Instruction::Addx(5), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-36), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::Addx(7), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(2), + Instruction::Addx(6), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(7), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(-13), + Instruction::Addx(13), + Instruction::Addx(7), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::Addx(-33), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(2), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(8), + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(2), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(17), + Instruction::Addx(-9), + Instruction::Addx(1), + Instruction::Addx(1), + Instruction::Addx(-3), + Instruction::Addx(11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-13), + Instruction::Addx(-19), + Instruction::Addx(1), + Instruction::Addx(3), + Instruction::Addx(26), + Instruction::Addx(-30), + Instruction::Addx(12), + Instruction::Addx(-1), + Instruction::Addx(3), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-9), + Instruction::Addx(18), + Instruction::Addx(1), + Instruction::Addx(2), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(9), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(2), + Instruction::Addx(-37), + Instruction::Addx(1), + Instruction::Addx(3), + Instruction::NoOp, + Instruction::Addx(15), + Instruction::Addx(-21), + Instruction::Addx(22), + Instruction::Addx(-6), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(2), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(-10), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(20), + Instruction::Addx(1), + Instruction::Addx(2), + Instruction::Addx(2), + Instruction::Addx(-6), + Instruction::Addx(-11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp + ] + ); + } +} diff --git a/days/day10/src/part1.rs b/days/day10/src/part1.rs new file mode 100644 index 0000000..d69856c --- /dev/null +++ b/days/day10/src/part1.rs @@ -0,0 +1,191 @@ +use std::collections::VecDeque; + +use crate::{parse::*, machine::Machine}; + +pub fn part1(input: VecDeque) -> i32 { + let mut machine = Machine::load_program(input.into()); + let mut total = 0; + + //20th + total+=machine.step20(); + + machine.step20(); + //60th + total+=machine.step20(); + + machine.step20(); + //100th + total+=machine.step20(); + + machine.step20(); + //140th + total+=machine.step20(); + + machine.step20(); + //180th + total+=machine.step20(); + + machine.step20(); + //220th + total+=machine.step20(); + + total +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_part1() { + let input = vec![ + Instruction::Addx(15), + Instruction::Addx(-11), + Instruction::Addx(6), + Instruction::Addx(-3), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(-8), + Instruction::Addx(13), + Instruction::Addx(4), + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(5), + Instruction::Addx(-1), + Instruction::Addx(-35), + Instruction::Addx(1), + Instruction::Addx(24), + Instruction::Addx(-19), + Instruction::Addx(1), + Instruction::Addx(16), + Instruction::Addx(-11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(21), + Instruction::Addx(-15), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-3), + Instruction::Addx(9), + Instruction::Addx(1), + Instruction::Addx(-3), + Instruction::Addx(8), + Instruction::Addx(1), + Instruction::Addx(5), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-36), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::Addx(7), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(2), + Instruction::Addx(6), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(7), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(-13), + Instruction::Addx(13), + Instruction::Addx(7), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::Addx(-33), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(2), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(8), + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(2), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(17), + Instruction::Addx(-9), + Instruction::Addx(1), + Instruction::Addx(1), + Instruction::Addx(-3), + Instruction::Addx(11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-13), + Instruction::Addx(-19), + Instruction::Addx(1), + Instruction::Addx(3), + Instruction::Addx(26), + Instruction::Addx(-30), + Instruction::Addx(12), + Instruction::Addx(-1), + Instruction::Addx(3), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-9), + Instruction::Addx(18), + Instruction::Addx(1), + Instruction::Addx(2), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(9), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(-1), + Instruction::Addx(2), + Instruction::Addx(-37), + Instruction::Addx(1), + Instruction::Addx(3), + Instruction::NoOp, + Instruction::Addx(15), + Instruction::Addx(-21), + Instruction::Addx(22), + Instruction::Addx(-6), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(2), + Instruction::Addx(1), + Instruction::NoOp, + Instruction::Addx(-10), + Instruction::NoOp, + Instruction::NoOp, + Instruction::Addx(20), + Instruction::Addx(1), + Instruction::Addx(2), + Instruction::Addx(2), + Instruction::Addx(-6), + Instruction::Addx(-11), + Instruction::NoOp, + Instruction::NoOp, + Instruction::NoOp, + ]; + assert_eq!(part1(input.into()), 13140) + } +} diff --git a/days/day10/src/part2.rs b/days/day10/src/part2.rs new file mode 100644 index 0000000..419e697 --- /dev/null +++ b/days/day10/src/part2.rs @@ -0,0 +1,15 @@ +use crate::parse::*; + +pub fn part2() -> usize { + unimplemented!() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_part2() { + assert_eq!(0, 0); + } +} diff --git a/template/Cargo.toml b/template/Cargo.toml index 987a9a3..801326a 100644 --- a/template/Cargo.toml +++ b/template/Cargo.toml @@ -4,3 +4,6 @@ authors.workspace = true description.workspace = true version.workspace = true edition.workspace = true + +[dependencies] +aoc_libs.workspace = true diff --git a/template/src/main.rs b/template/src/main.rs index bae4d49..e282b24 100644 --- a/template/src/main.rs +++ b/template/src/main.rs @@ -1,12 +1,10 @@ -//TODO: -#![allow(dead_code)] mod part1; mod part2; -mod utilities; +mod parse; fn main() { let input = include_str!("./input.txt"); - let structured_input = utilities::parse(input); + let structured_input = parse::parse(input); println!("Part One"); println!("Result: {}", part1::part1()); diff --git a/template/src/utilities.rs b/template/src/parse.rs similarity index 75% rename from template/src/utilities.rs rename to template/src/parse.rs index 1cf38f6..29de48b 100644 --- a/template/src/utilities.rs +++ b/template/src/parse.rs @@ -1,5 +1,3 @@ -//TODO: -#![allow(unused)] pub fn parse(input: &str) -> usize { unimplemented!() } @@ -10,9 +8,7 @@ mod tests { #[test] fn test_parse() { - let input = -"test" -; + let input = concat!(); assert_eq!(0, 0); } } diff --git a/template/src/part1.rs b/template/src/part1.rs index ac3e084..dd46fd2 100644 --- a/template/src/part1.rs +++ b/template/src/part1.rs @@ -1,7 +1,4 @@ -//TODO: -#![allow(unused)] -use crate::utilities::*; - +use crate::parse::* pub fn part1() -> usize { unimplemented!() } diff --git a/template/src/part2.rs b/template/src/part2.rs index 6f1cd6c..6d129e2 100644 --- a/template/src/part2.rs +++ b/template/src/part2.rs @@ -1,6 +1,4 @@ -//TODO: -#![allow(unused)] -use crate::utilities::*; +use crate::parse::* pub fn part2() -> usize { unimplemented!()