On my website, users enter their date of birth in the style
xx.xx.xx - three two-digit numbers separated by dots. Unfortunately, I forgot to tell the users exactly which format to use. All I know is that one section is used for the month, one for the date, and one for the year. The year is definitely in the 20th century (1900-1999), so the format
31 May 1975. Also, I'm assuming everyone uses either the Gregorian or the Julian calendar.
Now, I want to go through my database to clear up the mess. I'd like to start by dealing with the users with the most ambiguous dates, that is, those where the range of possible dates is the biggest.
For example, the date
27 August 1953 in either the Gregorian or Julian calendar. The date in the Julian calendar is 13 days later, so the range is just
In contrast, the notation
01.05.12 can refer to many possible dates. The earliest is
12 May 1901 (Gregorian), and the latest is
1 May 1912 (Julian). The range is
- Input is a string in the format
xx.xx.xx, where each field is two digits and zero-padded.
- Output is the number of days in the range.
- You can assume that the input will always be a valid date.
- You may not use any built-in date or calendar functions.
- Shortest code (in bytes) wins.
0(The only possibility is
29 February 1900 (Julian))