In the book The Giant Book of Puzzles by , on page 12, there is a problem that is stated as follows:
"The year 1978 has an unusual property: When you add the 19 to the 78, you get 97 - the middle two digits of the year!
What will be the next year to have this same property?"
Here is how I solved it:
We start with a 4-digit number with digits a, b, c, and d. In the case of 1978,
a=1, b=9, c=7, and d=8.
The property that 1978 has can be expressed as
10a+b + 10c+d = 10b+c.
Rearranging the equation gives
10a-9b+9c+d=0.
We can now try the years after 1978. It is not hard to find that 1979 or 1980 do not work. With 1981, 19+81=100, so nothing else in the 20th century will work. We can now assume that
a=2.
Plugging this into the equation gives
20-9b+9c+d=0.
Notice how after 9b, everything is addition, so 20-9b must be negative. For this, b has to be at least 3. Anything larger than 3 also works, but we want "the next year to have this same property". This means that
b=3.
Now, we have
20-27+9c+d=0
which simplifies to
-7+9c+d=0.
C cannot be positive, because if it were, d would have to be negative. Because of this,
c=0.
Since 9c = 0, we can simply remove c from the equation and get
-7+d=0.
Adding 7 to both sides gives
d=7.
The puzzle is solved! a=2, b=3, c=0, and d=7, which gives our answer of 2307!
Then again, we could have just used the C program below, which prints all 4-digit numbers that have this property.
"The year 1978 has an unusual property: When you add the 19 to the 78, you get 97 - the middle two digits of the year!
What will be the next year to have this same property?"
Here is how I solved it:
We start with a 4-digit number with digits a, b, c, and d. In the case of 1978,
a=1, b=9, c=7, and d=8.
The property that 1978 has can be expressed as
10a+b + 10c+d = 10b+c.
Rearranging the equation gives
10a-9b+9c+d=0.
We can now try the years after 1978. It is not hard to find that 1979 or 1980 do not work. With 1981, 19+81=100, so nothing else in the 20th century will work. We can now assume that
a=2.
Plugging this into the equation gives
20-9b+9c+d=0.
Notice how after 9b, everything is addition, so 20-9b must be negative. For this, b has to be at least 3. Anything larger than 3 also works, but we want "the next year to have this same property". This means that
b=3.
Now, we have
20-27+9c+d=0
which simplifies to
-7+9c+d=0.
C cannot be positive, because if it were, d would have to be negative. Because of this,
c=0.
Since 9c = 0, we can simply remove c from the equation and get
-7+d=0.
Adding 7 to both sides gives
d=7.
The puzzle is solved! a=2, b=3, c=0, and d=7, which gives our answer of 2307!
Then again, we could have just used the C program below, which prints all 4-digit numbers that have this property.
4_digit.c | |
File Size: | 0 kb |
File Type: | c |
These numbers form a sequence, but interestingly, it is not in the Online Encyclopedia of Integer Sequences (oeis.org).