2024 day-3 pre setup
This commit is contained in:
23
2024/day-3/Cargo.toml
Normal file
23
2024/day-3/Cargo.toml
Normal file
@@ -0,0 +1,23 @@
|
||||
[package]
|
||||
name = "day-3"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
[dependencies]
|
||||
nom.workspace = true
|
||||
itertools.workspace = true
|
||||
log.workspace = true
|
||||
error-stack.workspace = true
|
||||
thiserror.workspace = true
|
||||
dhat.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
test-log.workspace = true
|
||||
|
||||
[features]
|
||||
dhat-heap = []
|
||||
4
2024/day-3/src/lib.rs
Normal file
4
2024/day-3/src/lib.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
pub mod part1;
|
||||
pub use crate::part1::*;
|
||||
pub mod part2;
|
||||
pub use crate::part2::*;
|
||||
31
2024/day-3/src/main.rs
Normal file
31
2024/day-3/src/main.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
|
||||
use day_3::part1;
|
||||
use day_3::part2;
|
||||
|
||||
use error_stack::{Result, ResultExt};
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "dhat-heap")]
|
||||
#[global_allocator]
|
||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
enum Day3Error {
|
||||
#[error("Part 1 failed")]
|
||||
Part1Error,
|
||||
#[error("Part 2 failed")]
|
||||
Part2Error,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Day3Error> {
|
||||
#[cfg(feature = "dhat-heap")]
|
||||
let _profiler = dhat::Profiler::new_heap();
|
||||
|
||||
let input = include_str!("./input.txt");
|
||||
let part1_result = part1(input).change_context(Day3Error::Part1Error)?;
|
||||
println!("part 1: {part1_result}");
|
||||
let part2_result = part2(input).change_context(Day3Error::Part2Error)?;
|
||||
println!("part 2: {part2_result}");
|
||||
Ok(())
|
||||
}
|
||||
30
2024/day-3/src/part1.rs
Normal file
30
2024/day-3/src/part1.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
|
||||
use error_stack::Result;
|
||||
use thiserror::Error;
|
||||
|
||||
// day-3
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Day3Part1Error{
|
||||
#[error("Problem parsing Day 3")]
|
||||
ParseError,
|
||||
}
|
||||
|
||||
pub fn part1 (_input: &str) -> Result<String, Day3Part1Error> {
|
||||
Ok("Not Finished".to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
const INPUT: &str = "";
|
||||
|
||||
#[test_log::test]
|
||||
#[test_log(default_log_filter = "trace")]
|
||||
fn part1_works() {
|
||||
let result = part1(INPUT).unwrap();
|
||||
assert_eq!(result, "Not Finished".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
30
2024/day-3/src/part2.rs
Normal file
30
2024/day-3/src/part2.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
|
||||
use error_stack::Result;
|
||||
use thiserror::Error;
|
||||
|
||||
// day-3
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Day3Part2Error{
|
||||
#[error("Problem parsing Day 3")]
|
||||
ParseError,
|
||||
}
|
||||
|
||||
pub fn part2 (_input: &str) -> Result<String, Day3Part2Error> {
|
||||
Ok("Not Finished".to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
const INPUT: &str = "";
|
||||
|
||||
#[test_log::test]
|
||||
#[test_log(default_log_filter = "trace")]
|
||||
fn part2_works() {
|
||||
let result = part2(INPUT).unwrap();
|
||||
assert_eq!(result, "Not Finished".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user