2024
This commit is contained in:
parent
294c0a8e62
commit
e1ca0d5f61
76 changed files with 4607 additions and 204 deletions
48
src/main.rs
48
src/main.rs
|
|
@ -1,20 +1,50 @@
|
|||
use shared::Solution;
|
||||
mod solution;
|
||||
use solution::solution;
|
||||
|
||||
use shared::load_actual;
|
||||
mod input_data;
|
||||
use input_data::load_actual;
|
||||
|
||||
use std::time::Instant;
|
||||
use reqwest::blocking::Client;
|
||||
use reqwest::header::COOKIE;
|
||||
|
||||
use std::{time::Instant, env};
|
||||
|
||||
fn main() {
|
||||
let year = 2024;
|
||||
let day = 2;
|
||||
|
||||
let Ok(data) = load_actual(year, day)
|
||||
else { panic!("No Input Data"); };
|
||||
|
||||
let now = Instant::now();
|
||||
|
||||
let Ok(data) = load_actual(2023, 12)
|
||||
else { panic!("No Input Data"); };
|
||||
let part1 = solution(&data, year, day, 1).unwrap();
|
||||
|
||||
let result = aoc2023::day12::Day12.part_2(&data);
|
||||
let elapsed1 = now.elapsed();
|
||||
|
||||
let elapsed = now.elapsed();
|
||||
let now = Instant::now();
|
||||
|
||||
let part2 = solution(&data, year, day, 2).unwrap();
|
||||
|
||||
println!("{}", result);
|
||||
let elapsed2 = now.elapsed();
|
||||
|
||||
println!("Part 1 result is {}, took {}ms", part1, elapsed1.as_millis());
|
||||
println!("Part 2 result is {}, took {}ms", part2, elapsed2.as_millis());
|
||||
|
||||
println!("{:?}", elapsed);
|
||||
}
|
||||
|
||||
fn fetch_data(year, day) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let url = format!("https://adventofcode.com/{year}/day/{day}/input");
|
||||
let session_cookie = env::var("ADVENT_TOKEN")?;
|
||||
|
||||
let client = Client::new();
|
||||
let response = client
|
||||
.get(url)
|
||||
.header(COOKIE, session_cookie)
|
||||
.send()?;
|
||||
|
||||
let body = response.text()?;
|
||||
println!("Response: {}", body);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue