[Rust/2023] Add year bin
This commit is contained in:
parent
ce8e847394
commit
b7225546b5
6 changed files with 66 additions and 4 deletions
|
@ -67,7 +67,7 @@ fn solve<const N: usize>(input: &Input) -> usize {
|
|||
.iter()
|
||||
.map(|grid| {
|
||||
Reflection::generate_for(grid)
|
||||
.find(|reflection| dbg!(reflection.count_mismatches(grid)) == N)
|
||||
.find(|reflection| reflection.count_mismatches(grid) == N)
|
||||
.unwrap()
|
||||
.summarize()
|
||||
})
|
||||
|
|
|
@ -57,7 +57,7 @@ fn part2(input: &Input) -> usize {
|
|||
};
|
||||
}
|
||||
|
||||
dbg!(boxes)
|
||||
boxes
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.flat_map(|(i, bx)| {
|
||||
|
|
29
Rust/2023/main.rs
Normal file
29
Rust/2023/main.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#![feature(isqrt, iter_intersperse)]
|
||||
|
||||
aoc::year! {
|
||||
"01.rs",
|
||||
"02.rs",
|
||||
"03.rs",
|
||||
"04.rs",
|
||||
"05.rs",
|
||||
"06.rs",
|
||||
"07.rs",
|
||||
"08.rs",
|
||||
"09.rs",
|
||||
"10.rs",
|
||||
"11.rs",
|
||||
"12.rs",
|
||||
"13.rs",
|
||||
"14.rs",
|
||||
"15.rs",
|
||||
"16.rs",
|
||||
"17.rs",
|
||||
"18.rs",
|
||||
"19.rs",
|
||||
"20.rs",
|
||||
"21.rs",
|
||||
"22.rs",
|
||||
"23.rs",
|
||||
"24.rs",
|
||||
"25.rs",
|
||||
}
|
|
@ -227,6 +227,9 @@ path = "2022/25.rs"
|
|||
|
||||
# 2023
|
||||
[[bin]]
|
||||
name = "2023"
|
||||
path = "2023/main.rs"
|
||||
[[bin]]
|
||||
name = "2023_01"
|
||||
path = "2023/01.rs"
|
||||
[[bin]]
|
||||
|
|
|
@ -2,6 +2,7 @@ alias e := example
|
|||
alias r := run
|
||||
alias t := test
|
||||
alias b := bench
|
||||
alias y := year
|
||||
alias ty := test-year
|
||||
alias by := bench-year
|
||||
alias ta := test-all
|
||||
|
@ -27,6 +28,9 @@ test year day *args:
|
|||
bench year day *args:
|
||||
cargo bench --bin {{year}}_{{day}} {{args}}
|
||||
|
||||
year year *args:
|
||||
cargo run --bin {{year}} {{args}}
|
||||
|
||||
test-year year *args:
|
||||
cargo test --bin '{{year}}_*' {{args}}
|
||||
|
||||
|
@ -49,5 +53,5 @@ hyperfine-example year day ex *args: (build year day)
|
|||
hyperfine {{args}} '{{target}}/release/{{year}}_{{day}} ../examples/{{year}}/{{trim_start_match(day, "0")}}/{{ex}}'
|
||||
|
||||
hyperfine-year year *args:
|
||||
cargo build --release --bin '{{year}}_*'
|
||||
hyperfine {{args}} {{target}}/release/{{year}}_??
|
||||
cargo build --release --bin {{year}}
|
||||
hyperfine {{args}} {{target}}/release/{{year}}
|
||||
|
|
|
@ -28,6 +28,21 @@ macro_rules! main {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! year {
|
||||
($($path:tt),*$(,)?) => {
|
||||
#[cfg(not(test))]
|
||||
fn main() {
|
||||
$({
|
||||
#[path = $path]
|
||||
#[allow(unused_attributes)]
|
||||
mod day;
|
||||
day::_main();
|
||||
})*
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! __ifnot25 {
|
||||
|
@ -52,6 +67,17 @@ macro_rules! __main {
|
|||
::std::println!("{}", part2(&input));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _main() {
|
||||
let path = ::std::concat!("../.cache/", $year, "/", $day);
|
||||
let input = ::std::fs::read_to_string(path).unwrap();
|
||||
let input = setup(&input);
|
||||
::std::print!("[{}/{:02}/1] {:<20}", $year, $day, part1(&input));
|
||||
::aoc::__ifnot25! { $day,
|
||||
::std::print!("[{}/{:02}/2] {}", $year, $day, part2(&input));
|
||||
}
|
||||
::std::println!();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue