Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
Day 02: Nit code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
yamgent committed Dec 2, 2024
1 parent 586f9ad commit aaa54e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bin/day02/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ fn is_safe_increasing(values: &[i32]) -> bool {
values
.iter()
.zip(values.iter().skip(1))
.all(|(a, b)| b - a >= 1 && b - a <= 3)
.map(|(a, b)| b - a)
.all(|diff| diff >= 1 && diff <= 3)
}

fn is_safe_decreasing(values: &[i32]) -> bool {
values
.iter()
.zip(values.iter().skip(1))
.all(|(a, b)| a - b >= 1 && a - b <= 3)
.map(|(a, b)| a - b)
.all(|diff| diff >= 1 && diff <= 3)
}

fn p1(input: &str) -> String {
Expand Down

0 comments on commit aaa54e0

Please sign in to comment.