The month of October in 2010 has five Fridays, five Saturdays, and five Sundays.



Task

 Write a program to show all months that have this same characteristic of five full weekends from the year 1900 through 2100 (Gregorian calendar). 
 Show the number of months with this property (there should be 201).
 Show at least the first and last five dates, in order.

Algorithm suggestions

 Count the number of Fridays, Saturdays, and Sundays in every month.
 Find all of the 31-day months that begin on Friday.

Extra credit

Count and/or show all of the years which do not have at least one five-weekend month (there should be 29).



Related tasks
 Day of the week
 Last Friday of each month
 Find last sunday of each month


set fiveWeekendMonths to {}
set noFiveWeekendYears to {}
 
set someDate to current date
set day of someDate to 1
 
repeat with someYear from 1900 to 2100
  set year of someDate to someYear
  set foundOne to false
  repeat with someMonth in {January, March, May, July, ¬
                            August, October, December}
    set month of someDate to someMonth
    if weekday of someDate is Friday then
        set foundOne to true
        set end of fiveWeekendMonths to ¬
             (someYear as text) & "-" & (someMonth as text)
    end
  end repeat
  if not foundOne then
    set end of noFiveWeekendYears to someYear
  end
end repeat
 
set text item delimiters to ", "
set monthList to ¬
  (items 1 thru 5 of fiveWeekendMonths as text) & ", ..." & linefeed & ¬
   " ..., " & (items -5 thru end of fiveWeekendMonths as text)
 
set monthCount to count fiveWeekendMonths
set yearCount to count noFiveWeekendYears
 
set resultText to ¬
  "Months with five weekends (" & monthCount & "): " & linefeed & ¬
  "      " & monthList & linefeed & linefeed & ¬
  "Years with no such months (" & yearCount & "): "
 
set y to 1
repeat while y < yearCount
  set final to y+11
  if final > yearCount then
    set final to yearCount
  end
  set resultText to ¬
    resultText & linefeed & ¬
    "      " & (items y through final of noFiveWeekendYears as text)
  set y to y + 12
end
resultText