This commit is contained in:
nora 2024-12-06 19:19:03 +01:00
parent 605c03b4a6
commit a2e35b3fde
7 changed files with 1465 additions and 0 deletions

9
2024/Cargo.lock generated
View file

@ -151,6 +151,15 @@ dependencies = [
"nom",
]
[[package]]
name = "day05"
version = "0.1.0"
dependencies = [
"divan",
"helper",
"nom",
]
[[package]]
name = "divan"
version = "0.1.16"

15
2024/day05/Cargo.toml Normal file
View file

@ -0,0 +1,15 @@
[package]
name = "day05"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nom.workspace = true
helper.workspace = true
divan.workspace = true
[[bench]]
name = "benches"
harness = false

View file

@ -0,0 +1,3 @@
fn main() {
day05::bench();
}

1368
2024/day05/input.txt Normal file

File diff suppressed because it is too large Load diff

View file

67
2024/day05/src/lib.rs Normal file
View file

@ -0,0 +1,67 @@
use helper::{parse_unwrap, Day, IteratorExt, Variants};
pub fn main() {
helper::main::<Day05>(include_str!("../input.txt"));
}
struct Day05;
helper::define_variants! {
day => crate::Day05;
part1 {
basic => crate::part1;
}
part2 {
basic => crate::part2;
}
}
impl Day for Day05 {
fn part1() -> Variants {
part1_variants!(construct_variants)
}
fn part2() -> Variants {
part2_variants!(construct_variants)
}
}
fn part1(input: &str) -> u64 {
let mut rules = Vec::new();
let mut updates = Vec::new();
let mut lines = input.lines();
while let Some(line) = lines.next() {
if line.is_empty() {
break;
}
let values = line
.split('|')
.collect_array::<2>()
.unwrap()
.map(parse_unwrap);
rules.push((values[0], values[1]));
}
while let Some(line) = lines.next() {
let numbers = line.split(",").map(parse_unwrap).collect::<Vec<_>>();
updates.push(numbers);
}
0
}
fn part2(_input: &str) -> u64 {
0
}
helper::tests! {
day05 Day05;
part1 {
small => 143;
default => 0;
}
part2 {
small => 0;
default => 0;
}
}
helper::benchmarks! {}

3
2024/day05/src/main.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
day05::main();
}