Commit edited manually.
This commit is contained in:
parent
32744e2ed2
commit
e32002c0c5
@ -1,9 +1,9 @@
|
|||||||
fn mutual_inclusion(first_pair: &[u32], second_pair: &[u32]) -> bool {
|
pub fn mutual_inclusion(first_pair: &[u32], second_pair: &[u32]) -> bool {
|
||||||
(first_pair[0] <= second_pair[0] && first_pair[1] >= second_pair[1])
|
(first_pair[0] <= second_pair[0] && first_pair[1] >= second_pair[1])
|
||||||
|| (second_pair[0] <= first_pair[0] && second_pair[1] >= first_pair[1])
|
|| (second_pair[0] <= first_pair[0] && second_pair[1] >= first_pair[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn solve_part1(file_path: &str) -> i32 {
|
pub fn solve(file_path: &str, unary_operator: &dyn Fn(&[u32], &[u32]) -> bool) -> i32 {
|
||||||
std::fs::read_to_string(file_path)
|
std::fs::read_to_string(file_path)
|
||||||
.expect("Please provide a text file as an argument.")
|
.expect("Please provide a text file as an argument.")
|
||||||
.lines()
|
.lines()
|
||||||
@ -29,7 +29,7 @@ pub fn solve_part1(file_path: &str) -> i32 {
|
|||||||
.expect("Parsing number in first pair failed")
|
.expect("Parsing number in first pair failed")
|
||||||
})
|
})
|
||||||
.collect::<Vec<u32>>();
|
.collect::<Vec<u32>>();
|
||||||
if mutual_inclusion(&first_pair, &second_pair) {
|
if unary_operator(&first_pair, &second_pair) {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
@ -38,4 +38,4 @@ pub fn solve_part1(file_path: &str) -> i32 {
|
|||||||
.collect::<Vec<i32>>()
|
.collect::<Vec<i32>>()
|
||||||
.iter()
|
.iter()
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user