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.77 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.76 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.75 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.74 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.73 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.72 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.71 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.70 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.69 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.68 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.67 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.66 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.65 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.64 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.63 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.62 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.61 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.60 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.59 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.58 tracks/rust/exercises/isogram/example.rs