Five weekends: Difference between revisions
→{{header|J}}: extra credit
m (→{{header|Ruby}}: Don't need the uniq.) |
(→{{header|J}}: extra credit) |
||
Line 51:
=={{header|J}}==
<lang j>require 'types/datetime numeric'
find5wkdMonths=: verb define
years=.
months=. 1 3 5 7 8 10 12
▲ m5w=. (#~ 0 = weekday) >,{years;months;dates NB. 5 full weekends iff 31st is Sunday(0)
>'MMM YYYY' fmtDate toDayNo m5w
)</lang>
'''Usage:'''
<lang j> # find5wkdMonths
201
(5&{. , '...' , _5&{.) find5wkdMonths
Mar 1901
Aug 1902
Line 73 ⟶ 72:
May 2099
Jan 2100
Oct 2100
# (range -. _ {:"1@". find5wkdMonths) 1900 2100 NB. number of years without 5 weekend months
29</lang>
=={{header|Java}}==
|