RosettaCodeData/Task/Five-weekends/Phix/five-weekends.phix
2026-02-01 16:33:20 -08:00

31 lines
833 B
Text

with javascript_semantics
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,true)="Friday" 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