summaryrefslogtreecommitdiff
path: root/2024/day02.rs
diff options
context:
space:
mode:
authornekineki <nekineki@nekineki.net>2024-12-03 07:25:10 +0100
committernekineki <nekineki@nekineki.net>2024-12-03 07:25:10 +0100
commitb503d9bdd545232501ca9a34623edb8a324d49ae (patch)
tree7f21dae8da80f93244e9760a6dc6eda184006c77 /2024/day02.rs
parent3c5c7a3e09dc26c304921eadbcb4ef04f93c9303 (diff)
update template
Diffstat (limited to '2024/day02.rs')
-rw-r--r--2024/day02.rs5
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