chore: formatting and cleanup
This commit is contained in:
parent
c0acf9524a
commit
43a25ed66f
4 changed files with 50 additions and 27 deletions
10
src/day3.rs
10
src/day3.rs
|
|
@ -1,6 +1,8 @@
|
|||
use std::fs;
|
||||
fn check_mul(instruction: &str) -> bool {
|
||||
if instruction.find(',').is_none() { return false; }
|
||||
if instruction.find(',').is_none() {
|
||||
return false;
|
||||
}
|
||||
let (first_part, second_part) = instruction.split_once(',').expect("Expected mul to split");
|
||||
let first_num = &first_part[4..];
|
||||
let second_num = &second_part[..second_part.len() - 1];
|
||||
|
|
@ -32,7 +34,11 @@ pub fn part1(input_file_path: &str) {
|
|||
let end_index = tmp.find(')').expect("expected a closure");
|
||||
let trim_str = tmp.split_at(end_index + 1).0;
|
||||
println!("{}", trim_str);
|
||||
total += if check_mul(trim_str) {eval_mul(trim_str)} else {0};
|
||||
total += if check_mul(trim_str) {
|
||||
eval_mul(trim_str)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
});
|
||||
println!("Eval result: {}", total);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue