mirror of
https://github.com/Noratrieb/advent-of-code.git
synced 2026-01-14 17:45:02 +01:00
start 5
This commit is contained in:
parent
605c03b4a6
commit
a2e35b3fde
7 changed files with 1465 additions and 0 deletions
9
2024/Cargo.lock
generated
9
2024/Cargo.lock
generated
|
|
@ -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
15
2024/day05/Cargo.toml
Normal 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
|
||||
3
2024/day05/benches/benches.rs
Normal file
3
2024/day05/benches/benches.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
day05::bench();
|
||||
}
|
||||
1368
2024/day05/input.txt
Normal file
1368
2024/day05/input.txt
Normal file
File diff suppressed because it is too large
Load diff
0
2024/day05/input_small.txt
Normal file
0
2024/day05/input_small.txt
Normal file
67
2024/day05/src/lib.rs
Normal file
67
2024/day05/src/lib.rs
Normal 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
3
2024/day05/src/main.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
day05::main();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue