Created
February 21, 2015 18:29
-
-
Save fbwright/e46dad50c90805e3cba8 to your computer and use it in GitHub Desktop.
/r/dailyprogrammer Challenge #202 - Easter Challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( easter.fs 2015-02-21T18.23 by fbwright ) | |
( An implementation of the Butcher's algorithm ) | |
: easter { year -- year month day } | |
year 19 mod { a } year 100 / { b } year 100 mod { c } | |
19 a * b + b 4 / - 15 + b b 8 + 25 / - 1 + 3 / - 30 mod { d } | |
32 b 4 mod 2 * + c 4 / 2 * + d - c 4 mod - 7 mod { e } | |
d e + 114 + d 11 * a + e 22 * + 451 / 7 * - { f } | |
f 31 mod 1+ ( day ) f 31 / ( month ) year ; | |
: test ( -- ) cr | |
2014 easter . . . cr ( Should be 2014 4 20 ) | |
2015 easter . . . cr ( Should be 2015 4 5 ) | |
2016 easter . . . cr ( Should be 2016 3 27 ) | |
2017 easter . . . cr ( Should be 2017 4 16 ) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment