Fifth Thursdays and Sundays (Posted on 2022-05-17)

There are two clubs, X and Y. Club X meets on fourth Thursday of odd numbered months and fourth Sunday of even numbered months. That is, Club X meets on fourth Thursday of January, followed by fourth
Sunday of February, followed by fourth Thursday of March...., and so on.

Club Y meets on last Thursday of every odd numbered months, and last Sunday of every even numbered months.

Arne is a member of both the clubs and wants to attend all the meetings hosted by the two clubs. Now, fourth Thursday is usually the last Thursday and fourth Sunday is usually the last Sunday of a given month. However, in some odd numbered months there are five Thursdays and some even numbered months have five Sundays. In each of these months Arne can attend both the meetings.

(A) Devise an algorithm to determine all the fifth Thursdays of odd numbered months and fifth Sundays of even numbered months that have them and set it to calculate them for 14 years. You are given subroutines that convert Gregorian calendar dates to and from JD numbers, which are the number of days a given date is past a certain fixed date in the distant past (more than 6,000 years ago). You also have a virtual 2023 C.E. calendar available that intimates that January 5, 2023 will be a Thursday.

(B) Utilize the above algorithm to calculate the total number of meetings of both the clubs that Arne will be attending from January 1, 2023 to December 31, 2036 inclusively,
In which of these 14 years will Arne be able to attend a maximum number and a minimum number of meetings?

*** Assume that Arne will attend the meeting of one of the clubs whenever the dates of the meeting of the two clubs coincide.