-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-day
executable file
·94 lines (74 loc) · 1.83 KB
/
setup-day
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
if [ $# != 1 ]; then
echo "Usage: $(basename "$0") <day-number>" >&2
exit 1
fi
#if [ ! -d .git ]; then
# echo "must be run from root of advent-of-code repository" >&2
# exit 1
#fi
name="$(printf "aoc%02d" "$1")"
cargo new --bin "$name"
mkdir "$name/input"
touch "$name/input/input.txt"
# write template to source file
cat >"$name/src/main.rs" <<EOM
use std::error::Error;
use std::io::{self, Read, Write};
use std::time::Instant;
#[allow(unused_macros)]
macro_rules! err {
(\$(\$tt:tt)*) => { Err(Box::<dyn Error>::from(format!(\$(\$tt)*))) }
}
type Result<T> = ::std::result::Result<T, Box<dyn Error>>;
fn part1() -> Result<()> {
let _start = Instant::now();
writeln!(io::stdout(), "> Time elapsed is: {:?}", _start.elapsed())?;
todo!()
}
fn main() -> Result<()>{
let mut input = String::new();
io::stdin().read_to_string(&mut input)?;
// part1()?;
// part2()?;
Ok(())
}
#[test]
fn example_input() {
assert_eq!(1, 1);
}
#[test]
fn real_input() {
let input = std::fs::read_to_string("input/input.txt").unwrap();
assert_eq!(2, 2);
}
EOM
# template
# use std::error::Error;
# use std::io::{self, Read, Write};
# macro_rules! err {
# ($($tt:tt)*) => { Err(Box::<dyn Error>::from(format!($($tt)*))) }
# }
# type Result<T> = ::std::result::Result<T, Box<dyn Error>>;
# fn part1() -> Result<()> {
# let _start = Instant::now();
# writeln!(io::stdout(), "> Time elapsed is: {:?}", _start.elapsed())?;
# todo!()
# }
# fn main() -> Result<()>{
# let mut input = String::new();
# io::stdin().read_to_string(&mut input)?;
# // part1()?;
# // part2()?;
# Ok(())
# }
#
# #[test]
# fn example_input() {
# assert_eq!(1, 1);
# }
# #[test]
# fn real_input() {
# let input = std::fs::read_to_string("input/input.txt").unwrap();
# assert_eq!(2, 2);
# }