Teaser 3217: Peace in rest
From The Sunday Times, 19th May 2024 [link] [link]
George and Martha regularly read the obituaries in the national press; as well as the date of death, the date of birth of the person discussed is always shown. “That is interesting!” commented Martha as she looked at the three obituaries displayed one morning. Two of them have palindromic dates of birth (e.g., 13/11/31, 21/6/12). “Very unlikely, indeed!” agreed George.
Assuming that birth dates are expressed as day (1-31), month (1-12) year (00-99), what is the probability of a palindromic birth date in the 20th century (1900 to 1999 inclusive), and will it be greater, equal or less in the 21st century?
[teaser3217]
Jim Randell 4:50 pm on 17 May 2024 Permalink |
Technically the dates of the 20th century are 1st January 1901 – 31st December 2000, but that is not the convention followed in this puzzle. We are interested in the 19xx years and the 20xx years.
The answer to the second part of the puzzle comes from a fairly straightforward observation.
However, here is a constructive solution, that counts the palindromic dates in years 19xx and 20xx (assuming the calendar continues as expected, and that birth dates are uniformly distributed).
There are two ways we can check for palindromes, with or without the separators in the dates. In the following I am assuming that we only check the digits of the date, but the separators can be included at line 11 if required (although this changes the number of palindromic dates found).
Run: [ @replit ]
Solution: The proportion of palindromic dates in the years 1900 – 1999 is 7/794. In the years 2000 – 2099 there will be a (slightly) smaller proportion of palindromic dates.
In each of the 19xx and 20xx years there are a total of 322 palindromic dates. (Each palindromic date can refer to a 19xx date and a 20xx date).
However, as the year 1900 was not a leap year and the year 2000 was, there is 1 less day in the 19xx years, and so there is a higher proportion of palindromes compared to the 20xx years.
Note, that if we use the actual definition of 20th and 21st centuries (1901 – 2000 and 2001 – 2100) the result is reversed, as the leap day in 2000 is included in the earlier period.
Manually, we can count the number of palindromic dates in a 100 year period by considering the following constructions:
For a grand total of 81 + 198 + 27 + 22 = 328 dates.
However not all of these dates are valid, as some months don’t have 31 days. So we can remove the following invalid dates:
(Note that: 29/2/92 is a valid date).
And that leaves 322 palindromic dates in a century.
We can also count the total number of days in a century:
There are 365×100 = 36500 non-leap days, plus the number of leap days.
There are 24 leap years per century, plus an extra one when the year is divisibly by 400. So 2000 was a leap year, but 1900 was not.
Hence, there are 24 leap days in the years 1900..1999, and 25 in the years 2000..2099.
The proportions are:
So the proportion of palindromic dates in the years 2000..2099 is slightly smaller than the proportion in the years 1900..1999.
LikeLike
Pete Good 4:54 pm on 18 May 2024 Permalink |
Jim, I tried to run this program in Windows (using the Microsoft Visual Studio environment) but it generates the error INVALID FORMAT STRING because %-d and %-m are not supported by Microsoft. I am therefore hoping that my own C++ program has produced the correct solution!
LikeLike
Jim Randell 5:26 pm on 18 May 2024 Permalink |
Yes, I think this format is a
glibc
extension tostrftime()
. (Although it looks like Windows might use%#
instead of%-
to suppress zero padding).But in Python 3 you can replace line 11 with:
(which also seems to be faster).
or more generally:
LikeLike
Pete Good 5:44 pm on 18 May 2024 Permalink |
Thanks Jim, both of your suggestions work fine in Visual Studio and the program generated the same solution as my C++ program.
LikeLike