Utopian
Identification Number
The following is the solution to the Hacker Rank problem “Utopian
Identification Number". For other Hacker Rank problem solutions visit my Hacker Rank Solutions Page.
/**
* @author Arun.G
*
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[]
args) {
/* Enter your code here. Read input from
STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int no = sc.nextInt();
while(no-->=0)
{
String word = sc.nextLine();
int count=0;String
result="";
if(!word.equals(""))
{
//for country
String patternString ="\\b[a-z]{0,3}[0-9]{2,8}[A-Z]{3}";
Pattern pattern = Pattern.compile(patternString);
Matcher m =
pattern.matcher(word);
if(m.find())
{
System.out.println("VALID");
}
else
{
System.out.println("INVALID");
}
}
}
}
}
|
No comments:
Post a Comment