Merge branch 'main' into feat/solve-submit
This commit is contained in:
commit
3ea6e7ca17
6 changed files with 21 additions and 24 deletions
|
@ -165,7 +165,7 @@ To read inputs for previous years, append the `--year/-y` flag. _(example: `carg
|
|||
1. Install [`aoc-cli`](https://github.com/scarvalhojr/aoc-cli/) via cargo: `cargo install aoc-cli --version 0.7.0`
|
||||
2. Create an `.adventofcode.session` file in your home directory and paste your session cookie[^1] into it. To get this, press F12 anywhere on the Advent of Code website to open your browser developer tools. Look in your Cookies under the Application or Storage tab, and copy out the `session` cookie value.
|
||||
|
||||
Once installed, you can use the [download command](#download-input-for-a-day).
|
||||
Once installed, you can use the [download command](#download-input--description-for-a-day).
|
||||
|
||||
### Check code formatting in CI
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ fn main() {
|
|||
let args = match parse_args() {
|
||||
Ok(args) => args,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to process arguments: {}", e);
|
||||
eprintln!("Failed to process arguments: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("failed to spawn aoc-cli: {}", e);
|
||||
eprintln!("failed to spawn aoc-cli: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ fn main() {
|
|||
let args = match parse_args() {
|
||||
Ok(args) => args,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to process arguments: {}", e);
|
||||
eprintln!("Failed to process arguments: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("failed to spawn aoc-cli: {}", e);
|
||||
eprintln!("failed to spawn aoc-cli: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,16 +62,16 @@ fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
let day_padded = format!("{:02}", day);
|
||||
let day_padded = format!("{day:02}");
|
||||
|
||||
let input_path = format!("src/inputs/{}.txt", day_padded);
|
||||
let example_path = format!("src/examples/{}.txt", day_padded);
|
||||
let module_path = format!("src/bin/{}.rs", day_padded);
|
||||
let input_path = format!("src/inputs/{day_padded}.txt");
|
||||
let example_path = format!("src/examples/{day_padded}.txt");
|
||||
let module_path = format!("src/bin/{day_padded}.rs");
|
||||
|
||||
let mut file = match safe_create_file(&module_path) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to create module file: {}", e);
|
||||
eprintln!("Failed to create module file: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
@ -81,7 +81,7 @@ fn main() {
|
|||
println!("Created module file \"{}\"", &module_path);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to write module contents: {}", e);
|
||||
eprintln!("Failed to write module contents: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ fn main() {
|
|||
println!("Created empty input file \"{}\"", &input_path);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to create input file: {}", e);
|
||||
eprintln!("Failed to create input file: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ fn main() {
|
|||
println!("Created empty example file \"{}\"", &example_path);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to create example file: {}", e);
|
||||
eprintln!("Failed to create example file: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -77,7 +77,7 @@ macro_rules! solve {
|
|||
pub fn read_file(folder: &str, day: u8) -> String {
|
||||
let cwd = env::current_dir().unwrap();
|
||||
|
||||
let filepath = cwd.join("src").join(folder).join(format!("{:02}.txt", day));
|
||||
let filepath = cwd.join("src").join(folder).join(format!("{day:02}.txt"));
|
||||
|
||||
let f = fs::read_to_string(filepath);
|
||||
f.expect("could not open input file")
|
||||
|
@ -246,13 +246,13 @@ pub mod aoc_cli {
|
|||
}
|
||||
|
||||
fn get_input_path(day: u8) -> String {
|
||||
let day_padded = format!("{:02}", day);
|
||||
format!("src/inputs/{}.txt", day_padded)
|
||||
let day_padded = format!("{day:02}");
|
||||
format!("src/inputs/{day_padded}.txt")
|
||||
}
|
||||
|
||||
fn get_puzzle_path(day: u8) -> String {
|
||||
let day_padded = format!("{:02}", day);
|
||||
format!("src/puzzles/{}.md", day_padded)
|
||||
let day_padded = format!("{day:02}");
|
||||
format!("src/puzzles/{day_padded}.md")
|
||||
}
|
||||
|
||||
fn get_year() -> Option<u16> {
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::process::Command;
|
|||
fn main() {
|
||||
let total: f64 = (1..=25)
|
||||
.map(|day| {
|
||||
let day = format!("{:02}", day);
|
||||
let day = format!("{day:02}");
|
||||
|
||||
let mut args = vec!["run", "--bin", &day];
|
||||
if cfg!(not(debug_assertions)) {
|
||||
|
@ -18,7 +18,7 @@ fn main() {
|
|||
let cmd = Command::new("cargo").args(&args).output().unwrap();
|
||||
|
||||
println!("----------");
|
||||
println!("{}| Day {} |{}", ANSI_BOLD, day, ANSI_RESET);
|
||||
println!("{ANSI_BOLD}| Day {day} |{ANSI_RESET}");
|
||||
println!("----------");
|
||||
|
||||
let output = String::from_utf8(cmd.stdout).unwrap();
|
||||
|
@ -41,8 +41,5 @@ fn main() {
|
|||
})
|
||||
.sum();
|
||||
|
||||
println!(
|
||||
"{}Total:{} {}{:.2}ms{}",
|
||||
ANSI_BOLD, ANSI_RESET, ANSI_ITALIC, total, ANSI_RESET
|
||||
);
|
||||
println!("{ANSI_BOLD}Total:{ANSI_RESET} {ANSI_ITALIC}{total:.2}ms{ANSI_RESET}");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue