Author Topic: Easter Calculator  (Read 3214 times)

0 Members and 1 Guest are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Easter Calculator
« on: January 31, 2014, 05:08:11 pm »
Here is code in TI-BASIC to calculate the day of Easter Sunday.
Code: [Select]
ClrHome
Input "YEAR?           ",Y
int(Y/E2             //Scientific E, not the variable E
50-30fPart((11(1+19fPart(Y/19))-Ans+int(Ans/4)+int(8(Ans+11)/25))/30
Ans+7-round(7fPart((int(23(3+(Ans>31))/9)+Ans-31(Ans>31)+2+Y+int(Y/4)-int(V/E2)+int(Y/400))/7),0
If Ans=50 or Ans=49 and 10<19fPart(Y/19
Ans-1
Disp sub("MARCHAPRIL",1+5(Ans>31),5
Output(3,7,round(Ans-31(Ans>31),0

Whaddaya think? Any improvements?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Easter Calculator
« Reply #1 on: January 31, 2014, 05:44:25 pm »
That's a nice segment of code. I never knew there was so much math in determining the day Easter was on  ;)
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Easter Calculator
« Reply #2 on: January 31, 2014, 05:45:22 pm »
Not really.

There's so much math in calculating the Paschal Full Moon.

Once that is known, then Easter is the Sunday after.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Easter Calculator
« Reply #3 on: January 31, 2014, 07:02:25 pm »
Wait wow, I didn't know Easter was determined like that lol. Anyway, nice :D

Offline utz

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 161
  • Rating: +28/-0
    • View Profile
    • official hp - music, demos, and more
Re: Easter Calculator
« Reply #4 on: February 01, 2014, 11:30:18 am »
Supermarkets over here are already selling chocolate bunnies, so according to my calculations Easter is happening ... pretty damn soon enough :p

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Easter Calculator
« Reply #5 on: February 01, 2014, 03:00:02 pm »
I'm not getting the right dates according to Wikipedia :/

Starting in 2012, it is off by 1, before that, it's just off. I copied it to Source Coder and edited the E2 things to be the correct one.

EDIT: Also, for suggestions, sub() can be used to divide by 100, using the fPart() method to do modulo has issues with rounding error, causing it to pass unexpected results, so you should use the int() method:
Code: [Select]
X-Nint(X/N
And you will save some more bytes by computing some of the constants and using the inverse token. For example, see these two lines:
Code: [Select]
50-30fPart((11(1+19fPart(Y/19))-Ans+int(Ans/4)+int(8(Ans+11)/25))/30
50-30fPart(30{^-1}(11+209fPart(Y/19)-Ans+int(Ans/4)+int(.32(Ans+11

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Easter Calculator
« Reply #6 on: February 01, 2014, 10:11:01 pm »
OK, here's the code that should eliminate all rounding errors (unoptimized):

Code: [Select]
:int(Y/ᴇ2
:50-30fPart((11(1+19fPart(Y/19))-Ans+int(Ans/4)+int(8(Ans+11)/25))/30
:If Ans=50 or Ans=49 and 11≤19fPart(Y/19
:Ans-1
:round(Ans+7-7fPart((int(23(3+(Ans>31))/9)+Ans-31(Ans>31)+2+Y+int(Y/4)-int(Y/ᴇ2)+int(Y/400))/7),0

Optmizing soon.

Oh, and Xeda? That's what the final line's round( is for. To eliminate rounding errors.

And I tested, and the dates are correct.
« Last Edit: February 01, 2014, 10:12:22 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Easter Calculator
« Reply #7 on: February 02, 2014, 03:42:13 am »
Wait wow, I didn't know Easter was determined like that lol. Anyway, nice :D
I thought it was first sunday after first fullmoon after the astronomic beginning of spring ???

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Easter Calculator
« Reply #8 on: February 02, 2014, 12:55:35 pm »
Wait wow, I didn't know Easter was determined like that lol. Anyway, nice :D
I thought it was first sunday after first fullmoon after the astronomic beginning of spring ???

It is.

The Paschal Full Moon is basically that. The first full moon after the astronomic beginning of spring.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?