The IRS (Internal Revenue Service) processes tax documents of US residents every year. As part of checking the tax submission, the IRS validates the SSN (social security number) of the applicant. The tax processing software is being worked on by a software development firm who needs an SSN validator script. Can you step up and work on that script? If your script gets accepted, you will be exempt from paying taxes next year. So get going before some else does it first!

Challenge

Write a program validate an input SSN number.

Facts

  • An SSN number is a 9 digit number.
  • The Social Security number is in the format "AAA-GG-SSSS". The number is divided into three parts.
  •  The first three digits known as the Area Number represent people belonging to certain US geographical area.
  • The middle two digits are the Group Number. The Group Numbers range from 01 to 99.
  • The last four digits are Serial Numbers. They represent a straight numerical sequence of digits from 0001 to 9999 within the group.
  • Some special numbers are never allocated:
    • Numbers with all zeros in any digit group (000-##-####, ###-00-####, ###-##-0000).
    • Numbers with 666 or 900-999 (Individual Taxpayer Identification Number) in the first digit group.

Requirements

  • Evaluate the input number and return if the number is VALID or INVALID.

Input

  • The input number to validate as SSN.

Output 

  • Display VALID if the input number does comply with SSN rules else INVALID.

Test cases

No.
Input - Number (SSN)
Ouput- (VALID or INVALID)
Explanation
1
348-30-3474
VALIDValid Test SSN
2
216-17-4517
VALIDValid Test SSN
3
216-00-4517
INVALIDMiddle group cannot be 00
4
216-11-451A
INVALIDSSN should be all numeric
5
666-30-3474
INVALID
1st group cannot start with 666
6
901-30-3474
INVALID1st group cannot start with 900-999
734830-3474
INVALIDNot formatted correctly, missing a hyphen
8348-30-34741
INVALIDMore than 9 digits

Instructions 

  • Accept the input number an command line argument.
  • Write the logic to determine if the number is a valid SSN.
  • Display the resulting output.

Disclaimer: The whole thing about getting the tax break is just to get you motivated and nothing more. You still would have to pay your fair share of taxes next year!