Sha256: e42bf96690c09be7000572880d35cac999de6ab9867d0bf2327f0f180135af07

Contents?: true

Size: 620 Bytes

Versions: 103

Compression:

Stored size: 620 Bytes

Contents

pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> {
    let mut saddle_points = Vec::new();

    let width = input.len();
    let height = input[0].len();

    for i in 0..width {
        for j in 0..height {

            let column = input.iter().map(|x| x[j]).collect::<Vec<u64>>();
            let row = &input[i];

            let max = row.iter().max().unwrap();
            let min = column.iter().min().unwrap();

            let value = input[i][j];

            if value >= *max && value <= *min {
                saddle_points.push((i, j));
            }
        }
    }
    saddle_points
}

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
trackler-2.2.1.179 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.178 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.177 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.176 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.175 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.174 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.173 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.172 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.171 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.170 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.169 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.167 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.166 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.165 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.164 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.163 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.162 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.161 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.160 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.159 tracks/rust/exercises/saddle-points/example.rs