#C7562. Find Missing Cattle Tags
Find Missing Cattle Tags
Find Missing Cattle Tags
You are given a list of existing cattle tags from a farm. Each tag consists of a breed letter followed by a four‐digit number. In this problem, the numerical part ranges from 0001 to 0010 (for demonstration purposes; in a real scenario, it is from 0001 to 9999). The breeds are:
- A: Angus
- H: Hereford
- J: Jersey
- G: Guernsey
Your task is to determine all missing tags. The complete set of tags for a breed is given by \(\{b\,\texttt{0001}, b\,\texttt{0002}, \dots, b\,\texttt{0010}\}\) for each breed letter b. Given the list of existing tags, output the missing tags in the order of the breeds A, H, J, G, and for each breed, in increasing numerical order.
Note: All formulas are given in LaTeX format. The input will be taken from stdin
and the output should be written to stdout
. For example, if the complete set of tags for breed A is
\(\{A0001, A0002, \dots, A0010\}\), and some tags are missing, they should be listed in sorted order.
inputFormat
The input is read from stdin
and has the following format:
n tag1 tag2 ... tagn
Where:
- n: An integer representing the number of existing tags.
- tagi: A string representing each existing cattle tag.
outputFormat
The output should be written to stdout
. Print all the missing tags, each on a new line, following the order of breeds A, H, J, G and in increasing numerical order within each breed.
5
A0001
H0001
J0010
G0005
A0005
A0002
A0003
A0004
A0006
A0007
A0008
A0009
A0010
H0002
H0003
H0004
H0005
H0006
H0007
H0008
H0009
H0010
J0001
J0002
J0003
J0004
J0005
J0006
J0007
J0008
J0009
G0001
G0002
G0003
G0004
G0006
G0007
G0008
G0009
G0010
</p>