13
2
Your function or program should take a year as input and return (or print) the date (in the Gregorian calendar) of that years Easter (not the Eastern Orthodox Easter). The date returned should be formatted according to ISO 8601, but with support for years greater than 9999 (such as 312013-04-05 or 20010130), and it only needs to work with years greater than or equal to 1583 (the year of the adoption of the Gregorian calendar), and years less than or equal to 5701583 (as that is when the sequence of Easter dates starts to repeat itself).
Examples:
e(5701583) = 5701583-04-10
e(2013) = 2013-03-31
e(1583) = 1583-04-10
e(3029) = 30290322
e(1789) = 17890412
e(1725) = 17250401
The use of built-in functions for returning the date of easter is boring and therefore disallowed. Shortest answer (in characters) wins.
Resources:
Do you realise that some languages have a built-in function to do this? – Peter Taylor – 2013-04-05T13:58:08.437
Such as? The only one I am aware of is PHP, but the easter_date and easter_days functions are quite limited, easter_date only works for years after 1970 and easter_days doesn't return the correct amount of days for years prior to 1753. But I will edit the question to disallow the use of such functions. – Fors – 2013-04-05T14:06:49.913
R has a function
Easter
in packagetimeDate
that works for any year of the gregorian calendar. – plannapus – 2013-04-05T14:09:33.8031
resource: http://en.wikipedia.org/wiki/Computus#Algorithms
– John Dvorak – 2013-04-05T14:32:57.4431So this is Gregorian and NOT Julian? Also, I'm not Catholic, what is the "Catholic Tradition?" – jdstankosky – 2013-04-05T16:20:11.233
What's the scoring method? Fewest characters? – Mr. Llama – 2013-04-05T17:16:48.890
@jdstankosky, I wrote "according to the Catholic tradition" just to imply that it is Gregorian, I could perhaps clarify it a little. – Fors – 2013-04-05T17:31:36.123
Peter Taylor is correct. The function in Mathematica's Calendar package is
EasterSunday[year]
. No, I won't be submitting it. – DavidC – 2013-04-05T21:43:42.5632More functions – SeanC – 2013-04-09T13:41:32.800
Bearing in mind that ISO 8601 doesn't naturally support years greater than 9999, is the answer required to support them? – Peter Taylor – 2013-04-09T14:44:34.097
@PeterTaylor, a good question. But I do think that the answer at least needs to support years up to 5,701,583, as that is when the cycle of dates recur (and it is doable using signed 32-bit integers). I will update the question and add a couple of test cases. – Fors – 2013-04-11T05:45:57.567
txt file link is an empty file. – sergiol – 2017-01-09T10:52:38.650
@sergiol That's fixed now, I replaced the link with a version cached by archive.org, which should future proof it for quite a while. – Fors – 2017-01-11T15:33:09.163