make rust happy about Capitalized names
This commit is contained in:
parent
83cb093d0a
commit
e19c2201f8
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
pub enum PART {
|
||||
ONE,
|
||||
TWO
|
||||
pub enum Part {
|
||||
One,
|
||||
Two
|
||||
}
|
||||
|
||||
fn line_to_calibration_part1(line: &str) -> (Option<u32>, Option<u32>) {
|
||||
|
|
@ -48,12 +48,12 @@ fn line_to_calibration_part2(line: &str) -> (Option<u32>, Option<u32>) {
|
|||
(a,b)
|
||||
}
|
||||
|
||||
pub fn solve(lines: Vec<String>, part: self::PART) -> u32 {
|
||||
pub fn solve(lines: Vec<String>, part: self::Part) -> u32 {
|
||||
let mut sum = 0;
|
||||
for line in lines.iter() {
|
||||
let (a, b) = match part {
|
||||
PART::ONE => line_to_calibration_part1(line),
|
||||
PART::TWO => line_to_calibration_part2(line)
|
||||
Part::One => line_to_calibration_part1(line),
|
||||
Part::Two => line_to_calibration_part2(line)
|
||||
};
|
||||
if let (Some(a), Some(b)) = (a, b) {
|
||||
sum += a * 10 + b;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ mod utils;
|
|||
|
||||
fn main() {
|
||||
let day1_data_path = "./datasets/adventofcode.com_2023_day_1_input.txt";
|
||||
let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::ONE);
|
||||
let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::TWO);
|
||||
let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::One);
|
||||
let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::Two);
|
||||
|
||||
println!("Day 1 (part 1) result is {}", day1_result_part1);
|
||||
println!("Day 1 (part 2) result is {}", day1_result_part2);
|
||||
|
|
@ -21,8 +21,8 @@ mod tests {
|
|||
#[test]
|
||||
fn day1() {
|
||||
let day1_data_path = "./datasets/adventofcode.com_2023_day_1_input.txt";
|
||||
let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::ONE);
|
||||
let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::TWO);
|
||||
let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::One);
|
||||
let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::Two);
|
||||
|
||||
assert_eq!(day1_result_part1, 54338);
|
||||
assert_eq!(day1_result_part2, 53389);
|
||||
|
|
|
|||
Loading…
Reference in New Issue