pub fn sum_depth_measurement(path: &str) -> i32 {
    let measurements = parse(path);

    // forward index up to three elements at most
    let measurement_cap = measurements.len() - 3;
    let mut i = 0;
    let mut depth_increase = 0;

    while i < measurement_cap {
        let window: i32 = measurements[i..i+3].iter().sum::<i32>();
        let next_window: i32 = measurements[i+1..i+4].iter().sum::<i32>();
        i += 1;

        if next_window > window { depth_increase += 1 }
    }

    return depth_increase
}
// Part two: counts sums of a three-measurement sliding window of measurements
Part two: counts sums of a three-measurement sliding window of measurements
Part two : counts sums of a three - measurement sliding window of measurements
pub fn sum_depth_measurement(path: &str) -> i32 {
    let measurements = parse(path);
    // forward index up to three elements at most
    let measurement_cap = measurements.len() - 3;
    let mut i = 0;
    let mut depth_increase = 0;
    while i < measurement_cap {
        let window: i32 = measurements[i..i+3].iter().sum::<i32>();
        let next_window: i32 = measurements[i+1..i+4].iter().sum::<i32>();
        i += 1;
        if next_window > window { depth_increase += 1 }
    }
    return depth_increase
}
pub fn sum_depth_measurement ( path : & str ) -> i32 { let measurements = parse ( path ) ; // forward index up to three elements at most let measurement_cap = measurements . len ( ) - 3 ; let mut i = 0 ; let mut depth_increase = 0 ; while i < measurement_cap { let window : i32 = measurements [ i .. i + 3 ] . iter ( ) . sum :: < i32 > ( ) ; let next_window : i32 = measurements [ i + 1 .. i + 4 ] . iter ( ) . sum :: < i32 > ( ) ; i += 1 ; if next_window > window { depth_increase += 1 } } return depth_increase }
Part two: counts sums of a three-measurement sliding window of measurements
Part two : counts sums of a three - measurement sliding window of measurements
path
&str