#C11756. Tracking Number Validator

    ID: 41107 Type: Default 1000ms 256MiB

Tracking Number Validator

Tracking Number Validator

In this problem, you are given a tracking number and your task is to determine whether it is valid based on a set of rules. A tracking number is valid if it meets all the following criteria:

  1. The tracking number must be exactly 10 characters long.
  2. The first character must be an uppercase letter (A-Z).
  3. The last character must be a digit (0-9).
  4. Every character (except the first and last) can be an uppercase letter or a digit.
  5. No two consecutive characters are the same.

The formal pattern can be expressed using regular expressions as follows:

( [1][A-Z0-9]{8}[0-9]$ ) (\text{for length and allowable characters})

and

( ^(?!.(.)\1).$ ) (\text{to ensure no consecutive repeated characters}).

Your program should read a single line from standard input representing the tracking number, and then print either "Valid" if the tracking number passes all the checks, or "Invalid" otherwise.

inputFormat

The input consists of a single line from standard input containing the tracking number string.

outputFormat

Print a single line to standard output: "Valid" if the tracking number is valid, otherwise "Invalid".## sample

A1B2C3D4E5
Valid

</p>
  1. A-Z ↩︎