University of Calgary

problem: year 2000 problem


The Year 2000 Problem
[Credit: ACM Programming Contest, adapted]


The infamous year 2000 problem stems from the fact that, in many computer systems and databases, the year component of a date is represented by two decimal digits. So, if a person's date of birth (in month/year format) is 04/10/95, was the person born in 1895 or 1995?

Here is an example of input to your program, contained in a file PROG1.DAT:
Dijkstra, Edsger          603849562 ----  0  9  1 99
Hopper, Grace Murray     234258030 ---- 97  2 12 0
Hollerith, Herman        602348748 FGSH 97  5 20 77
Shannon, Claude           571839480 FGJH 96 10 28 79
Lovelace, Ada             123456789 BAMS  0  6 30 92
Babbage, Charles         234567890 ----  0  8 31 92
McCarthy, John            345678901 ----  0  8 31 93
Noether, Emmy             456789123 ---- 97 12 10 94
Curie, Marie             567890123 ----  0  1 15 94
Shugart, Alan             678901234 ---- 95 11  1 93
Knuth, Donald             789012345 ----  0  9 28 93
Atanasoff, John          798723424 ---- 97 11 14 98
Von Neumann, John         890123456 ----  0 11 14 98

Each line of the input consists of seven fields. Adjacent fields are separated by one blank space. In order to understand the meaning of each field, let us consider a typical line of input, preceeded by a template which shows the numbering of the columns:
                      1         2        3         4         5         6
123456789012345678901234567890123456789012345678901234567890
Hopper, Grace Murray      234258030 ---- 97  2 12 0
The meaning of each of the seven fields is as follows:
Columns 1-25: A person's name
Columns 27-35: The person's social security number.
Columns 37-40: A 4 character code designating the last known school attended during the last 10 years. The code "----" means that the person did not attend school during that period.
Columns 42-43: The last two digits of the most recent year in which the person filed a tax return, if one has been filed since 1950. Otherwise there is no tax record for this person, and column 42 will be blank and column 43 will contain the single digit 0.
Columns 45-46: The person's month of birth.
Columns 48-49: The day of the month of the person's date of birth.
Columns 51-52: The last two digits of the person's year of birth (or just the last digit if the person was born in the persion 1900-1909).
If the data in columns 45-46, or columns 48-49, or columns 51-52 requires only one digit, it will be right justified in the stated columns.

Your program will write its output to the file PROG1.OUT. Each line or input will give rise to one line of output, almost identical. The differences between input and output will be:
1. The two digit year of birth (columns 51-52) will be replaced by the four digit year of birth in columns 51-54. The first two digits of the year of birth will be 18 or 19 determined by the rules that follow.
2. A letter `K' in column 56 of the output will indicate a child who is expecetd to attend kindergarten starting September 1999. The rule for identifying such children will be stated in the following section.
For the example data above, your program will produce the following output on the file PROG1.OUT:
Problem 1
Dijkstra, Edsger          603849562 ----  0  9  1 1899
Hopper, Grace Murray      234258030 ---- 97  2 12 1900
Hollerith, Herman         602348748 FGSH 97  5 20 1977
Shannon, Claude           571839480 FGJH 96 10 28 1979
Lovelace, Ada             123456789 BAMS  0  6 30 1992
Babbage, Charles          234567890 ----  0  8 31 1892
McCarthy, John            345678901 ----  0  8 31 1993
Noether, Emmy             456789123 ---- 97 12 10 1894
Curie, Marie              567890123 ----  0  1 15 1994 K
Shugart, Alan             678901234 ---- 95 11  1 1893
Knuth, Donald             789012345 ----  0  9 28 1993 K
Atanasoff, John           798723424 ---- 97 11 14 1898
Von Neumann, John         890123456 ----  0 11 14 1998
End of problem 1

Here are the rules that determine a person's age:
Rule 1: All persons in the input data will have been born before the date of this contest (November 14, 1998). This means:
- If the last two digits of the year are 99 then the year of birth is 1899.
- If the last two digits of the year of birth are 98 and the date in that year is in the range November 15 through December 31, then the year of birth is 1898.
Rule 1 is illustrated by line 1 of the sample input.
Before defining the remaining rules, let's define a person's apparent age to be the age on August 31, 1999, calculated from the input data, assuming that the first two digits of the year are 19. This definition will appply only to cases not covered by rule 1.
Rule 2: If the apparent age is 20 or more, the first two digits of the year of birst are 19. Rule 2 is illustrated by lines 2-3 of the sample input. In other words, it is assumed that no person's age will exceed 119 years.
Rule 3: If the apparent age is in the range 7..19 then the existance of school records will determine the first two digits of the year of birth: if the person attended school during the preceeding ten years then the first two digits of the year of birst are 19; otherwise they are 18. This rule is illustrated by lines 4-6 of the sample input.
Rule 4: If the apparent age is 6 or less, the first two digits of the year of birth will be determined by tax records: if there is a tax record for that person, the first two digits of the year will be 18, otherwise they are 19. Rule 4 is illustrated by lines 7-13 of the input.
The Kindergarten Rule states that children who are five years old on August 31, 1999 will be expected to attend kindergarten starting September 1999.
You may assume that all cases which arise in the input data will be covered by the rules just stated.


Updated: August 5, 2005 12:18 AM