main.rs
This commit is contained in:
parent
8d8fe53574
commit
19fe0a53ff
2 changed files with 12 additions and 5 deletions
6
.envrc
6
.envrc
|
|
@ -1 +1,7 @@
|
|||
use flake
|
||||
|
||||
if [[ $(date +'%m') -eq 12 ]]
|
||||
then
|
||||
export ADVENT_YEAR=$(date +'%Y')
|
||||
export ADVENT_DAY=$(date +'%d')
|
||||
fi
|
||||
|
|
|
|||
11
src/main.rs
11
src/main.rs
|
|
@ -11,18 +11,20 @@ use std::{path::Path, time::Instant, env};
|
|||
|
||||
fn main() {
|
||||
let year = env::var("ADVENT_YEAR")
|
||||
.unwrap()
|
||||
.unwrap_or("2024".into())
|
||||
.parse()
|
||||
.unwrap_or(2024);
|
||||
.unwrap();
|
||||
let day = env::var("ADVENT_DAY")
|
||||
.unwrap()
|
||||
.unwrap_or("1".into())
|
||||
.parse()
|
||||
.unwrap_or(1);
|
||||
.unwrap();
|
||||
|
||||
if ! Path::new(&format!("./data/{}/day{:02}", year, day)).exists()
|
||||
&& env::var("ADVENT_TOKEN").is_ok() {
|
||||
fetch_input(year, day).expect("Set ADVENT_TOKEN to the correct session cookie to fetch input automatically");
|
||||
}
|
||||
|
||||
println!("Attempting to run {year}/{day}");
|
||||
|
||||
let Ok(data) = load_actual(year, day)
|
||||
else { panic!("No Input Data"); };
|
||||
|
|
@ -41,5 +43,4 @@ fn main() {
|
|||
|
||||
println!("Part 1 result is {}, took {}ms", part1, elapsed1.as_millis());
|
||||
println!("Part 2 result is {}, took {}ms", part2, elapsed2.as_millis());
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue