Sha256: 3dedbd76b3b8e91903b66bcdfdbb91471cc5309fd54738b1eec42568428fe874
Contents?: true
Size: 1.16 KB
Versions: 183
Compression:
Stored size: 1.16 KB
Contents
module pangram; import std.uni : toLower; bool isPangram(string str) { bool[dchar] letters; foreach (char letter; str) { auto lower = toLower(letter); if (lower >= 'a' && lower <= 'z') { letters[lower] = true; } } return letters.length == 26; } unittest { assert(!isPangram("")); assert(isPangram("the quick brown fox jumps over the lazy dog")); // missing x assert(!isPangram("a quick movement of the enemy will jeopardize five gunboats")); assert(!isPangram("the quick brown fish jumps over the lazy dog")); // test underscores assert(isPangram("the_quick_brown_fox_jumps_over_the_lazy_dog")); // test pangram with numbers assert(isPangram("the 1 quick brown fox jumps over the 2 lazy dogs")); // test missing letters replaced by numbers assert(!isPangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")); // test pangram with mixed case and punctuation assert(isPangram("\"Five quacking Zephyrs jolt my wax bed\"")); // pangram with non-ascii characters assert(isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich")); } void main() {}
Version data entries
183 entries across 183 versions & 1 rubygems