Prime Wednesdays

Python 2, 95 93 68 67 bytes

lambda y:0x10ea2c8dbb06c5619/5**((y+((y-22)/99-y/2002)*16)%28)%5+16

Thanks to @Josay for golfing off 1 byte!

Test it on Ideone.


Brain-Flak, 6588, 2310, 2308, 2290 bytes

First things first, I did not write nearly 100% of this program, which is probably evidenced by the enormous size of the program. Most of this code was written by my own Brain-Flak golfing algorithm. Along with an additional python script I wrote to prompt it in the right direction.

Try it online!

({}<(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()()())){}{}){})[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])()())[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])())()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())[()()()])())())[()])[()])()()())[()()])()())[()()()()])()())())[()()])())()())[()()()()])())()()())[()()()])()())[()()()])()())[()]))())()())[()()()()])())()()())>[(((((((((()()()()())){}{}){}){}){}){}[()]){}){}){}]){({}[()]<{}>)}{}({}<{{}}>)

While this program is quite long for code golf, it really is decently short for Brain-Flak. Currently the world record for integer division is over 1000 bytes.

Explanation

The algorithm is quite simple. Because there is a limited number of years available (321) it simply pushes the answers in reverse order under the input and uses a lookup algorithm to find the correct answer. While hardcoding all 321 possibilities may seem rather inefficient with an task as complex as this one and a language as esoteric as brain-flak it may very well be the best solution. (I plan to find out in the coming week).

Since most of the 321 numbers are about 18 on average and they differ by very little from year to year instead of pushing all the numbers individually I push the first year (2233) normally and then just duplicate and change the value a bit for each year after. This way instead of paying to push ~18 for all 321 years I only pay to push ~2 for every year.

Once all the answers have been pushed it subtracts 1912 from the input ({}[(((((((((()()()()())){}{}){}){}){}){}[()]){}){}){}]) (This may be suboptimal, I rewrote the optimizer to skip certain values that I believed would not be optimal because hardcoding numbers is a super-exponential process and running it to completion may have taken a few days).

It then subtracts one from the first element and pops the second element until the result reaches zero, {({}[()]<{}>)}.

It pops the zero, {} and all the elements below the top element ({}<{{}}>).


MATL, 38 36 34 bytes

FT+"@llI$YO]q&:t8XO!s9\~)9#1$ZOZps

Try it online! Or verify all test cases (takes a few seconds).

Explanation

FT+     % Input year implicitly. Add [0 1] element-wise. Gives array with input year
        % and next year
"       % For each of those two years
  @     %   Push year
  ll    %   Push 1 twice. This indicates January 1.
  I$YO  %   Convert year, month, day to serial date number
]       % End for each. We now have the serial date number for January 1 of the input
        % year and that of the following year
q       % Subtract 1 to the latter, to yield December 31 of the input year
&:      % Inclusive range between those two numbers. This gives an array of serial date
        % numbers for the whole input year
t       % Push another copy of that array
8XO     % Convert to date string with format 8. This gives weekday as "Mon", "Tue" etc.
        % The result is a 3-column 2D char array, where each row is a day
!s      % Transpose, sum of each column. 'Wed' gives 288 (sum of ASCII codes)
9\~     % 288 gives 0 modulo 9, and is the only weekday to do so. So we compute modulo 9
        % and negate. This gives true for Wednesdays, false for the rest
)       % Apply as logical index into the array of serial date numbers
9#1$ZO  % Array of month numbers corresponding to those serial date numbers
Zp      % Array that contains true for prime numbers, false for the rest
s       % Sum of array. Display implicitly