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.97 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.96 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.95 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.94 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.93 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.92 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.91 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.90 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.89 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.88 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.87 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.86 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.85 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.84 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.83 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.82 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.81 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.80 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.79 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.78 tracks/rust/exercises/isogram/example.rs