From New Scientist #2710, 30th May 2009 [link] [link]
Writing 30 May 2009 in the order day’s number.month.year, with just one digit for the month but the year in full, gives 30.5.2009. This is a perfect square date because 3052009 = 1747². If two digits are allocated for the month, then 3 May 2009 (3.05.2009) was a perfect square date.
If you maintain the order day’s number.month.year and write the year as a four-digit number, as in these examples, what is the next date that will be a perfect square
(a) if you allocate one digit for the month, and
(b) if you allocate two digits for the month?
Give your answers in the form of (a) 30.5.2009, (b) 3.05.2009.
[enigma1547]
Here’s my original Perl code. It runs in 25ms.
Solution: (a) 22.6.2016, (b) 16.03.2016.
Here’s how I would do it now in Python. This uses the [[
datetime
]] module to go through increasing dates, and checks both parts of the problem together. It runs in 67ms.