# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1287: Blue Bin

From New Scientist #2445, 1st May 2004 [link]

George’s blue wheelie bin (used for recyclable paper) was emptied by the council on 1 April 2004.  It is emptied every fourth Thursday, and we presume that this schedule will continue indefinitely, in spite of official holidays.  The next collection will be on 29 April giving, unusually, two collections in one calendar month.  Looking to the future, when are the first years in which the following events will occur?

(1) One calendar month in the year has no collection day.
(2) There are two collections in one calendar month in the year.
(3) No month in the year has two collection days.
(4) Two months in the year each have two collection days.
(5) February has two collection days.

Note: I am still waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. The latest estimate is that I’ll have a connection by the end of October 2014.

[enigma1287]

### 3 responses to “Enigma 1287: Blue Bin”

1. Jim Randell 11 October 2014 at 2:46 pm

This Python program examines the collection days for the next 100 years. It runs in 35ms.

```from datetime import date, timedelta
from collections import Counter
from enigma import irange, printf

# record the years for the answers
a1 = a2 = a3 = a4 = a5 = None

# start date
year = 2005
d = date(year, 1, 6)

# increment
i = timedelta(days=28)

# record data for the rest of the current year
data = dict((m, 0) for m in irange(1, 12))

# consider the next 100 years
while True:
if d.year > year:
# examine the data for <year>
c = Counter(data.values())

# (1) one month in the year has no collection day
if not(a1) and 0 in c:
a1 = year
printf("[(1) {year} {data}]")

# (2) one month in the year has 2 collection days
if not(a2) and 2 in c:
a2 = year
printf("[(2) {year} {data}]")

# (3) no month in the year has 2 collection days
if not(a3) and 2 not in c:
a3 = year
printf("[(3) {year} {data}]")

# (4) two months in the year have 2 collection days
if not(a4) and c[2] > 1:
a4 = year
printf("[(4) {year} {data}]")

# (5) February has 2 collection days
if not(a5) and data[2] == 2:
a5 = year
printf("[(5) {year} {data}]")

year = d.year
if year > 2105: break
data = dict((m, 0) for m in irange(1, 12))

data[d.month] += 1
d += i

printf("(1)={a1} (2)={a2} (3)={a3} (4)={a4} (5)={a5}")
```

Solution: (1) There will never be a year that has month with no collection days; (2) The next year with two collections in exactly one calendar month is 2005; (3) There will never be a year where no month of the year has two collection days; (4) The next year with two collection days in exactly two calendar months is 2009; (5) The next year when February has exactly two collection days is 2052.

(1) In order for a month to have no collection days it would have to have fewer than 28 days.

(2) March 2005 has two collection days – 3rd March and 31st March.

(3) If no month has two collection days then each month must have exactly one collection day. If the first collection day is as late as possible in the year such that January has only one collection day (28th January), then the 12th collection is on 2nd December (or 1st December in a leap year) and there will be a 13th collection on 30th December (or 29th December). So (given the current calendar) we cannot have a year with only 12 collection days.

(4) January 2009 and December 2009 have two collection days – 1st January, 29th January, 3rd December, 31st December.

(5) 1st February 2052, 29th February 2052.

2. Hugh Casement 1 December 2014 at 8:27 am

Between 1904 and 2096 inclusive, every fourth year is a leap year with no exceptions.  There are seven days in a week; therefore 29 Feb. falls on the same weekday every 4×7 = 28 years.  If it’s a Thursday in 2052 then also in 2024. I’ve noted it in my diary!

• Hugh Casement 26 July 2015 at 10:31 am

I must apologize for leading people astray there.  Of course it’s true that 1 and 29 Feb. 2024 fall on a Thursday, but not in the 4-week cycle starting on 1 Apr. 2004.  Jim’s solution was correct.
The occasions with two collections in a month were 3 and 31 Mar. 2005, 2 and 30 Mar. 2006, 1 and 29 Mar. 2007, 3 and 31 Jan. 2008, 1 and 31 Jan. 2009, then 3 and 31 Dec. 2009.
So they follow sometimes after 12, sometime after 13 multiples of four weeks.

Another calendar reform is overdue!