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

Task

1. Write a program to show all months that have this same characteristic of five full weekends from the year 1900 through 2100 (Gregorian calendar).
2. Show the *number* of months with this property (there should be 201).
3. 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
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2015-09-10

```
# A month has 5 weekends iff it has 31 days and starts on Friday.

my @years = 1900 .. 2100;
my @has31 = 1, 3, 5, 7, 8, 10, 12;
my @happy = ($_ when *.day-of-week == 5 for (@years X @has31).map(-> ($y, $m) { Date.new: $y, $m, 1 }));

say 'Happy month count:  ', +@happy;
say 'First happy months: ' ~ @happy[^5];
say 'Last  happy months: ' ~ @happy[*-5 .. *];
say 'Dreary years count: ',  @years - @happy».year.squish;

```

Output:

```
Happy month count:  201
First happy months: 1901-03-01 1902-08-01 1903-05-01 1904-01-01 1904-07-01
Last  happy months: 2097-03-01 2098-08-01 2099-05-01 2100-01-01 2100-10-01
Dreary years count: 29
```