27 lines
893 B
Plaintext
27 lines
893 B
Plaintext
link datetime,printf
|
|
|
|
procedure main(A) # five weekends
|
|
printf( "There are %d months from %d to %d with five full weekends.\n",
|
|
*(L := fiveweekends(s := 1900, f := 2100)), s,f)
|
|
printf("The first and last five such months are:\n")
|
|
every printf("%s\n",L[1 to 5]|"..."|L[-4 to 0])
|
|
printf( "There are %d years without such months as follows:\n",
|
|
*(M := Bonus(s,f,L)))
|
|
every printf("%s\n",!M)
|
|
end
|
|
|
|
procedure fiveweekends(start,finish)
|
|
L := [] # months years with five weekends FRI-SUN
|
|
every year := start to finish & month := 1 to 12 do
|
|
if month = (2|4|6|9|11) then next
|
|
else if julian(month,1,year) % 7 = 4 then
|
|
put(L,sprintf("%d-%d-1",year,month))
|
|
return L
|
|
end
|
|
|
|
procedure Bonus(start,finish,fwe)
|
|
every insert(Y := set(), start to finish)
|
|
every insert(F := set(), integer(!fwe ? tab(find("-"))))
|
|
return sort(Y--F)
|
|
end
|