r/ProgrammerHumor • • May 16 '20

The meaning of everything

Post image
35.0k Upvotes

533 comments sorted by

View all comments

Show parent comments

31

u/Muhznit May 16 '20 edited May 16 '20

They aren't. Want proof? Try writing an algorithm that will tell you when easter occurs for a given year.

EDIT: I hadn't expected people to jump up to the challenge, but the amount of people starting their solutions with "Given ____..." kind of hints at how non-straightforward it is.

35

u/tinydonuts May 16 '20

Oh I know they're not. The other dude thought so though... JuSt UsE a LiBrArY.

29

u/MokitTheOmniscient May 16 '20

I guess it's not hard if someone else does it for you.

8

u/tinydonuts May 16 '20

My point precisely.

0

u/[deleted] May 16 '20

[deleted]

2

u/MokitTheOmniscient May 16 '20

The fact that it's not hard for the end user doesn't mean that it's not hard.

A lot of smart scientists worked for decades to develop those technologies.

1

u/Even-Understanding May 16 '20

My employer does. It’s clearly salmon

20

u/[deleted] May 16 '20

[removed] — view removed comment

30

u/AegisToast May 16 '20

“year is undefined”

5

u/WilliamMButtlickerJr May 16 '20

Found the JavaScript programmer that makes comments in python syntax so he won’t get found out

3

u/[deleted] May 16 '20

[removed] — view removed comment

2

u/WilliamMButtlickerJr May 16 '20

Haha I was just messing around, I meant no offense :P

9

u/EirIroh May 16 '20

Given dates of the equinox and full moon occurences, it’s pretty simple. Missing any of those, you suddenly have a much larger task.

9

u/Meshiest May 16 '20

Tried my hand at it using suncalc.js to calculate full moons from sun and moon positions and only got 89% success for 600 Easters from 1700-2299.

Please excuse the absolute garbage javascript, it's 2am for me.

source website

-4

u/[deleted] May 16 '20

89% success rate is pretty shit. If I wrote a program that only succeeded 89% of the time it would not get past code review

13

u/sea___ May 16 '20

I think his point was that be found it difficult to achieve a good result

4

u/Meshiest May 16 '20

If anything I proved his point

4

u/Meshiest May 16 '20 edited May 16 '20

It actually calculates astrological easters with higher accuracy than Gregorian Easters. I just got lazy when I realized that and went to sleep

edit: a character

2

u/Mwarw May 16 '20

Give me access to pre-made:
-What weekday is given date
-What moonphase is at given date
-Some ok Date data structure, and it would be something like:

Date day = firstSpringDay; //firstSpringDay would be constant in code, don't remember that day today
day.year = calculatedYear;
bool wasFullMoon = false;
while(1){
    if(GetMoonPhase(day) == MoonPhases::Full){
        wasFullMoon = true;
    }
    //not sure if sunday in fullmoon counts, if not it would be elseif here 
    if(wasFullMoon && GetWeekDay(day) == WeekDay::Sunday){
        return day;
    }
    day.day++;
}

1

u/Meshiest May 16 '20

I tried that. Turns out that's only astrological easters. dateutil's solution is full of magic numbers and less trig to get the Gregorian ones