Compare commits
No commits in common. "1531239f2005dfd8bc8536579eae6ae8baf790c1" and "a6405f2edb7b626696dc72da7e81176c304536c0" have entirely different histories.
1531239f20
...
a6405f2edb
|
@ -7,11 +7,11 @@
|
|||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in executable 'advent_of_code'",
|
||||
"name": "Debug unit tests in executable 'aoc'",
|
||||
"cargo": {
|
||||
"args": ["test", "--no-run", "--bin=advent_of_code", "--package=advent_of_code"],
|
||||
"args": ["test", "--no-run", "--bin=aoc", "--package=aoc"],
|
||||
"filter": {
|
||||
"name": "advent_of_code",
|
||||
"name": "aoc",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
|
@ -21,11 +21,11 @@
|
|||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug executable 'advent_of_code'",
|
||||
"name": "Debug executable 'aoc'",
|
||||
"cargo": {
|
||||
"args": ["build", "--bin=advent_of_code", "--package=advent_of_code"],
|
||||
"args": ["build", "--bin=aoc", "--package=aoc"],
|
||||
"filter": {
|
||||
"name": "advent_of_code",
|
||||
"name": "aoc",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
|
@ -35,11 +35,11 @@
|
|||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug unit tests in library 'advent_of_code'",
|
||||
"name": "Debug unit tests in library 'aoc'",
|
||||
"cargo": {
|
||||
"args": ["test", "--no-run", "--lib", "--package=advent_of_code"],
|
||||
"args": ["test", "--no-run", "--lib", "--package=aoc"],
|
||||
"filter": {
|
||||
"name": "advent_of_code",
|
||||
"name": "aoc",
|
||||
"kind": "lib"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "advent_of_code"
|
||||
version = "0.8.0"
|
||||
name = "aoc"
|
||||
version = "0.6.3"
|
||||
dependencies = [
|
||||
"pico-args",
|
||||
]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
name = "advent_of_code"
|
||||
version = "0.8.0"
|
||||
name = "aoc"
|
||||
version = "0.6.3"
|
||||
authors = ["Felix Spöttel <1682504+fspoettel@users.noreply.github.com>"]
|
||||
edition = "2021"
|
||||
default-run = "advent_of_code"
|
||||
default-run = "aoc"
|
||||
publish = false
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ Displayed _timings_ show the raw execution time of your solution without overhea
|
|||
cargo all
|
||||
|
||||
# output:
|
||||
# Running `target/release/advent_of_code`
|
||||
# Running `target/release/aoc`
|
||||
# ----------
|
||||
# | Day 01 |
|
||||
# ----------
|
||||
|
@ -141,7 +141,7 @@ cargo clippy
|
|||
|
||||
### Download puzzle inputs via aoc-cli
|
||||
|
||||
1. Install [`aoc-cli`](https://github.com/scarvalhojr/aoc-cli/) via cargo: `cargo install aoc-cli --version 0.5.0`.
|
||||
1. Install [`aoc-cli`](https://github.com/scarvalhojr/aoc-cli/) via cargo: `cargo install aoc-cli`.
|
||||
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).
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
pub fn part_one(input: &str) -> Option<u32> {
|
||||
let inlines = input.split("\n");
|
||||
let mut count: u32 = 0;
|
||||
let mut elves: Vec<u32> = vec![];
|
||||
for l in inlines {
|
||||
match l {
|
||||
"" => { elves.push(count); count = 0},
|
||||
_ => { count += l.parse::<u32>().unwrap() }
|
||||
}
|
||||
}
|
||||
|
||||
let mut largest = 0;
|
||||
|
||||
for e in elves {
|
||||
if e > largest {
|
||||
largest = e;
|
||||
}
|
||||
}
|
||||
|
||||
Some(largest)
|
||||
}
|
||||
|
||||
pub fn part_two(input: &str) -> Option<u32> {
|
||||
let inlines = input.split("\n");
|
||||
let mut count: u32 = 0;
|
||||
let mut elves: Vec<u32> = vec![];
|
||||
for l in inlines {
|
||||
match l {
|
||||
"" => { elves.push(count); count = 0},
|
||||
_ => { count += l.parse::<u32>().unwrap() }
|
||||
}
|
||||
}
|
||||
|
||||
elves.sort();
|
||||
elves.reverse();
|
||||
elves.truncate(3);
|
||||
|
||||
Some(elves.iter().sum::<u32>())
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let input = &advent_of_code::read_file("inputs", 1);
|
||||
advent_of_code::solve!(1, part_one, input);
|
||||
advent_of_code::solve!(2, part_two, input);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_part_one() {
|
||||
let input = advent_of_code::read_file("examples", 1);
|
||||
assert_eq!(part_one(&input), Some(24000));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_part_two() {
|
||||
let input = advent_of_code::read_file("examples", 1);
|
||||
assert_eq!(part_two(&input), None);
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ fn main() {
|
|||
}
|
||||
|
||||
cmd_args.append(&mut vec![
|
||||
"--input-file".into(),
|
||||
"--file".into(),
|
||||
tmp_file_path.to_string_lossy().to_string(),
|
||||
"--day".into(),
|
||||
args.day.to_string(),
|
||||
|
|
|
@ -17,9 +17,9 @@ pub fn part_two(input: &str) -> Option<u32> {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let input = &advent_of_code::read_file("inputs", DAY);
|
||||
advent_of_code::solve!(1, part_one, input);
|
||||
advent_of_code::solve!(2, part_two, input);
|
||||
let input = &aoc::read_file("inputs", DAY);
|
||||
aoc::solve!(1, part_one, input);
|
||||
aoc::solve!(2, part_two, input);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -28,13 +28,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_part_one() {
|
||||
let input = advent_of_code::read_file("examples", DAY);
|
||||
let input = aoc::read_file("examples", DAY);
|
||||
assert_eq!(part_one(&input), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_part_two() {
|
||||
let input = advent_of_code::read_file("examples", DAY);
|
||||
let input = aoc::read_file("examples", DAY);
|
||||
assert_eq!(part_two(&input), None);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
1000
|
||||
2000
|
||||
3000
|
||||
|
||||
4000
|
||||
|
||||
5000
|
||||
6000
|
||||
|
||||
7000
|
||||
8000
|
||||
9000
|
||||
|
||||
10000
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
* Use this file if you want to extract helpers from your solutions.
|
||||
* Example import from this file: `use advent_of_code::helpers::example_fn;`.
|
||||
* Example import from this file: `use aoc::helpers::example_fn;`.
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@ pub const ANSI_RESET: &str = "\x1b[0m";
|
|||
#[macro_export]
|
||||
macro_rules! solve {
|
||||
($part:expr, $solver:ident, $input:expr) => {{
|
||||
use advent_of_code::{ANSI_BOLD, ANSI_ITALIC, ANSI_RESET};
|
||||
use aoc::{ANSI_BOLD, ANSI_ITALIC, ANSI_RESET};
|
||||
use std::fmt::Display;
|
||||
use std::time::Instant;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file contains template code.
|
||||
* There is no need to edit this file unless you want to change template functionality.
|
||||
*/
|
||||
use advent_of_code::{ANSI_BOLD, ANSI_ITALIC, ANSI_RESET};
|
||||
use aoc::{ANSI_BOLD, ANSI_ITALIC, ANSI_RESET};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
|
@ -34,7 +34,7 @@ fn main() {
|
|||
if is_empty {
|
||||
0_f64
|
||||
} else {
|
||||
advent_of_code::parse_exec_time(&output)
|
||||
aoc::parse_exec_time(&output)
|
||||
}
|
||||
})
|
||||
.sum();
|
||||
|
|
Loading…
Reference in New Issue