This is repository holds my solutions to the Advent of Code puzzles.
export AOC_SESSION=D34DBEEFbefore running to get input dynamically from AoC server. How to get session cookie.cd YYYY; cargo run 4runs justDay04.rscargo run allruns all dayscargo run --release allfor fastest benchmarkcargo test --docruns all testsAOC_RENDER=1 cargo run allto render visualizations (if implemented)
- 2025: Rust & more visualizations
- 2024: Rustaceans assemble! Focusing on faster solutions this year. Caching in rust feels quite clumsy compared to python's
@lru_cachedecorator. - 2023: Going with rust again!
- 2022: Using this as an opportunity to learn rust. I did use python on some of the puzzles where I was racing against colleagues. :D
use serde::{Deserialize,Serialize};#[derive(Serialize,Deserialize,Debug)]structPart{x:usize,m:usize,a:usize,s:usize,}// then laterlet json_line:&str = "{x=787,m=2655,a=1222,s=2876}";let some_part:Part = serde_json::from_str(&json_line).unwrap();// and it adds the debug print so you canprintln!("{:?}", some_part)let max = 777u64;use indicatif::{ProgressBar,ProgressStyle};let progress = ProgressBar::new(max);
progress.set_style(ProgressStyle::with_template("{bar:40.cyan/blue} {pos:>9}/{len:9} [{eta} left] {msg}",).unwrap(),);
progress.set_message("finding repeating sequence...");for idx in0..max {// do something
progress.set_position(idx asu64);}
progress.finish_with_message("Done");use rayon::prelude::*;use std::sync::atomic::{AtomicUsize,Ordering};
acc = AtomicUsize::new(0);
lines.par_iter().for_each(|line| {// do something
acc.fetch_add(1,Ordering::Relaxed);})let final_acc = acc.load(Ordering::Relaxed);libsslneeded for aoc input fetchffmpegneeded for animated GIFs (2024 day14)
apt install libssl-dev ffmpeg




