Make a calendar such that the number of days between two specified days is the least value

802 Views Asked by At

The last monday of a 31-day month must be at least how many days after the first Friday of the same month?

I have a question about the two methods to solve the problem

I don't understand the intuition behind the two methods. Can I get a drawing to understand them?

A. make the last monday as early as possible

B. make the first friday as late as possible

Wouldn't making the last monday or first friday as early or late as possible affect the date of the other corresponding day such that the number of days between the two dates is not minimized?

What I mean is if the day of the last monday is modified then all other days change, so wouldn't this method be ineffective and not minimize the days between Monday and Friday?

1

There are 1 best solutions below

0
On BEST ANSWER

There's only 7 things to try, let's see what happens. Friday the 1st --> Monday the 25th Friday the 2nd --> Monday the 26th Friday the 3rd --> Monday the 27th Friday the 4th --> Monday the 28th Friday the 5th --> Monday the 29th Friday the 6th --> Monday the 30th Friday the 7th --> Monday the 31st

...in all of these cases, the two days are 24 days apart. Boring!

Let's try 30 days instead. For the cases of Friday the 1st through Friday the 6th, the results remain the same. But there's a difference in the last one... Friday the 7th -> Monday the 24th. That's only 17 days, and contains both the last day that Friday could be and the first day that Monday could be.

The goal in setting the "first Friday" value as late as possible is to push whatever monday you might hit with earlier starting points off the end of the month's calendar -- and thus back a whole week.