-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-day.sh
executable file
·58 lines (44 loc) · 983 Bytes
/
start-day.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -eo pipefail
day=$1
if [[ -z $day ]]; then
echo "No day argument supplied" >&2
exit 1
fi
# make sure repo is up to date
git pull
cargo aoc input -d $day -y 2016
# create solution
cat > src/day$day.rs <<EOF
use aoc_runner_derive::{aoc, aoc_generator};
//#[aoc_generator(day$day)]
//pub fn generator(input: &str) -> Vec<_> {
// todo!()
//}
#[aoc(day$day, part1)]
pub fn part1(input: &str) -> usize {
todo!()
}
#[aoc(day$day, part2)]
pub fn part2(input: &str) -> usize {
todo!()
}
#[cfg(test)]
mod tests {
use super::*;
static INPUT: &str = include_str!("../input/2016/day$day.txt");
#[test]
fn test_part1() {
assert_eq!(part1(INPUT), 0);
}
#[test]
fn test_part2() {
assert_eq!(part2(INPUT), 0);
}
}
EOF
sed -i "s/aoc_lib! { year = 2016 }/mod day$day;\naoc_lib! { year = 2016 }/" src/lib.rs
cargo fmt
# start VS and the web page
start https://adventofcode.com/2016/day/$day
code .