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.159 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.158 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.157 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.156 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.155 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.154 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.153 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.152 tracks/rust/exercises/hamming/example.rs
trackler-2.2.1.151 tracks/rust/exercises/hamming/example.rs