use std::collections::HashSet;
pub fn is_pangram(sentence: &str) -> bool {
sentence
.to_lowercase()
.chars()
.filter(|c| c.is_ascii_alphabetic())
.collect::<HashSet<char>>()
.len()
== 26
}
This approach chains several functions together to determine the result.
- It first passes the
sentenceto_lowercase. - The lowercased
sentenceis then iterated by chars. - The
charsare filtered in its closure so that only a character that is_ascii_alphabetic makes it through to be collected into a HashSet. - The function returns if the len of the
HashSetis26. If the number of unique letters in theHashSetis equal to the26letters in the alphabet, then the function will returntrue.
Translation missing: el.number.nth.ordinalized Sep 2026
·
Σου φάνηκε χρήσιμη;