31 lines
795 B
Plaintext
31 lines
795 B
Plaintext
sequence m31 = {"January",0,"March",0,"May",0,"July","August",0,"October",0,"December"}
|
|
integer y,m,
|
|
nmonths = 0
|
|
string months
|
|
sequence res = {},
|
|
none = {}
|
|
|
|
for y=1900 to 2100 do
|
|
months = ""
|
|
for m=1 to 12 do
|
|
if string(m31[m])
|
|
and day_of_week(y,m,1)=6 then
|
|
if length(months)!=0 then months &= ", " end if
|
|
months &= m31[m]
|
|
nmonths += 1
|
|
end if
|
|
end for
|
|
if length(months)=0 then
|
|
none = append(none,y)
|
|
else
|
|
res = append(res,sprintf("%d : %s\n",{y,months}))
|
|
end if
|
|
end for
|
|
|
|
printf(1,"Found %d months with five full weekends\n",nmonths)
|
|
res[6..-6] = {" ...\n"}
|
|
puts(1,join(res,""))
|
|
printf(1,"Found %d years with no month having 5 weekends:\n",{length(none)})
|
|
none[6..-6] = {".."}
|
|
?none
|