Easter Bar Graph Announcing the arrival of Valued Associate #679: Cesar Manara ...

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

What makes black pepper strong or mild?

Why is "Captain Marvel" translated as male in Portugal?

How to deal with a team lead who never gives me credit?

How much radiation do nuclear physics experiments expose researchers to nowadays?

Letter Boxed validator

What would be the ideal power source for a cybernetic eye?

Stars Make Stars

Single word antonym of "flightless"

What is the longest distance a 13th-level monk can jump while attacking on the same turn?

Using et al. for a last / senior author rather than for a first author

G-Code for resetting to 100% speed

What do you call a plan that's an alternative plan in case your initial plan fails?

Why aren't air breathing engines used as small first stages

When is phishing education going too far?

How to find all the available tools in macOS terminal?

Why was the term "discrete" used in discrete logarithm?

Sorting numerically

How do I mention the quality of my school without bragging

Do I really need recursive chmod to restrict access to a folder?

How to draw this diagram using TikZ package?

Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?

Is the address of a local variable a constexpr?

Storing hydrofluoric acid before the invention of plastics



Easter Bar Graph



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Find easter on any given yearCoding adjacency list representing graphCounting letters program with ASCII-art graphClone of an undirected graphGraph implementation adjacency list 2.0Strongly connected components, component graph, semiconnected graph and new graph from SCCsGraph Library in CGet a path between graph nodes using breadth-first searchIndeterminate progress bar with Raspberry PiSplitting a rectangular chocolate barSysinfo parser for a window manager status bar





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0












$begingroup$


Computing Easter for a given year is a classic computational problem.



It is also one of the few cases when code seems to just have to live with magic numbers.



Alternative to magic numbers: Decoding Gauss' Easter Algorithm



So I thought today, I'd make a bar graph.



C99 Review goal: General coding comments, style, etc.



// easter.h
// chux: April 15, 2019

#ifndef EASTER_H
#define EASTER_H

#define EASTER_EPOCH_YEAR 33
#define EASTER_JULIAN_YEAR EASTER_EPOCH_YEAR
#define EASTER_GREGORIAN_EPOCH_YEAR 1582 /* 15 October 1582 */
#define EASTER_JULIAN_PERIOD 532
#define EASTER_GREGORIAN_PERIOD 5700000

typedef struct ymd {
int y, m, d;
} ymd;

ymd Easter_DateJulian(int year);
ymd Easter_DateGregorian(int year);
ymd Easter_Date(int year);

#endif

// easter.c

/*
* Anonymous Gregorian algorithm: Meeus/Jones/Butcher
* * Dates of Easter
* Astronomical Algorithms 1991
* Jean Meeus
* https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
*
* Meeus's Julian algorithm
* https://en.wikipedia.org/wiki/Computus#Meeus's_Julian_algorithm
*/
ymd Easter_DateJulian(int year) {
if (year < EASTER_EPOCH_YEAR) {
return (ymd) {0, 0, 0};
}
int a = year % 4;
int b = year % 7;
int c = year % 19;
int d = (19 * c + 15) % 30;
int e = (2 * a + 4 * b - d + 34) % 7;
int f = (d + e + 114) / 31;
int g = (d + e + 114) % 31;
return (ymd) {year, f, g + 1};
}

ymd Easter_DateGregorian(int year) {
if (year <= EASTER_GREGORIAN_EPOCH_YEAR) {
return (ymd) {0, 0, 0};
}
int a = year%19;
int b = year/100;
int c = year%100;
int d = b/4;
int e = b%4;
int f = (b+8)/25;
int g = (b-f+1)/3;
int h = (19*a + b - d - g + 15)%30;
int i = c/4;
int k = c%4;
int l = (32 + 2*e + 2*i - h - k)%7;
int m = (a+11*h + 22*l) / 451;
int n = (h + l - 7 *m + 114)/31;
int p = (h + l - 7 *m + 114)%31;
return (ymd) {year, n, p+1};
}

ymd Easter_Date(int year) {
return (year > EASTER_GREGORIAN_EPOCH_YEAR) ?
Easter_DateGregorian(year) : Easter_DateJulian(year);
}


Test



// main.c

// **Alternate code used as a check**
// Find easter on any given year
// https://codereview.stackexchange.com/questions/193847/find-easter-on-any-given-year
// Decoding Gauss' Easter Algorithm
// https://math.stackexchange.com/q/896954/83175

static ymd Easter(int year) {
int a = year%19;
int b = year/100;
int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30;
int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11));
int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7);
int month = 3 + ((e + 40)/44);
int day = e + 28 - (31*(month/4));
return (ymd) {year, month , day};
}

#include <assert.h>
#include <stdio.h>

int main(void) {
int count[5][32] = { 0 };
for (int year = EASTER_GREGORIAN_EPOCH_YEAR + 1;
year <= EASTER_GREGORIAN_EPOCH_YEAR + EASTER_GREGORIAN_PERIOD;
year++) {
ymd e1 = Easter_Date(year);
ymd e2 = Easter(year);
if (e1.d != e2.d) {
printf("%5d-%02d-%02d ", e1.y, e1.m, e1.d);
printf("%5d-%02d-%02d ", e2.y, e2.m, e2.d);
puts("");
}
assert(e1.m >= 3 && e1.m <=4);
assert(e1.d >= 1 && e1.d <=31);
count[e1.m][e1.d]++;
}
for (int m = 3; m <= 4; m++) {
for (int d = 1; d <= 31; d++) {
if (count[m][d]) {
double permill = round(1000.0*count[m][d]/EASTER_GREGORIAN_PERIOD);
printf("%d, %2d, %3.1f%%, %0*dn", m, d, permill/10, (int) permill, 0);
}
}
}
return 0;
}


Output: Month, Day, Percentage, Graph



3, 22, 0.5%, 00000
3, 23, 1.0%, 0000000000
3, 24, 1.4%, 00000000000000
3, 25, 1.9%, 0000000000000000000
3, 26, 2.3%, 00000000000000000000000
3, 27, 2.9%, 00000000000000000000000000000
3, 28, 3.3%, 000000000000000000000000000000000
3, 29, 3.4%, 0000000000000000000000000000000000
3, 30, 3.3%, 000000000000000000000000000000000
3, 31, 3.3%, 000000000000000000000000000000000
4, 1, 3.4%, 0000000000000000000000000000000000
4, 2, 3.3%, 000000000000000000000000000000000
4, 3, 3.4%, 0000000000000000000000000000000000
4, 4, 3.3%, 000000000000000000000000000000000
4, 5, 3.4%, 0000000000000000000000000000000000
4, 6, 3.3%, 000000000000000000000000000000000
4, 7, 3.3%, 000000000000000000000000000000000
4, 8, 3.4%, 0000000000000000000000000000000000
4, 9, 3.3%, 000000000000000000000000000000000
4, 10, 3.4%, 0000000000000000000000000000000000
4, 11, 3.3%, 000000000000000000000000000000000
4, 12, 3.4%, 0000000000000000000000000000000000
4, 13, 3.3%, 000000000000000000000000000000000
4, 14, 3.3%, 000000000000000000000000000000000
4, 15, 3.4%, 0000000000000000000000000000000000
4, 16, 3.3%, 000000000000000000000000000000000
4, 17, 3.4%, 0000000000000000000000000000000000
4, 18, 3.5%, 00000000000000000000000000000000000
4, 19, 3.9%, 000000000000000000000000000000000000000
4, 20, 3.3%, 000000000000000000000000000000000 <-- 2019
4, 21, 2.9%, 00000000000000000000000000000
4, 22, 2.4%, 000000000000000000000000
4, 23, 1.9%, 0000000000000000000
4, 24, 1.5%, 000000000000000
4, 25, 0.7%, 0000000








share









$endgroup$



















    0












    $begingroup$


    Computing Easter for a given year is a classic computational problem.



    It is also one of the few cases when code seems to just have to live with magic numbers.



    Alternative to magic numbers: Decoding Gauss' Easter Algorithm



    So I thought today, I'd make a bar graph.



    C99 Review goal: General coding comments, style, etc.



    // easter.h
    // chux: April 15, 2019

    #ifndef EASTER_H
    #define EASTER_H

    #define EASTER_EPOCH_YEAR 33
    #define EASTER_JULIAN_YEAR EASTER_EPOCH_YEAR
    #define EASTER_GREGORIAN_EPOCH_YEAR 1582 /* 15 October 1582 */
    #define EASTER_JULIAN_PERIOD 532
    #define EASTER_GREGORIAN_PERIOD 5700000

    typedef struct ymd {
    int y, m, d;
    } ymd;

    ymd Easter_DateJulian(int year);
    ymd Easter_DateGregorian(int year);
    ymd Easter_Date(int year);

    #endif

    // easter.c

    /*
    * Anonymous Gregorian algorithm: Meeus/Jones/Butcher
    * * Dates of Easter
    * Astronomical Algorithms 1991
    * Jean Meeus
    * https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
    *
    * Meeus's Julian algorithm
    * https://en.wikipedia.org/wiki/Computus#Meeus's_Julian_algorithm
    */
    ymd Easter_DateJulian(int year) {
    if (year < EASTER_EPOCH_YEAR) {
    return (ymd) {0, 0, 0};
    }
    int a = year % 4;
    int b = year % 7;
    int c = year % 19;
    int d = (19 * c + 15) % 30;
    int e = (2 * a + 4 * b - d + 34) % 7;
    int f = (d + e + 114) / 31;
    int g = (d + e + 114) % 31;
    return (ymd) {year, f, g + 1};
    }

    ymd Easter_DateGregorian(int year) {
    if (year <= EASTER_GREGORIAN_EPOCH_YEAR) {
    return (ymd) {0, 0, 0};
    }
    int a = year%19;
    int b = year/100;
    int c = year%100;
    int d = b/4;
    int e = b%4;
    int f = (b+8)/25;
    int g = (b-f+1)/3;
    int h = (19*a + b - d - g + 15)%30;
    int i = c/4;
    int k = c%4;
    int l = (32 + 2*e + 2*i - h - k)%7;
    int m = (a+11*h + 22*l) / 451;
    int n = (h + l - 7 *m + 114)/31;
    int p = (h + l - 7 *m + 114)%31;
    return (ymd) {year, n, p+1};
    }

    ymd Easter_Date(int year) {
    return (year > EASTER_GREGORIAN_EPOCH_YEAR) ?
    Easter_DateGregorian(year) : Easter_DateJulian(year);
    }


    Test



    // main.c

    // **Alternate code used as a check**
    // Find easter on any given year
    // https://codereview.stackexchange.com/questions/193847/find-easter-on-any-given-year
    // Decoding Gauss' Easter Algorithm
    // https://math.stackexchange.com/q/896954/83175

    static ymd Easter(int year) {
    int a = year%19;
    int b = year/100;
    int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30;
    int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11));
    int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7);
    int month = 3 + ((e + 40)/44);
    int day = e + 28 - (31*(month/4));
    return (ymd) {year, month , day};
    }

    #include <assert.h>
    #include <stdio.h>

    int main(void) {
    int count[5][32] = { 0 };
    for (int year = EASTER_GREGORIAN_EPOCH_YEAR + 1;
    year <= EASTER_GREGORIAN_EPOCH_YEAR + EASTER_GREGORIAN_PERIOD;
    year++) {
    ymd e1 = Easter_Date(year);
    ymd e2 = Easter(year);
    if (e1.d != e2.d) {
    printf("%5d-%02d-%02d ", e1.y, e1.m, e1.d);
    printf("%5d-%02d-%02d ", e2.y, e2.m, e2.d);
    puts("");
    }
    assert(e1.m >= 3 && e1.m <=4);
    assert(e1.d >= 1 && e1.d <=31);
    count[e1.m][e1.d]++;
    }
    for (int m = 3; m <= 4; m++) {
    for (int d = 1; d <= 31; d++) {
    if (count[m][d]) {
    double permill = round(1000.0*count[m][d]/EASTER_GREGORIAN_PERIOD);
    printf("%d, %2d, %3.1f%%, %0*dn", m, d, permill/10, (int) permill, 0);
    }
    }
    }
    return 0;
    }


    Output: Month, Day, Percentage, Graph



    3, 22, 0.5%, 00000
    3, 23, 1.0%, 0000000000
    3, 24, 1.4%, 00000000000000
    3, 25, 1.9%, 0000000000000000000
    3, 26, 2.3%, 00000000000000000000000
    3, 27, 2.9%, 00000000000000000000000000000
    3, 28, 3.3%, 000000000000000000000000000000000
    3, 29, 3.4%, 0000000000000000000000000000000000
    3, 30, 3.3%, 000000000000000000000000000000000
    3, 31, 3.3%, 000000000000000000000000000000000
    4, 1, 3.4%, 0000000000000000000000000000000000
    4, 2, 3.3%, 000000000000000000000000000000000
    4, 3, 3.4%, 0000000000000000000000000000000000
    4, 4, 3.3%, 000000000000000000000000000000000
    4, 5, 3.4%, 0000000000000000000000000000000000
    4, 6, 3.3%, 000000000000000000000000000000000
    4, 7, 3.3%, 000000000000000000000000000000000
    4, 8, 3.4%, 0000000000000000000000000000000000
    4, 9, 3.3%, 000000000000000000000000000000000
    4, 10, 3.4%, 0000000000000000000000000000000000
    4, 11, 3.3%, 000000000000000000000000000000000
    4, 12, 3.4%, 0000000000000000000000000000000000
    4, 13, 3.3%, 000000000000000000000000000000000
    4, 14, 3.3%, 000000000000000000000000000000000
    4, 15, 3.4%, 0000000000000000000000000000000000
    4, 16, 3.3%, 000000000000000000000000000000000
    4, 17, 3.4%, 0000000000000000000000000000000000
    4, 18, 3.5%, 00000000000000000000000000000000000
    4, 19, 3.9%, 000000000000000000000000000000000000000
    4, 20, 3.3%, 000000000000000000000000000000000 <-- 2019
    4, 21, 2.9%, 00000000000000000000000000000
    4, 22, 2.4%, 000000000000000000000000
    4, 23, 1.9%, 0000000000000000000
    4, 24, 1.5%, 000000000000000
    4, 25, 0.7%, 0000000








    share









    $endgroup$















      0












      0








      0





      $begingroup$


      Computing Easter for a given year is a classic computational problem.



      It is also one of the few cases when code seems to just have to live with magic numbers.



      Alternative to magic numbers: Decoding Gauss' Easter Algorithm



      So I thought today, I'd make a bar graph.



      C99 Review goal: General coding comments, style, etc.



      // easter.h
      // chux: April 15, 2019

      #ifndef EASTER_H
      #define EASTER_H

      #define EASTER_EPOCH_YEAR 33
      #define EASTER_JULIAN_YEAR EASTER_EPOCH_YEAR
      #define EASTER_GREGORIAN_EPOCH_YEAR 1582 /* 15 October 1582 */
      #define EASTER_JULIAN_PERIOD 532
      #define EASTER_GREGORIAN_PERIOD 5700000

      typedef struct ymd {
      int y, m, d;
      } ymd;

      ymd Easter_DateJulian(int year);
      ymd Easter_DateGregorian(int year);
      ymd Easter_Date(int year);

      #endif

      // easter.c

      /*
      * Anonymous Gregorian algorithm: Meeus/Jones/Butcher
      * * Dates of Easter
      * Astronomical Algorithms 1991
      * Jean Meeus
      * https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
      *
      * Meeus's Julian algorithm
      * https://en.wikipedia.org/wiki/Computus#Meeus's_Julian_algorithm
      */
      ymd Easter_DateJulian(int year) {
      if (year < EASTER_EPOCH_YEAR) {
      return (ymd) {0, 0, 0};
      }
      int a = year % 4;
      int b = year % 7;
      int c = year % 19;
      int d = (19 * c + 15) % 30;
      int e = (2 * a + 4 * b - d + 34) % 7;
      int f = (d + e + 114) / 31;
      int g = (d + e + 114) % 31;
      return (ymd) {year, f, g + 1};
      }

      ymd Easter_DateGregorian(int year) {
      if (year <= EASTER_GREGORIAN_EPOCH_YEAR) {
      return (ymd) {0, 0, 0};
      }
      int a = year%19;
      int b = year/100;
      int c = year%100;
      int d = b/4;
      int e = b%4;
      int f = (b+8)/25;
      int g = (b-f+1)/3;
      int h = (19*a + b - d - g + 15)%30;
      int i = c/4;
      int k = c%4;
      int l = (32 + 2*e + 2*i - h - k)%7;
      int m = (a+11*h + 22*l) / 451;
      int n = (h + l - 7 *m + 114)/31;
      int p = (h + l - 7 *m + 114)%31;
      return (ymd) {year, n, p+1};
      }

      ymd Easter_Date(int year) {
      return (year > EASTER_GREGORIAN_EPOCH_YEAR) ?
      Easter_DateGregorian(year) : Easter_DateJulian(year);
      }


      Test



      // main.c

      // **Alternate code used as a check**
      // Find easter on any given year
      // https://codereview.stackexchange.com/questions/193847/find-easter-on-any-given-year
      // Decoding Gauss' Easter Algorithm
      // https://math.stackexchange.com/q/896954/83175

      static ymd Easter(int year) {
      int a = year%19;
      int b = year/100;
      int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30;
      int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11));
      int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7);
      int month = 3 + ((e + 40)/44);
      int day = e + 28 - (31*(month/4));
      return (ymd) {year, month , day};
      }

      #include <assert.h>
      #include <stdio.h>

      int main(void) {
      int count[5][32] = { 0 };
      for (int year = EASTER_GREGORIAN_EPOCH_YEAR + 1;
      year <= EASTER_GREGORIAN_EPOCH_YEAR + EASTER_GREGORIAN_PERIOD;
      year++) {
      ymd e1 = Easter_Date(year);
      ymd e2 = Easter(year);
      if (e1.d != e2.d) {
      printf("%5d-%02d-%02d ", e1.y, e1.m, e1.d);
      printf("%5d-%02d-%02d ", e2.y, e2.m, e2.d);
      puts("");
      }
      assert(e1.m >= 3 && e1.m <=4);
      assert(e1.d >= 1 && e1.d <=31);
      count[e1.m][e1.d]++;
      }
      for (int m = 3; m <= 4; m++) {
      for (int d = 1; d <= 31; d++) {
      if (count[m][d]) {
      double permill = round(1000.0*count[m][d]/EASTER_GREGORIAN_PERIOD);
      printf("%d, %2d, %3.1f%%, %0*dn", m, d, permill/10, (int) permill, 0);
      }
      }
      }
      return 0;
      }


      Output: Month, Day, Percentage, Graph



      3, 22, 0.5%, 00000
      3, 23, 1.0%, 0000000000
      3, 24, 1.4%, 00000000000000
      3, 25, 1.9%, 0000000000000000000
      3, 26, 2.3%, 00000000000000000000000
      3, 27, 2.9%, 00000000000000000000000000000
      3, 28, 3.3%, 000000000000000000000000000000000
      3, 29, 3.4%, 0000000000000000000000000000000000
      3, 30, 3.3%, 000000000000000000000000000000000
      3, 31, 3.3%, 000000000000000000000000000000000
      4, 1, 3.4%, 0000000000000000000000000000000000
      4, 2, 3.3%, 000000000000000000000000000000000
      4, 3, 3.4%, 0000000000000000000000000000000000
      4, 4, 3.3%, 000000000000000000000000000000000
      4, 5, 3.4%, 0000000000000000000000000000000000
      4, 6, 3.3%, 000000000000000000000000000000000
      4, 7, 3.3%, 000000000000000000000000000000000
      4, 8, 3.4%, 0000000000000000000000000000000000
      4, 9, 3.3%, 000000000000000000000000000000000
      4, 10, 3.4%, 0000000000000000000000000000000000
      4, 11, 3.3%, 000000000000000000000000000000000
      4, 12, 3.4%, 0000000000000000000000000000000000
      4, 13, 3.3%, 000000000000000000000000000000000
      4, 14, 3.3%, 000000000000000000000000000000000
      4, 15, 3.4%, 0000000000000000000000000000000000
      4, 16, 3.3%, 000000000000000000000000000000000
      4, 17, 3.4%, 0000000000000000000000000000000000
      4, 18, 3.5%, 00000000000000000000000000000000000
      4, 19, 3.9%, 000000000000000000000000000000000000000
      4, 20, 3.3%, 000000000000000000000000000000000 <-- 2019
      4, 21, 2.9%, 00000000000000000000000000000
      4, 22, 2.4%, 000000000000000000000000
      4, 23, 1.9%, 0000000000000000000
      4, 24, 1.5%, 000000000000000
      4, 25, 0.7%, 0000000








      share









      $endgroup$




      Computing Easter for a given year is a classic computational problem.



      It is also one of the few cases when code seems to just have to live with magic numbers.



      Alternative to magic numbers: Decoding Gauss' Easter Algorithm



      So I thought today, I'd make a bar graph.



      C99 Review goal: General coding comments, style, etc.



      // easter.h
      // chux: April 15, 2019

      #ifndef EASTER_H
      #define EASTER_H

      #define EASTER_EPOCH_YEAR 33
      #define EASTER_JULIAN_YEAR EASTER_EPOCH_YEAR
      #define EASTER_GREGORIAN_EPOCH_YEAR 1582 /* 15 October 1582 */
      #define EASTER_JULIAN_PERIOD 532
      #define EASTER_GREGORIAN_PERIOD 5700000

      typedef struct ymd {
      int y, m, d;
      } ymd;

      ymd Easter_DateJulian(int year);
      ymd Easter_DateGregorian(int year);
      ymd Easter_Date(int year);

      #endif

      // easter.c

      /*
      * Anonymous Gregorian algorithm: Meeus/Jones/Butcher
      * * Dates of Easter
      * Astronomical Algorithms 1991
      * Jean Meeus
      * https://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
      *
      * Meeus's Julian algorithm
      * https://en.wikipedia.org/wiki/Computus#Meeus's_Julian_algorithm
      */
      ymd Easter_DateJulian(int year) {
      if (year < EASTER_EPOCH_YEAR) {
      return (ymd) {0, 0, 0};
      }
      int a = year % 4;
      int b = year % 7;
      int c = year % 19;
      int d = (19 * c + 15) % 30;
      int e = (2 * a + 4 * b - d + 34) % 7;
      int f = (d + e + 114) / 31;
      int g = (d + e + 114) % 31;
      return (ymd) {year, f, g + 1};
      }

      ymd Easter_DateGregorian(int year) {
      if (year <= EASTER_GREGORIAN_EPOCH_YEAR) {
      return (ymd) {0, 0, 0};
      }
      int a = year%19;
      int b = year/100;
      int c = year%100;
      int d = b/4;
      int e = b%4;
      int f = (b+8)/25;
      int g = (b-f+1)/3;
      int h = (19*a + b - d - g + 15)%30;
      int i = c/4;
      int k = c%4;
      int l = (32 + 2*e + 2*i - h - k)%7;
      int m = (a+11*h + 22*l) / 451;
      int n = (h + l - 7 *m + 114)/31;
      int p = (h + l - 7 *m + 114)%31;
      return (ymd) {year, n, p+1};
      }

      ymd Easter_Date(int year) {
      return (year > EASTER_GREGORIAN_EPOCH_YEAR) ?
      Easter_DateGregorian(year) : Easter_DateJulian(year);
      }


      Test



      // main.c

      // **Alternate code used as a check**
      // Find easter on any given year
      // https://codereview.stackexchange.com/questions/193847/find-easter-on-any-given-year
      // Decoding Gauss' Easter Algorithm
      // https://math.stackexchange.com/q/896954/83175

      static ymd Easter(int year) {
      int a = year%19;
      int b = year/100;
      int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30;
      int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11));
      int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7);
      int month = 3 + ((e + 40)/44);
      int day = e + 28 - (31*(month/4));
      return (ymd) {year, month , day};
      }

      #include <assert.h>
      #include <stdio.h>

      int main(void) {
      int count[5][32] = { 0 };
      for (int year = EASTER_GREGORIAN_EPOCH_YEAR + 1;
      year <= EASTER_GREGORIAN_EPOCH_YEAR + EASTER_GREGORIAN_PERIOD;
      year++) {
      ymd e1 = Easter_Date(year);
      ymd e2 = Easter(year);
      if (e1.d != e2.d) {
      printf("%5d-%02d-%02d ", e1.y, e1.m, e1.d);
      printf("%5d-%02d-%02d ", e2.y, e2.m, e2.d);
      puts("");
      }
      assert(e1.m >= 3 && e1.m <=4);
      assert(e1.d >= 1 && e1.d <=31);
      count[e1.m][e1.d]++;
      }
      for (int m = 3; m <= 4; m++) {
      for (int d = 1; d <= 31; d++) {
      if (count[m][d]) {
      double permill = round(1000.0*count[m][d]/EASTER_GREGORIAN_PERIOD);
      printf("%d, %2d, %3.1f%%, %0*dn", m, d, permill/10, (int) permill, 0);
      }
      }
      }
      return 0;
      }


      Output: Month, Day, Percentage, Graph



      3, 22, 0.5%, 00000
      3, 23, 1.0%, 0000000000
      3, 24, 1.4%, 00000000000000
      3, 25, 1.9%, 0000000000000000000
      3, 26, 2.3%, 00000000000000000000000
      3, 27, 2.9%, 00000000000000000000000000000
      3, 28, 3.3%, 000000000000000000000000000000000
      3, 29, 3.4%, 0000000000000000000000000000000000
      3, 30, 3.3%, 000000000000000000000000000000000
      3, 31, 3.3%, 000000000000000000000000000000000
      4, 1, 3.4%, 0000000000000000000000000000000000
      4, 2, 3.3%, 000000000000000000000000000000000
      4, 3, 3.4%, 0000000000000000000000000000000000
      4, 4, 3.3%, 000000000000000000000000000000000
      4, 5, 3.4%, 0000000000000000000000000000000000
      4, 6, 3.3%, 000000000000000000000000000000000
      4, 7, 3.3%, 000000000000000000000000000000000
      4, 8, 3.4%, 0000000000000000000000000000000000
      4, 9, 3.3%, 000000000000000000000000000000000
      4, 10, 3.4%, 0000000000000000000000000000000000
      4, 11, 3.3%, 000000000000000000000000000000000
      4, 12, 3.4%, 0000000000000000000000000000000000
      4, 13, 3.3%, 000000000000000000000000000000000
      4, 14, 3.3%, 000000000000000000000000000000000
      4, 15, 3.4%, 0000000000000000000000000000000000
      4, 16, 3.3%, 000000000000000000000000000000000
      4, 17, 3.4%, 0000000000000000000000000000000000
      4, 18, 3.5%, 00000000000000000000000000000000000
      4, 19, 3.9%, 000000000000000000000000000000000000000
      4, 20, 3.3%, 000000000000000000000000000000000 <-- 2019
      4, 21, 2.9%, 00000000000000000000000000000
      4, 22, 2.4%, 000000000000000000000000
      4, 23, 1.9%, 0000000000000000000
      4, 24, 1.5%, 000000000000000
      4, 25, 0.7%, 0000000






      c reinventing-the-wheel c99





      share












      share










      share



      share










      asked 1 min ago









      chuxchux

      13.6k21346




      13.6k21346






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217528%2feaster-bar-graph%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217528%2feaster-bar-graph%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

          Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...