We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Regex
  3. Applications
  4. Alien Username

Alien Username

Problem
Submissions
Leaderboard
Discussions
Editorial

In a galaxy far, far away, on a planet different from ours, each computer username uses the following format:

  1. It must begin with either an underscore, _ (ASCII value ), or a period, . (ASCII value ).
  2. The first character must be immediately followed by one or more digits in the range through .
  3. After some number of digits, there must be or more English letters (uppercase and/or lowercase).
  4. It may be terminated with an optional _ (ASCII value ). Note that if it's not terminated with an underscore, then there should be no characters after the sequence of or more English letters.

Given strings, determine which ones are valid alien usernames. If a string is a valid alien username, print VALID on a new line; otherwise, print INVALID.

Input Format

The first line contains a single integer, , denoting the number of usernames.
Each line of the subsequent lines contains a string denoting an alien username to validate.

Constraints

Output Format

Iterate through each of the strings in order and determine whether or not each string is a valid alien username. If a username is a valid alien username, print VALID on a new line; otherwise, print INVALID.

Sample Input

3
_0898989811abced_
_abce
_09090909abcD0

Sample Output

VALID
INVALID
INVALID

Explanation

We validate the following three usernames:

  1. _0898989811abced_ is valid as it satisfies the requirements specified above. Thus, we print VALID.
  2. _abce is invalid as the beginning _ is not followed by one or more digits. Thus, we print INVALID.
  3. _09090909abcD0 is invalid as the sequence of English alphabetic letters is immediately followed by a number. Thus, we print INVALID.

Author

dheeraj

Difficulty

Easy

Max Score

10

Submitted By

13599

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy