advent-of-code-2023/lib/src/utils.rs

26 lines
689 B
Rust
Raw Normal View History

pub trait Day: std::fmt::Debug {
fn part1(&mut self) -> String;
fn part2(&mut self) -> String;
2023-12-06 21:55:04 -07:00
fn part1_large(&mut self) -> String {
self.part1()
}
fn part2_large(&mut self) -> String {
self.part2()
}
fn parse(&mut self) {}
2023-12-06 21:55:04 -07:00
fn solve(&mut self, part: u8, large: bool) -> String {
self.parse();
match part {
2023-12-06 21:55:04 -07:00
1 => match large {
false => self.part1(),
true => self.part1_large(),
},
2 => match large {
false => self.part2(),
true => self.part2_large(),
},
_ => panic!("Invalid part #"),
}
}
}