Task
A date can be compactly represented in a 6-character string in the format ddmmyy
where the first two characters (dd
) represent a day, the 3rd and 4th characters (mm
) represent a month and the last two characters (yy
) represent a 20XX
year. Given a string with 6 characters in [0-9]
determine if it represents a valid date. But because today (the day this was posted) is April Fools' day, we will have a twist in the way dates work:
April Fools' dates
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; i.e.:
- months
01
,03
,05
,07
,08
,10
and12
have30
days; - months
04
,06
,09
and11
have31
days; - February has
28
days if the yearyy
is a multiple of4
, otherwise February has29
days (let us assume we are in the year20yy
);
Input
An integer in [0 - 311299]
or a 0-padded string representation of such an integer.
Output
A Truthy value if the input corresponds to a date as per the April Fools' dates, Falsy otherwise.
Test cases
Python naïve implementation for your convenience.
"000511" -> False
"000611" -> False
"290200" -> False
"290204" -> False
"290208" -> False
"310004" -> False
"310005" -> False
"310104" -> False
"310105" -> False
"310204" -> False
"310205" -> False
"310304" -> False
"310305" -> False
"310504" -> False
"310505" -> False
"310704" -> False
"310705" -> False
"310804" -> False
"310805" -> False
"311004" -> False
"311005" -> False
"311204" -> False
"311205" -> False
"311304" -> False
"311305" -> False
"311404" -> False
"311405" -> False
"010694" -> True
"031288" -> True
"050199" -> True
"050298" -> True
"050397" -> True
"060496" -> True
"070595" -> True
"100793" -> True
"150892" -> True
"181189" -> True
"200991" -> True
"251090" -> True
"280200" -> True
"280201" -> True
"280202" -> True
"280203" -> True
"280204" -> True
"280205" -> True
"280206" -> True
"280207" -> True
"280208" -> True
"290201" -> True
"290202" -> True
"290203" -> True
"290205" -> True
"290206" -> True
"290207" -> True
"310404" -> True
"310405" -> True
"310604" -> True
"310605" -> True
"310904" -> True
"310905" -> True
"311104" -> True
"311105" -> True
This challenge was inspired by this one.
This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it! If you dislike this challenge, please give me your feedback. Happy golfing!