Skip to content

Instantly share code, notes, and snippets.

@TT--
Created October 20, 2017 15:20
Show Gist options
  • Save TT--/efac7feece45d35e1ec2d2745e08b9db to your computer and use it in GitHub Desktop.
Save TT--/efac7feece45d35e1ec2d2745e08b9db to your computer and use it in GitHub Desktop.
check if input contains all letters of alphabet (case in-sensitive)
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class PangramCheck {
public static void main(String args[] ) throws Exception {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
// Output "pangram" or "not pangram" depending if input sentence contains
// all the letters of the English alphabet or not
HashSet<Character> set = new HashSet<Character>();
Scanner in = new Scanner(System.in);
in.useDelimiter(""); // make scanner give strings of length==1
while (in.hasNext()) {
char c = in.next().charAt(0); // returns primitive
if (Character.isLetter(c)) set.add(Character.toLowerCase(c));
}
String result;
result = (set.size() == 26) ? "pangram" : "not pangram";
System.out.println(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment