language-agnosticcode-golfrosetta-stone

Code Golf: Calculate Orthodox Easter date


The Challenge

Calculate the Date of the Greek Orthodox Easter (http://www.timeanddate.com/holidays/us/orthodox-easter-day) Sunday in a given Year (1900-2100) using the least amount of characters.

Input is just a year in the form '2010'. It's not relevant where you get it (Input, CommandLineArgs etc.) but it must be dynamic!

Output should be in the form day-month-year (say dd/mm/yyyy or d/m/yyyy)

Restrictions No standard functions, such as Mathematica's EasterSundayGreekOrthodox or PHP's easter_date(), which return the (not applicable gregorian) date automatic must be used!

Examples

2005 returns 1/5/2005
2006 returns 23/4/2006
2007 returns 8/4/2007
2008 returns 27/4/2008
2009 returns 19/4/2009
2010 returns 4/4/2010
2011 returns 24/4/2011
2012 returns 15/4/2012
2013 returns 5/5/2013
2014 returns 20/4/2014
2015 returns 12/4/2015

Code count includes input/output (i.e full program).

Edit: I mean the Eastern Easter Date.

Reference: http://en.wikipedia.org/wiki/Computus


Solution

  • Python (101 140 132 115 chars)

    y=input()
    d=(y%19*19+15)%30
    e=(y%4*2+y%7*4-d+34)%7+d+127
    m=e/31
    a=e%31+1+(m>4)
    if a>30:a,m=1,5
    print a,'/',m,'/',y
    

    This one uses the Meeus Julian algorithm but since this one only works between 1900 and 2099, an implementation using Anonymous Gregorian algorithm is coming right up.

    Edit: Now 2005 is properly handled. Thanks to Mark for pointing it out.

    Edit 2: Better handling of some years, thanks for all the input!

    Edit 3: Should work for all years in range. (Sorry for hijacking it Juan.)