UK Postal Codes

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

A postal code in the United Kingdom must come in one of the following formats:

A9 9AA
A9A 9AA
A99 9AA
AA9 9AA
AA9A 9AA
AA99 9AA

In the above formats, A is a placeholder for any lowercase or uppercase letter and 9 is a placeholder for any digit. For example e5Y 8Qe is a valid UK postal code because it follows the second format listed above. Given a string, determine if it is a valid UK postal code.

Input Specification

The only line of input is a string of lowercase and uppercase letters, digits and spaces.

Output Specification

If the input is a valid UK postal code, print code, otherwise print not code.

Sample Input

e5Y 8Qe

Sample Output

code

Comments

There are no comments at the moment.