Sha256: cc09cc515dbdc314f4b58f1224016dca4af3269e97cbfb553a157bfb8194ee66

Contents?: true

Size: 187 Bytes

Versions: 29

Compression:

Stored size: 187 Bytes

Contents

pub fn hamming_distance(a: &str, b: &str) -> Option<usize> {
    if a.len() != b.len() {
        return None;
    }

    Some(a.chars().zip(b.chars()).filter(|&(a, b)| a != b).count())
}

Version data entries

29 entries across 29 versions & 1 rubygems

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