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.158 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.157 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.156 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.155 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.154 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.153 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.152 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.151 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.150 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.149 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.148 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.147 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.146 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.145 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.144 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.143 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.142 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.141 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.140 tracks/rust/exercises/saddle-points/example.rs
trackler-2.2.1.139 tracks/rust/exercises/saddle-points/example.rs