• Welcome to Righteous Wrath Online Community. Please login or sign up.
 

Code Golf - "Is this a legal date?" (ApRiL fOoLs EdItIoN 2020)

Started by Darren Dirt, April 03, 2020, 04:29:27 PM

Previous topic - Next topic

Darren Dirt

https://codegolf.stackexchange.com/questions/202889/is-this-a-legal-date-april-fools-edition https://archive.fo/izPW6

Task:
A date can be compactly represented in a 6-character string "ddmmyy" (20XX year); determine if it represents a valid date.

Input:
An integer in [0 - 311299] or a 0-padded string representation of such an integer.

*TWIST:*
Because today (the day this was posted) is April Fools' day...
-We will pretend every 30-day month has 31 days and every 31-day month has 30 days.
-Furthermore, in years when February is supposed to have 29 days we will pretend February only has 28 days and in all the other years we will pretend February has 29 days.
Therefore, months 01, 03, 05, 07, 08, 10 and 12 have 30 days; months 04, 06, 09 and 11 have 31 days; February has 28 days if the year yy is a multiple of 4 otherwise it has 29 days.

...

This is code-golf so shortest submission in bytes, wins!

Folks soon shared ridic tiny solutions, like Javascript in 59 bytes and Python3 in 61 bytes... even Java in 74 bytes!

There is even a solution in a language I never heard** of until now -- invented specifically FOR Code Golf -- called 05AB1E

** and thanks to THAT, I also just now discovered "Try It Online" -- which is yet another "fiddle" but in this case it is an editor/interpreter for HUNDREDS of crazy languages, including that meanest of the mean, "whitespace"!





_____________________

Get better at getting better. Daily.
_____________________

Darren Dirt

_____________________

Get better at getting better. Daily.
_____________________

Mr. Analog

By Grabthar's Hammer