Skip to content
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

Easter date gauss algorithm #2010

Merged
merged 5 commits into from May 19, 2020
Merged

Conversation

@mateuszz0000
Copy link
Contributor

mateuszz0000 commented May 19, 2020

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}.
@mateuszz0000 mateuszz0000 changed the title Easter date Easter date gauss algorithm May 19, 2020
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
Comment on lines 24 to 33

This comment has been minimized.

Copy link
@cclauss

cclauss May 19, 2020

Member

Single letter variable names are old school and they force the reader to guess a lot to make sense of this algorithm.

This comment has been minimized.

Copy link
@mateuszz0000

mateuszz0000 May 19, 2020

Author Contributor

Should be better now.

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

This comment has been minimized.

Copy link
@cclauss

cclauss May 19, 2020

Member
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
2 checks passed
2 checks passed
codespell
Details
Travis CI - Pull Request Build Passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.