+/{13∊⍎,⍉3↑¯5↑⍉2↓cal⍵}¨⎕,¨⍳12
Try it online!
⍳ 12
the integers one through twelve
⎕ ,¨
take numeric input and prepend to each of the twelve numbers
{
…}¨
on each of the pairs, apply the function…
cal⍵
get a calendar for that year-month
2 ↓
drop two rows (caption and days)
⍉
transpose (so we can address columns instead of rows)
¯5 ↑
take the last five (two digits for each of Friday and Saturday plus one space)
3 ↑
take the first two (two digits for Friday plus a space)
⍉
transpose (so we get reading order)
,
ravel
⍎
execute as APL expression (gives list of Fridays' dates)
13 ∊
is thirteen a member of that list?
+/
sum the 12 Booleans
Using @Wrzlprmft's algorithm, we can do it without libraries for 53 bytes:
'21232211321211'⊃⍨14|2 3 ¯1+.×⊢,0≠.=400 100 4∘.|-∘0 1
-∘0 1
subtract zero and one
400 100 4 ∘.|
division remainder table for the two years (across) divided by these numbers (down)
0 ≠.=
inner "product" with 0, but using ≠ and = instead of +.×
⊢ ,
prepend the unmodified argument year
2 3 ¯1 +.×
inner product with these numbers
14 |
division remainder when divided by fourteen
'21232211321211' ⌷⍨
index into this string