Front page | perl.golf |
Postings from September 2002
Collaborative golf.
Thread Next
From:
Piers Cawley
Date:
September 14, 2002 00:49
Subject:
Collaborative golf.
Message ID:
84bs71gghg.fsf@despairon.bofh.org.uk
So, whilst rambling, I came upon the calculations required to work out
the date of easter for a given year (Gregorian calendar). Here it is
expressed in perl.
my $year = pop;
my $G = $year%19;
my $C = int($year/100);
my $H = ($C - $C/4 - int((8*$C+13)/25) + 19*$G + 15) %30;
$I = $H - int($H/28)*(1 - int($H/28) * int(29/($H+1)) * int(21-$G/11));
$J = ($year + int($year/4) + $I + 2 - $C + int($C/4))%7;
$L = $I - $J;
$month = 3 + int(($L+40)/44);
$day = $L + 28 - 31 * int($month/4);
printf("%d%02d%02d\n", $year, $month, $day);
I'm sure we can do better. But how *much* better?
My current best effort stands at 212 chars (scored by wc), which I'll
post later today, unless someone has already done better.
Kudos will be given to anyone who does it in a regex...
--
Piers
"It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite."
-- Jane Austen?
Thread Next
-
Collaborative golf.
by Piers Cawley