Sha256: f71b8489052ab163e050b44037987ec4a0e91422b47aceb1c07d0bc8adcef340

Contents?: true

Size: 460 Bytes

Versions: 395

Compression:

Stored size: 460 Bytes

Contents

fn sort(word: &String) -> String {
    let mut sorted: Vec<char> = word.chars().collect();
    sorted.sort();
    sorted.into_iter().collect()
}

pub fn anagrams_for<'a>(word: &str, inputs: &[&'a str]) -> Vec<&'a str> {
    let lower = word.to_lowercase();
    let sorted = sort(&lower);
    inputs.iter().filter(|input| {
        let input_lower = input.to_lowercase();
        lower != input_lower && sorted == sort(&input_lower)
    }).cloned().collect()
}

Version data entries

395 entries across 395 versions & 1 rubygems

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