#P11387. Parsing ID Card Information
Parsing ID Card Information
Parsing ID Card Information
An identification card contains three lines of data formatted as follows:
- The first line consists of exactly 5 uppercase letters, 21 digits and 4 '
<
' characters. In the 21‐digit block, the last 11 digits represent the checksum. - The second line is a 6-digit string. The first two digits indicate the birth year. If the two-digit year is less than or equal to 24, then the full year is obtained by adding 2000; otherwise, add 1900. The next two digits indicate the birth month and the final two indicate the birth day. The resulting date should be output in YYYY-MM-DD format.
- The third line contains the name data. It is composed of the given name followed by the delimiter "<<" and then the surname. The entire line has a fixed length of 30 characters; if the name data is shorter than 30 characters, the remaining positions are padded with the '
<
' character.
Your task is to parse the three input lines and extract the following information:
- The checksum (the last 11 digits from the digit block in the first line).
- The birth date in the format
YYYY-MM-DD
(computed from the second line). - The given name and the surname (extracted from the third line, ignoring the padding characters).
- The first line follows the format: 5 uppercase letters, 21 digits, and 4 '
<
' characters. The last 11 digits of the 21-digit portion form the checksum. - The second line is a 6-digit string where the first 2 digits are the birth year, the next 2 digits are the birth month, and the final 2 digits are the birth day.
- The third line contains the name in the format: given name, then "<<", then surname, padded with '
<
' characters to a total length of 30 characters. - The extracted checksum (11-digit string).
- The birth date in the format
YYYY-MM-DD
. - The given name.
- The surname.
Output the extracted information on separate lines: first the checksum, then the formatted birth date, followed by the given name, and finally the surname.
inputFormat
The input consists of three lines:
outputFormat
Output 4 lines:
sample
ABCDE012345678901234567890<<<<
900101
JOHN<<DOE<<<<<<<<<<<<<<<<<<
01234567890
1990-01-01
JOHN
DOE
</p>