diff options
Diffstat (limited to '2024/day02.rs')
| -rw-r--r-- | 2024/day02.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/2024/day02.rs b/2024/day02.rs index c32aa19..b573d5c 100644 --- a/2024/day02.rs +++ b/2024/day02.rs @@ -11,7 +11,10 @@ fn is_all_same(arr: &[bool]) -> bool { fn is_safe(arr: &[i32]) -> bool { let diff: Vec<i32> = arr.windows(2).map(|w| w[0] - w[1]).collect(); - let inc_ok = diff.iter().map(|a| (3 >= a.abs()) && (a.abs() >= 1)).all(|a|a); + let inc_ok = diff + .iter() + .map(|a| (3 >= a.abs()) && (a.abs() >= 1)) + .all(|a| a); let sign_ok = is_all_same(&diff.iter().map(|a| *a > 0).collect::<Vec<_>>()); inc_ok && sign_ok |
