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
|
use std::collections::BTreeMap;
use std::env;
fn main() {
let mut puzzle_solutions: BTreeMap<&str, fn()> = BTreeMap::new();
puzzle_solutions.insert("2018::day1::part1", advent_of_code::year_2018::day1::part1);
puzzle_solutions.insert("2018::day1::part2", advent_of_code::year_2018::day1::part2);
puzzle_solutions.insert("2018::day2::part1", advent_of_code::year_2018::day2::part1);
puzzle_solutions.insert("2018::day2::part2", advent_of_code::year_2018::day2::part2);
puzzle_solutions.insert("2018::day3::part1", advent_of_code::year_2018::day3::part1);
puzzle_solutions.insert("2018::day3::part2", advent_of_code::year_2018::day3::part2);
puzzle_solutions.insert("2018::day4::part1", advent_of_code::year_2018::day4::part1);
puzzle_solutions.insert("2018::day4::part2", advent_of_code::year_2018::day4::part2);
puzzle_solutions.insert("2018::day5::part1", advent_of_code::year_2018::day5::part1);
puzzle_solutions.insert("2018::day5::part2", advent_of_code::year_2018::day5::part2);
puzzle_solutions.insert("2018::day6::part1", advent_of_code::year_2018::day6::part1);
puzzle_solutions.insert("2018::day6::part2", advent_of_code::year_2018::day6::part2);
puzzle_solutions.insert("2018::day7::part1", advent_of_code::year_2018::day7::part1);
puzzle_solutions.insert("2018::day7::part2", advent_of_code::year_2018::day7::part2);
puzzle_solutions.insert("2019::day1::part1", advent_of_code::year_2019::day1::part1);
puzzle_solutions.insert("2019::day1::part2", advent_of_code::year_2019::day1::part2);
puzzle_solutions.insert("2019::day2::part1", advent_of_code::year_2019::day2::part1);
puzzle_solutions.insert("2019::day2::part2", advent_of_code::year_2019::day2::part2);
puzzle_solutions.insert("2019::day3::part1", advent_of_code::year_2019::day3::part1);
puzzle_solutions.insert("2019::day3::part2", advent_of_code::year_2019::day3::part2);
puzzle_solutions.insert("2019::day4::part1", advent_of_code::year_2019::day4::part1);
puzzle_solutions.insert("2019::day4::part2", advent_of_code::year_2019::day4::part2);
puzzle_solutions.insert("2019::day5::part1", advent_of_code::year_2019::day5::part1);
puzzle_solutions.insert("2019::day5::part2", advent_of_code::year_2019::day5::part2);
puzzle_solutions.insert("2019::day6::part1", advent_of_code::year_2019::day6::part1);
puzzle_solutions.insert("2019::day6::part2", advent_of_code::year_2019::day6::part2);
puzzle_solutions.insert("2019::day7::part1", advent_of_code::year_2019::day7::part1);
puzzle_solutions.insert("2019::day7::part2", advent_of_code::year_2019::day7::part2);
puzzle_solutions.insert("2019::day8::part1", advent_of_code::year_2019::day8::part1);
puzzle_solutions.insert("2019::day8::part2", advent_of_code::year_2019::day8::part2);
puzzle_solutions.insert("2019::day9::part1", advent_of_code::year_2019::day9::part1);
puzzle_solutions.insert("2019::day9::part2", advent_of_code::year_2019::day9::part2);
puzzle_solutions.insert(
"2019::day10::part1",
advent_of_code::year_2019::day10::part1,
);
let command = match env::args().nth(1) {
Some(command) => command,
None => {
eprintln!(
"Usage: advent-of-code <command>\n\nCommands:\n\tlist{}",
puzzle_solutions
.keys()
.map(|key| format!("\n\t{}", key))
.collect::<String>()
);
std::process::exit(1);
}
};
match command.as_str() {
"list" => {
for puzzle_solution in puzzle_solutions.keys() {
println!("{}", puzzle_solution);
}
std::process::exit(1);
}
puzzle_solution => match puzzle_solutions.get(puzzle_solution) {
Some(puzzle_solution_fn) => puzzle_solution_fn(),
None => {
eprintln!("Puzzle solution '{}' not found", puzzle_solution);
std::process::exit(1);
}
},
}
}
|