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