-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Easter date gauss algorithm #2010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
other/gauss_easter.py
Outdated
a = year % 19 | ||
b = year % 4 | ||
c = year % 7 | ||
k = math.floor(year / 100) | ||
p = math.floor((13 + 8 * k) / 25) | ||
q = k / 4 | ||
M = (15 - p + k - q) % 30 | ||
N = (4 + k - q) % 7 | ||
d = (19 * a + M) % 30 | ||
e = (2 * b + 4 * c + 6 * d + N) % 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single letter variable names are old school and they force the reader to guess a lot to make sense of this algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be better now.
other/gauss_easter.py
Outdated
print(f"Easter in 2023 will be {gauss_easter(2023)}") | ||
print(f"Easter in 2021 will be {gauss_easter(2021)}") | ||
print(f"Easter in 2010 was {gauss_easter(2010)}") | ||
print(f"Easter in 1994 was {gauss_easter(1994)}") | ||
print(f"Easter in 2000 was {gauss_easter(2000)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(f"Easter in 2023 will be {gauss_easter(2023)}") | |
print(f"Easter in 2021 will be {gauss_easter(2021)}") | |
print(f"Easter in 2010 was {gauss_easter(2010)}") | |
print(f"Easter in 1994 was {gauss_easter(1994)}") | |
print(f"Easter in 2000 was {gauss_easter(2000)}") | |
for year in (1994, 2000, 2010, 2021, 2023): | |
tense = "will be" if year > datetime.now().year else "was" | |
print(f"Easter in {year} {tense} {gauss_easter(year)}") |
* Added gauss easter algorithm * Fixes in easter algorithm * Commit suggestions
Describe your change:
Added Gauss algorithm to calculate easter date for given year. Source: https://en.wikipedia.org/wiki/Computus#Gauss'_Easter_algorithm
Checklist:
Fixes: #{$ISSUE_NO}
.