1
You get a string which contains an integer between 1000
and 99999999
as input. The input string might contain leading zeroes but cannot be longer than 8 characters.
Your goal is to output all dates between 6th of December 1919
and 5th of December 2019
which fit the input in these formats:
- day - month - year (dmy)
- month - day -year (mdy)
- year - month - day (ymd)
Days and months can be either one or two digits. Years can be either two or four digits. Also don't forget the leap years!
Your output dates must be all in the same format (choose one). Its days, months and years must be clearly distinguishable (choose a separator or encode them like YYYYMMDD).
You are free to leave any duplicate dates in your output (you're a good boy if you remove them though). If there are no dates to return, return nothing.
Examples:
Input: "1234"
Output: 1934-02-01, 2012-03-04, 1934-01-02
Input: "01234"
Output: 1934-01-02, 1934-02-01
Input: "01211"
Output: 2001-11-01, 2011-01-01, 2001-01-11
Input: "30288"
Output: 1988-02-03, 1988-02-30, 1988-03-02
Input: "999999"
Output:
Shortest code in bytes wins. Have fun!
1In your examples you have inputs with leading zeros. However you say that inputs are integers between
1000
and99999999
. Hence 1234 is equivalent to 01234. This needs clarified – Expired Data – 2019-12-05T17:28:25.380Are there situations where a 7-digit integer leads to non-empty output? – Robin Ryder – 2019-12-05T17:31:38.140
@RobinRyder
2018111
should produce2018-11-01,2018-01-11
, if I'm understanding this challenge properly. – 79037662 – 2019-12-05T17:34:45.2133
1988-02-30
doesn't look like a valid date. – Arnauld – 2019-12-05T17:41:58.097How is
2001-11-01
a valid output for"01211"
? How is2001-02-11
not a valid output for"01211"
? – 79037662 – 2019-12-05T18:06:43.2431Did you mean for the input to be
"01111"
for that example? – 79037662 – 2019-12-05T18:13:45.273