Check Pangram
A pangram is a sentence that contains every letter of the alphabet at least once.
Sample input
The quick brown fox jumps over the lazy dog
Sample output
true
Solution
s = "The quick brown fox jumps over the lazy dog"
letters = set(ch for ch in s.lower() if ch.isalpha())
print(len(letters) == 26)
const s = "The quick brown fox jumps over the lazy dog";
const letters = new Set(s.toLowerCase().replace(/[^a-z]/g, ""));
console.log(letters.size === 26);
public class Main {
public static void main(String[] args) {
String s = "The quick brown fox jumps over the lazy dog";
boolean[] seen = new boolean[26];
for (char c : s.toLowerCase().toCharArray()) {
if (c >= 'a' && c <= 'z') seen[c - 'a'] = true;
}
int count = 0;
for (boolean b : seen) if (b) count++;
System.out.println(count == 26);
}
}
fun main() {
val s = "The quick brown fox jumps over the lazy dog"
val letters = s.lowercase().filter { it in 'a'..'z' }.toSet()
println(letters.size == 26)
}
let s = "The quick brown fox jumps over the lazy dog"
let letters = Set(s.lowercased().filter { $0.isLetter })
print(letters.count == 26)
void main() {
String s = 'The quick brown fox jumps over the lazy dog';
Set<String> letters = {};
for (var c in s.toLowerCase().split('')) {
if (RegExp(r'[a-z]').hasMatch(c)) letters.add(c);
}
print(letters.length == 26);
}
#include <iostream>
#include <cctype>
using namespace std;
int main() {
string s = "The quick brown fox jumps over the lazy dog";
bool seen[26] = {false};
for (char c : s) {
c = tolower(c);
if (c >= 'a' && c <= 'z') seen[c - 'a'] = true;
}
int count = 0;
for (bool b : seen) if (b) count++;
cout << (count == 26 ? "true" : "false") << endl;
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main() {
char s[] = "The quick brown fox jumps over the lazy dog";
int seen[26] = {0};
for (int i = 0; s[i]; i++) {
char c = tolower(s[i]);
if (c >= 'a' && c <= 'z') seen[c - 'a'] = 1;
}
int count = 0;
for (int i = 0; i < 26; i++) if (seen[i]) count++;
printf("%s\n", count == 26 ? "true" : "false");
return 0;
}