Sha256: 84ed19c2273051e6e1af20eadae63aa5881487c31738d034e93131d2d01e82b1

Contents?: true

Size: 626 Bytes

Versions: 123

Compression:

Stored size: 626 Bytes

Contents

pub fn check(word: &str) -> bool {

    // Filter all non-Alphabetic character out and collect them in a new String
    let normalized_string: String = word.to_lowercase().chars().filter(|c| c.is_alphabetic()).collect();

    /* Find the char element from back and front and compare the index.
       If it is the same unique char the index will be the same.*/
    let is_unique = |x: char, word: &str| word.find(x).unwrap() == word.rfind(x).unwrap();

    // Length should be the same if it is a isogram
    normalized_string.len() == normalized_string.chars().filter(|&x| is_unique(x, normalized_string.as_str())).count()
}

Version data entries

123 entries across 123 versions & 1 rubygems

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