Righteous Wrath Online Community

General => Tech Chat => Topic started by: Darren Dirt on April 03, 2020, 04:29:27 PM

Title: Code Golf - "Is this a legal date?" (ApRiL fOoLs EdItIoN 2020)
Post by: Darren Dirt on April 03, 2020, 04:29:27 PM
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 (https://github.com/Adriandmen/05AB1E)

** and thanks to THAT, I also just now discovered "Try It Online" (https://tio.run) -- 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 (https://tio.run/#whitespace)"!





Title: Re: Code Golf - "Is this a legal date?" (ApRiL fOoLs EdItIoN 2020)
Post by: Darren Dirt on April 03, 2020, 04:55:19 PM
There is even a language called "ArnoldC".

It should have been "AHNOLD", but other than that, solid thumbs up:

https://codegolf.stackexchange.com/questions/200086/is-it-really-time/202947#202947


Title: Re: Code Golf - "Is this a legal date?" (ApRiL fOoLs EdItIoN 2020)
Post by: Mr. Analog on April 03, 2020, 09:04:10 PM
LOL

Sent from my Pixel 2 XL using Tapatalk