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

Home > Just Math
24 pre-scheduled dates (Posted on 2018-12-31) Difficulty: 3 of 5
Adam and Betty decided to dine together 24 times a year, twice each month, but never on two consecutive evenings.

How many distinct schedules exist complying with the above specifications?

Please provide 2 answers (to cover both leap and non-leap years).

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer-aided solution Comment 1 of 1
January has C(31,2) - 30 = 435 possibilities, of which 29 include January 31.

I'm going to assume that, for example, a schedule that has the first and 15th of every month, is the same regardless of whether it's in a leap year or an ordinary year, even though there are more days between February 15 and March 1 in a leap year than in an ordinary year. Therefore we need consider only leap years, as any schedule that applies to an ordinary year is already included in our count for leap years.  Some schedules are leap-year only: those that include February 29 and those that include both February 28 and March 1; but all the rest are common to Ordinary and Leap years.  We shouldn't count twice the ones that are common to both.

February has C(29,2) - 28 = 378 possibilities. Of these, 27 include Feb. 1 and 27 include Feb. 29; each of the 27's includes the one pair that includes both, so 53 include one or the other.

So the combined first two months have:

(435-29)*(378-27) + 29*(378-53) schedules that don't include Feb. 29. That's 151931.
(435-29)*27 + 29*26 schedules that do include Feb. 29.  That's 11716.

Rather than do the arithmetic for the entire year, a program produces the following list after each of the twelve months of the year, with the first number representing the ways that include a date on the last day of the period up through that month; the second being the number that do not include that; the last is the total of these.


 29   406   435 
 11716   151931   163647 
 4734047   66112634   70846681 
 828325802909   11568855618432   12397181421341 
 346292753994639   4663769780588355   5010062534582994 
 144945520748912187   2024389191928845672   2169334712677757859 
 62765761146906065724   876691418766200149518   939457179913106215242 
 26242035276420067961052   353420138456187685586928   379662173732607753547980 
 10983961002969204784930368   153408065547698986037570424   164392026550668190822500792 
 4591992782415740138245091808   61843619089072407601712179440   66435611871488147739957271248 
 1922040751490740544320515774384   26844282621916547258551789556064   28766323373407287802872305330448 

So by the end of December we have counted 28,766,323,373,407,287,802,872,305,330,448 or about 28.8 nonillion ways.  Years with only 28 days in February have only  26,702,087,143,838,671,766,594,258,014,464 ways. So 2,064,236,229,568,616,036,278,047,315,984 ways are available in leap years only, due to the presence of Feb. 29 or coincidence of Feb. 28 with March 1.

Yes, I know that in the following program I should have made a loop instead of repeating most of the code.

    5   LastOcc=0:LastNotOcc=1
    6   open "24dates.txt" for output as #2
   10   MLen=31:Poss=combi(MLen,2)-(MLen-1)
   20   AppFirst=MLen-2:AppLast=MLen-2
   30   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
   40   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
   50   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
   60   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
   70   LastNotOcc=NewLastNotOcc
   80   LastOcc=NewLastOcc
   90   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
   91   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  110   MLen=29:Poss=combi(MLen,2)-(MLen-1)
  120   AppFirst=MLen-2:AppLast=MLen-2
  130   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  140   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  150   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  160   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  170   LastNotOcc=NewLastNotOcc
  180   LastOcc=NewLastOcc
  190   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  191   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  210   MLen=31:Poss=combi(MLen,2)-(MLen-1)
  220   AppFirst=MLen-2:AppLast=MLen-2
  230   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  240   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  250   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  260   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  270   LastNotOcc=NewLastNotOcc
  280   LastOcc=NewLastOcc
  290   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  291   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  310   MLen=30:Poss=combi(MLen,2)-(MLen-1)
  320   AppFirst=MLen-2:AppLast=MLen-2
  330   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  340   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  350   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  360   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  370   LastNotOcc=NewLastNotOcc
  380   LastOcc=NewLastOcc
  390   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  391   print 2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  410   MLen=31:Poss=combi(MLen,2)-(MLen-1)
  420   AppFirst=MLen-2:AppLast=MLen-2
  430   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  440   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  450   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  460   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  470   LastNotOcc=NewLastNotOcc
  480   LastOcc=NewLastOcc
  490   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  491   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  510   MLen=30:Poss=combi(MLen,2)-(MLen-1)
  520   AppFirst=MLen-2:AppLast=MLen-2
  530   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  540   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  550   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  560   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  570   LastNotOcc=NewLastNotOcc
  580   LastOcc=NewLastOcc
  590   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  591   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  610   MLen=31:Poss=combi(MLen,2)-(MLen-1)
  620   AppFirst=MLen-2:AppLast=MLen-2
  630   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  640   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  650   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  660   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  670   LastNotOcc=NewLastNotOcc
  680   LastOcc=NewLastOcc
  690   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  691   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  710   MLen=31:Poss=combi(MLen,2)-(MLen-1)
  720   AppFirst=MLen-2:AppLast=MLen-2
  730   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  740   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  750   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  760   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  770   LastNotOcc=NewLastNotOcc
  780   LastOcc=NewLastOcc
  790   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  791   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  810   MLen=30:Poss=combi(MLen,2)-(MLen-1)
  820   AppFirst=MLen-2:AppLast=MLen-2
  830   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  840   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  850   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  860   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  870   LastNotOcc=NewLastNotOcc
  880   LastOcc=NewLastOcc
  890   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  891   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
  910   MLen=31:Poss=combi(MLen,2)-(MLen-1)
  920   AppFirst=MLen-2:AppLast=MLen-2
  930   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
  940   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
  950   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
  960   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
  970   LastNotOcc=NewLastNotOcc
  980   LastOcc=NewLastOcc
  990   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
  991   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
 1010   MLen=30:Poss=combi(MLen,2)-(MLen-1)
 1020   AppFirst=MLen-2:AppLast=MLen-2
 1030   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
 1040   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
 1050   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
 1060   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
 1070   LastNotOcc=NewLastNotOcc
 1080   LastOcc=NewLastOcc
 1090   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
 1091   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc
 1110   MLen=31:Poss=combi(MLen,2)-(MLen-1)
 1120   AppFirst=MLen-2:AppLast=MLen-2
 1130   AppBoth=1:AppEither=AppFirst+AppLast-AppBoth
 1140   FirstOnly=AppFirst-AppBoth:LastOnly=AppLast-AppBoth
 1150   NewLastNotOcc=LastNotOcc*(Poss-AppLast)+LastOcc*(Poss-AppEither)
 1160   NewLastOcc=LastNotOcc*AppLast+LastOcc*LastOnly
 1170   LastNotOcc=NewLastNotOcc
 1180   LastOcc=NewLastOcc
 1190   print LastOcc,LastNotOcc,LastOcc+LastNotOcc
 1191   print #2,LastOcc,LastNotOcc,LastOcc+LastNotOcc


  Posted by Charlie on 2018-12-31 22:42:41
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 (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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