Forecast Romantic Dates
code-golf date
Sort of inspired by this.
A Romantic date is a date that, when the year, month and day are converted to Roman Numerals the individual values contain no more than two symbols. For example, in YY-MM-DD
format: the Romantic date 20-04-15
would become XX-IV-XV
.
For the purpose of this challenge, years will only be tracked by the two least significant digits of the year, as otherwise the last Romantic date was in the 15th century. In addition, they wouldn't add much to the challenge as the omissions of the leap year every 400 years is irrelevant, as February the 29th is not a Romantic date.
Romantic dates
For your convenience, here is a list of all of the two digit numbers that can be represented with two or fewer symbols in Roman numerals:
[1, 2, 4, 5, 6, 9, 10, 11, 15, 20, 40, 50, 51, 55, 60]
These were determined using the "standard method" that negative groups would only be used with the symbols that are powers of ten and only on the values that are five or ten times that symbol's value. So I
only combines with V
and X
for example.
Dates which include only numbers from this list are Romantic dates. For the purpose of this challenge, assume an ideal Western calendar: no dates are ever skipped or repeated, 12 months per year, and more than 20 days per month. Assume there is no year, month or day zero (i.e. year 99 loops to 1 not to 0).
Task
Given a date as input, output that date if it is Romantic, or output the next Romantic date.
Input and Output
You may accept input in any consistent ordering of year, month and day with any consistent separator. You may specify if the input should have the numbers padded to be two digits. If the numbers are padded, you may choose to have no separator. Your output must have the same form as your input.
Test Cases
The following test cases are all in the format YY MM DD
, with no padding.
1 1 1 => 1 1 1
20 4 3 => 20 4 4
15 7 1 => 15 9 1
51 9 7 => 51 9 9
70 9 7 => 1 1 1
20 6 24 => 20 9 1
47 12 1 => 50 1 1
60 11 24 => 1 1 1
Here is the script that I used to generate these.
Sandbox
Did I miss any Romantic numbers? I just did that by hand.
Allow unary? I'm unsure about this because it sort of violates the reasoning behind Romantic dates for the values to have >2 symbols...
Should I explain more about parts of dates that are not useful? For example, the length of the months is entirely irrelevant as the later days are all skipped. My concern is that the current one feels clunky already
Should I allow both outputting the input if the date is already Romantic or the strictly next Romantic date (as long as it is consistent)? There doesn't seem to be much different, but I don't know if that'd be too broad? Personally leading towards allowing it.
I'm also somewhat tempted to make use of the silly title a bit more, but I'm not sure if that'd be going overboard.
Too boring / compression based? I've particularly been trying to think of a way for fewer results to wrap back around to 1.