Write a function or program that accepts a date (as a string in
YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.
An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:
September 26th 2018 -> September twenty-sixth two thousand eighteen September Twenty-sixth Two thousand eighteen
Another way to think of this challenge: "are the elements of a given date lexically sorted?"
- 2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight." For another example, the year 1456 would be represented as "one thousand four hundred fifty-six," not "fourteen fifty-six."
- 26th is represented as "twenty-sixth," not "twenty-six."
- Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.
The following dates are not alphabetical:
- September 2nd 2018 ("second" should sort ahead of "September")
- April 30th 4000 ("four thousand" should sort ahead of "thirtieth")
- You will receive the date as a string, formatted like
YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).
- You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year
- You should return a truthy or falsey value, not necessarily a boolean
0that's fine. Of course, if you want to return a boolean, feel free.
- Standard loopholes are forbidden.
- This is
More Examples of Alphabetical Dates
- 2066-01-02 (January second, two thousand sixty-six)
- 1000-04-08 (April eighth, one thousand)
- 6000-08-01 (August first, six thousand)
More Examples of Non-Alphabetical Dates
- 1066-01-02 (January second, one thousand sixty-six)
- 1000-04-07 (April seventh, one thousand)
- 8000-08-01 (August first, eight thousand)