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
|
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,19 +11,21 @@ use std::{path::Path, time::Instant, env};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let year = env::var("ADVENT_YEAR")
|
let year = env::var("ADVENT_YEAR")
|
||||||
.unwrap()
|
.unwrap_or("2024".into())
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap_or(2024);
|
.unwrap();
|
||||||
let day = env::var("ADVENT_DAY")
|
let day = env::var("ADVENT_DAY")
|
||||||
.unwrap()
|
.unwrap_or("1".into())
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap_or(1);
|
.unwrap();
|
||||||
|
|
||||||
if ! Path::new(&format!("./data/{}/day{:02}", year, day)).exists()
|
if ! Path::new(&format!("./data/{}/day{:02}", year, day)).exists()
|
||||||
&& env::var("ADVENT_TOKEN").is_ok() {
|
&& env::var("ADVENT_TOKEN").is_ok() {
|
||||||
fetch_input(year, day).expect("Set ADVENT_TOKEN to the correct session cookie to fetch input automatically");
|
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)
|
let Ok(data) = load_actual(year, day)
|
||||||
else { panic!("No Input Data"); };
|
else { panic!("No Input Data"); };
|
||||||
|
|
||||||
|
|
@ -41,5 +43,4 @@ fn main() {
|
||||||
|
|
||||||
println!("Part 1 result is {}, took {}ms", part1, elapsed1.as_millis());
|
println!("Part 1 result is {}, took {}ms", part1, elapsed1.as_millis());
|
||||||
println!("Part 2 result is {}, took {}ms", part2, elapsed2.as_millis());
|
println!("Part 2 result is {}, took {}ms", part2, elapsed2.as_millis());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue