All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Double Dates (Posted on 2005-09-14) Difficulty: 2 of 5
Steve is in charge of designing a wall-hanging calendar. Each month is allocated a grid of 5 X 7 squares, labeled Sunday thru Saturday across the top. The problem is, Steve hates to put two dates in the same square on the calendar, necessary when the month spans parts of six weeks. Is it possible for Steve to find a year when he never has to put two dates in the same square? What is the most double-date squares he would ever need for a single year?

See The Solution Submitted by Josh70679    
Rating: 3.3333 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 2 of 4 |

A double-date square will be needed when a 30-day month begins on a Saturday, or a 31-day month begins on either a Friday or a Saturday.

The following table shows all 14 possible years: beginning on any day of the week, and either leap or non-leap. The columns correspond to the months and show the beginning day of the week for the first day of the month as well as the length of the month.  An asterisk shows the need for at least one double-date square.

A 30-day month beginning on a Saturday requires one double-date square, as does a 31-day monght beginning on a Friday.  A 31-day month beginning on a Saturday requires two double-date squares.  A count of the double-date squares appears to the right of each year's row. The least for any year is 2 and the most is 6.

Su31  We28  We31  Sa30* Mo31  Th30  Sa31* Tu31  Fr30  Su31  We30  Fr31*  4
Mo31  Th28  Th31  Su30  Tu31  Fr30  Su31  We31  Sa30* Mo31  Th30  Sa31*  3
Tu31  Fr28  Fr31* Mo30  We31  Sa30* Mo31  Th31  Su30  Tu31  Fr30  Su31   2
We31  Sa28  Sa31* Tu30  Th31  Su30  Tu31  Fr31* Mo30  We31  Sa30* Mo31   4
Th31  Su28  Su31  We30  Fr31* Mo30  We31  Sa31* Tu30  Th31  Su30  Tu31   3
Fr31* Mo28  Mo31  Th30  Sa31* Tu30  Th31  Su31  We30  Fr31* Mo30  We31   4
Sa31* Tu28  Tu31  Fr30  Su31  We30  Fr31* Mo31  Th30  Sa31* Tu30  Th31   5
Su31  We29  Th31  Su30  Tu31  Fr30  Su31  We31  Sa30* Mo31  Th30  Sa31*  3
Mo31  Th29  Fr31* Mo30  We31  Sa30* Mo31  Th31  Su30  Tu31  Fr30  Su31   2
Tu31  Fr29  Sa31* Tu30  Th31  Su30  Tu31  Fr31* Mo30  We31  Sa30* Mo31   4
We31  Sa29  Su31  We30  Fr31* Mo30  We31  Sa31* Tu30  Th31  Su30  Tu31   3
Th31  Su29  Mo31  Th30  Sa31* Tu30  Th31  Su31  We30  Fr31* Mo30  We31   3
Fr31* Mo29  Tu31  Fr30  Su31  We30  Fr31* Mo31  Th30  Sa31* Tu30  Th31   4
Sa31* Tu29  We31  Sa30* Mo31  Th30  Sa31* Tu31  Fr30  Su31  We30  Fr31*  6

Of course it wouldn't do to do all this work by hand:

DIM length(12)
CLS

DATA 31,28,31,30,31,30,31,31,30,31,30,31
FOR i = 1 TO 12
  READ length(i)
NEXT

FOR ly = 0 TO 1
 FOR stDay = 1 TO 7
   ct = 0
   day1 = stDay: mo = 1
   DO
     dw$ = MID$("SuMoTuWeThFrSa", day1 * 2 - 1, 2)
     l$ = LTRIM$(STR$(length(mo) + ly * (ABS(mo = 2))))
     v = day1 + length(mo) + ly * (ABS(mo = 2)) - 1
     IF v > 5 * 7 THEN
      ind$ = "* "
      ct = ct + v - 5 * 7
     ELSE
      ind$ = "  "
     END IF
     PRINT dw$; l$; ind$;
     day1 = (day1 + length(mo) + ly * (ABS(mo = 2))) MOD 7
     IF day1 = 0 THEN day1 = 7
     mo = mo + 1
   LOOP UNTIL mo > 12
   PRINT USING "##"; ct
 NEXT
NEXT

 

 


  Posted by Charlie on 2005-09-14 13:43:27
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information