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

ListPlot join points by nearest neighbor rather than order

Storing hydrofluoric acid before the invention of plastics

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

Is high blood pressure ever a symptom attributable solely to dehydration?

Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?

What is the correct way to use the pinch test for dehydration?

When -s is used with third person singular. What's its use in this context?

Why one of virtual NICs called bond0?

If 'B is more likely given A', then 'A is more likely given B'

∞ symbol in external pdf disappears when used as figure

How do I keep my slimes from escaping their pens?

Is it true that "carbohydrates are of no use for the basal metabolic need"?

What causes the vertical darker bands in my photo?

"Seemed to had" is it correct?

Why did the IBM 650 use bi-quinary?

3 doors, three guards, one stone

How widely used is the term Treppenwitz? Is it something that most Germans know?

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

Is 1 ppb equal to 1 μg/kg?

What is this single-engine low-wing propeller plane?

Did Kevin spill real chili?

Can a non-EU citizen traveling with me come with me through the EU passport line?

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

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



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 an Easter 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 an Easter 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 an Easter 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 an Easter 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 5 mins 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

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

          Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar