mirror of
https://github.com/Noratrieb/advent-of-code.git
synced 2026-01-14 17:45:02 +01:00
script
This commit is contained in:
parent
8ffd71c2d1
commit
56f39b5c3c
11 changed files with 120 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
||||||
target
|
target
|
||||||
perf.data*
|
perf.data*
|
||||||
|
aoc_cookie
|
||||||
|
|
|
||||||
15
2023/day00/Cargo.toml
Normal file
15
2023/day00/Cargo.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
[package]
|
||||||
|
name = "day00"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
nom.workspace = true
|
||||||
|
helper.workspace = true
|
||||||
|
divan.workspace = true
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "benches"
|
||||||
|
harness = false
|
||||||
3
2023/day00/benches/benches.rs
Normal file
3
2023/day00/benches/benches.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
day00::bench();
|
||||||
|
}
|
||||||
0
2023/day00/input.txt
Normal file
0
2023/day00/input.txt
Normal file
0
2023/day00/input_small.txt
Normal file
0
2023/day00/input_small.txt
Normal file
48
2023/day00/src/lib.rs
Normal file
48
2023/day00/src/lib.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
use helper::{Day, Variants};
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
helper::main::<Day00>(include_str!("../input.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Day00;
|
||||||
|
|
||||||
|
helper::define_variants! {
|
||||||
|
day => crate::Day00;
|
||||||
|
part1 {
|
||||||
|
basic => crate::part1;
|
||||||
|
}
|
||||||
|
part2 {
|
||||||
|
basic => crate::part2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Day for Day00 {
|
||||||
|
fn part1() -> Variants {
|
||||||
|
part1_variants!(construct_variants)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2() -> Variants {
|
||||||
|
part2_variants!(construct_variants)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part1(_input: &str) -> u64 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn part2(_input: &str) -> u64 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
helper::tests! {
|
||||||
|
day00 Day00;
|
||||||
|
part1 {
|
||||||
|
small => 8;
|
||||||
|
default => 1931;
|
||||||
|
}
|
||||||
|
part2 {
|
||||||
|
small => 2286;
|
||||||
|
default => 83105;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
helper::benchmarks! {}
|
||||||
3
2023/day00/src/main.rs
Normal file
3
2023/day00/src/main.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
day00::main();
|
||||||
|
}
|
||||||
|
|
@ -24,5 +24,5 @@ pub fn part2(input: &str) -> u64 {
|
||||||
})
|
})
|
||||||
.sum::<u64>();
|
.sum::<u64>();
|
||||||
|
|
||||||
sum
|
sum
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,5 +39,5 @@ pub fn part2(input: &str) -> u64 {
|
||||||
})
|
})
|
||||||
.sum::<u64>();
|
.sum::<u64>();
|
||||||
|
|
||||||
sum
|
sum
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
Cargo.lock
generated
18
Cargo.lock
generated
|
|
@ -96,6 +96,15 @@ version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af"
|
checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day00"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"divan",
|
||||||
|
"helper",
|
||||||
|
"nom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "day01"
|
name = "day01"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -122,6 +131,15 @@ dependencies = [
|
||||||
"nom",
|
"nom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day04"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"divan",
|
||||||
|
"helper",
|
||||||
|
"nom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "divan"
|
name = "divan"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
|
|
|
||||||
27
aoc.sh
Executable file
27
aoc.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
function get_cookie {
|
||||||
|
if [ ! -f aoc_cookie ]; then
|
||||||
|
echo "aoc_cookie file not found, cannot download" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cat aoc_cookie
|
||||||
|
}
|
||||||
|
|
||||||
|
: "${1:?usage: ./aoc.sh new}"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
new)
|
||||||
|
: "${2:?usage: ./aoc.sh new DAY}"
|
||||||
|
day="$(printf %02d "$2")"
|
||||||
|
cp -r "2023/day00" "2023/day$day"
|
||||||
|
find "2023/day$day" -type f -exec sed -i -e "s/00/$day/g" {} \;
|
||||||
|
|
||||||
|
curl -H "Cookie: $(get_cookie)" "https://adventofcode.com/2023/day/$2/input" -o "2023/day$day/input.txt"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: ./aoc.sh new" >&2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Loading…
Add table
Add a link
Reference in a new issue