Skip to content

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

Merged
merged 5 commits into from
May 19, 2020
Merged

Conversation

l3str4nge
Copy link
Member

Describe your change:

Added Gauss algorithm to calculate easter date for given year. Source: https://en.wikipedia.org/wiki/Computus#Gauss'_Easter_algorithm

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@l3str4nge l3str4nge changed the title Easter date Easter date gauss algorithm May 19, 2020
Comment on lines 24 to 33
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
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be better now.

Comment on lines 44 to 48
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)}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)}")

@cclauss cclauss merged commit 2431001 into TheAlgorithms:master May 19, 2020
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Added gauss easter algorithm

* Fixes in easter algorithm

* Commit suggestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants