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.118 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.117 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.116 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.115 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.114 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.113 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.111 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.110 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.109 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.108 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.107 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.106 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.105 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.104 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.103 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.102 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.101 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.100 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.99 tracks/rust/exercises/isogram/example.rs
trackler-2.2.1.98 tracks/rust/exercises/isogram/example.rs