Today's date is quite an interesting one. Let's take a look at why. The date
DD/MM/YYYY date format) can be split into the year (
2017) and the rest (
07/12). You may notice that the digits in the year can be rearranged to match the digits in the rest of the date, which is the basis of this challenge.
Given an valid integer (e.g. no leading zeros) representing a year, consisting of exactly four digits, output all unique possible valid dates that can be made from those digits. You may take the number as a list of digits, or a string representing the input if you want. Each number in the input must be used exactly once in each of the final outputs. As leading
0s aren't used in integers, the input will be in the range
1000 <= input <= 9999.
A valid date is one in which the date exists on the Gregorian Calendar, such as
17/05/2000. The only corner case is February 29th, which is only a valid date when the year is a leap year. You can (but don't have to) assume that leap years are years that are divisible by 4.
You have to output a separator between the day and the month (e.g.
/) and a different separator between different dates. You may optionally output the year with each date, but this must be consistent between dates.
Finally, you may choose between the date format order, i.e. you can output as any of
MM/DD/YYYY etc. but leading
0s are required when the input contains at least one
Essentially, you may output in any obviously understandable format, such as an array of strings, one concatenated string etc.
This is a code-golf so shortest code wins!
input outputs 2017 07/12, 12/07, 17/02, 21/07, 27/01, 27/10 2092 22/09, 29/02 2029 22/09 1000 Nothing 8502 25/08, 28/05