## Passover

### March 30, 2010

The Jewish holiday of Passover celebrates the biblical event when, during the Jewish captivity in Egypt, God killed the first-born child of every person and cattle in Egypt, except in those homes whose doorposts were marked with the blood of a spring lamb, which were passed over; as a result, the Jewish people were able to escape enslavement in Egypt.

Passover is celebrated on the date of the first full moon after the spring equinox, with some adjustments. British mathematician John Horton Conway gives this algorithm for calculating the date of Passover:

First, calculate the date of Rosh Hashanah, the Jewish new year. In gregorian year *y* of the common era, Rosh Hashanah falls on September *n*, where:

`g = remainder(y/19) + 1`

`n + fraction =`

( floor(y/100) - floor(y/400) - 2)

+ 765433/492480 × remainder(12g/19)

+ remainder(y/4) / 4

- (313y + 89081) / 98496

The calculation of *n* is subject to the following postponement rules:

- If the day calculated above is a Sunday, Wednesday, or Friday, Rosh Hashanah falls on the next day (i.e., Monday, Thursday or Saturday, respectively).
- If the day calculated above is a Monday, and if the fraction is greater than or equal to 23269/25920, and if
`remainder(12g/19)`

is greater than 11, Rosh Hashanah falls on the next day, a Tuesday. - If the day calculated above is a Tuesday, and if the fraction is greater than or equal to 1367/2160, and if
`remainder(12g/19)`

is greater than 11, Rosh Hashanah falls two days later, on Thursday.

Given the date of Rosh Hashanah, the date of Passover in the same calendar year is calculated as *m* days after March 21, where *m* is the day of September on which Rosh Hashanah falls, if Rosh Hashanah is in September, or thirty plus the day of October on which Rosh Hashanah falls, if Rosh Hashanah is in October.

According to Jewish custom, the holiday actually begins at sunset on the day prior to that calculated above.

Your task is to write functions that calculate the dates of Rosh Hashanah and Passover for any given calendar year. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

[...] Praxis – Passover By Remco Niemeijer In today’s Programming Praxis exercise we have to write functions to calculate the dates of the Jewish [...]

My Haskell solution (see http://bonsaicode.wordpress.com/2010/03/30/programming-praxis-passover/ for a version with comments):

Python: