Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,31 @@
/*REXX program finds months that contain five weekends (given a date range). */
month. =31; month.2=0 /*month days; February is skipped. */
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
parse arg yStart yStop . /*get the "start" and "stop" years.*/
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
haps=0 /*number of five weekends happenings. */
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
do y=yStart to yStop /*process the years specified. */
do m=1 for 12; wd.=0 /*process each month and also each year*/
do d=1 for month.m; dat_= y"-"right(m,2,0)'-'right(d,2,0)
parse upper value date('W', dat_, "I") with ? 3
wd.?=wd.?+1 /*? is the first two chars of weekday.*/
end /*d*/ /*WD.su = number of Sundays in a month.*/
if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*five weekends ?*/
say 'There are five weekends in' y date('M', dat_, "I")
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
end /*m*/
end /*y*/
say
say "There were " haps ' occurrence's(haps) "of" @5w 'in year's(years) yStart"──►"yStop
say; #=0
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
#=#+1; say 'Year ' y " doesn't have any" @5wem'.'
end /*y*/
say
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart''yStop
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*pluralizer.*/

View file

@ -0,0 +1,37 @@
/*REXX program finds months that contain five weekends (given a date range). */
month. =31; month,2=0 /*month days; February is skipped. */
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
@months='January February March April May June July August September October November December'
parse arg yStart yStop . /*get the "start" and "stop" years.*/
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
haps=0 /*number of five weekends happenings. */
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
do y=yStart to yStop /*process the years specified. */
do m=1 for 12; wd.=0 /*process each month and also each year*/
do d=1 for month.m
?=dow(m,d,y) /*get the day-of-week for mm/dd/yyyy*/
wd.?=wd.?+1 /*?: 1=Sun, 2=Mon, 3=Tue ∙∙∙ 7=Sat.*/
end /*d*/
if wd.1\==5 | wd.6\==5 | wd.7\==5 then iterate /*not a weekend ? */
say 'There are five weekends in' y word(@months, m)
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
end /*m*/
end /*y*/
say
say 'There were ' haps " occurrence"s(haps) 'of' @5w "in year"s(years) yStart''yStop
#=0; say
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
#=#+1
say 'Year ' y " doesn't have any five-weekend months."
end /*y*/
say
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart''yStop
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
dow: procedure; parse arg m,d,y; if m<3 then do; m=m+12; y=y-1; end
yL=left(y,2); yr=right(y,2); w=(d+(m+1)*26%10+yr+yr%4+yL%4+5*yL) // 7
if w==0 then w=7; return w /*Sunday=1, Monday=2, ... Saturday=7 */
/*──────────────────────────────────────────────────────────────────────────────────────*/
s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*pluralizer.*/

View file

@ -0,0 +1,55 @@
/* REXX ***************************************************************
* Short(er) solution focussed at the task's description
* Only 7 months can have 5 full weekends
* and it's enough to test if the 1st day of the month is a Friday
* 30.08.2012 Walter Pachl
**********************************************************************/
Numeric digits 20
nr5fwe=0
years_without_5fwe=0
mnl='Jan Mar May Jul Aug Oct Dec'
ml='1 3 5 7 8 10 12'
Do j=1900 to 2100
year_has_5fwe=0
Do mi=1 To words(ml)
m=word(ml,mi)
jd=greg2jul(j m 1)
IF jd//7=4 Then Do /* 1st m j is a Friday */
nr5fwe=nr5fwe+1
year_has_5fwe=1
If j<=1905 | 2095<=j Then
Say word(mnl,mi) j 'has 5 full weekends'
End
End
If j=1905 Then Say '...'
if year_has_5fwe=0 Then years_without_5fwe=years_without_5fwe+1
End
Say ' '
Say nr5fwe 'occurrences of 5 full weekends in a month'
Say years_without_5fwe 'years without 5 full weekends'
exit
greg2jul: Procedure
/***********************************************************************
* Converts a Gregorian date to the corresponding Julian day number
* 19891101 Walter Pachl REXXified algorithm published in CACM
* (Fliegel & vanFlandern, CACM Vol.11 No.10 October 1968)
* 19891125 PA copy leapyear test into this to avoid the dependency
***********************************************************************/
numeric digits 12
Parse Arg yy mm d
If mm<1 | 12<mm Then Call err 'month ('mm') not within 1 to 12'
mdl='31' (28+leapyear(yy)) '31 30 31 30 31 31 30 31 30 31'
md=word(mdl,mm)
If d<1 | md<d Then Call err 'day ('d') not within 1 to' md
/***********************************************************************
* The published formula:
* res=d-32075+1461*(yy+4800+(mm-14)%12)%4+,
* 367*(mm-2-((mm-14)%12)*12)%12-3*((yy+4900+(mm-14)%12)%100)%4
***********************************************************************/
mma=(mm-14)%12
yya=yy+4800+mma
result=d-32075+1461*yya%4+367*(mm-2-mma*12)%12-3*((yya+100)%100)%4
Return result /* return the result */
leapyear: Return ( (arg(1)//4=0) & (arg(1)//100<>0) ) | (arg(1)//400=0)

View file

@ -0,0 +1,30 @@
/*REXX program finds months that contain five weekends (given a date range). */
month. =31; month.2=0 /*month days; February is skipped. */
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
parse arg yStart yStop . /*get the "start" and "stop" years.*/
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
haps=0 /*number of five weekends happenings. */
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
do y=yStart to yStop /*process the years specified. */
do m=1 for 12; wd.=0 /*process each month and also each year*/
do d=1 for month.m; dat_= y"-"right(m, 2, 0)'-'right(d, 2, 0)
parse upper value date('W', dat_, "I") with ? 3
wd.?=wd.?+1 /*?: 1=Sun, 2=Mon, 3=Tue ∙∙∙ 7=Sat.*/
end /*d*/ /*WD.su=number of Sundays in the month.*/
if wd.su\==5 | wd.fr\==5 | wd.sa\==5 then iterate /*is this a weekend ? */
say 'There are five weekends in' y date('M', dat_, "I")
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
end /*m*/
end /*y*/
say
say 'There were ' haps " occurrence"s(haps) 'of' @5w "in year"s(years) yStart''yStop
#=0; say
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
#=#+1
say 'Year ' y " doesn't have any five-weekend months."
end /*y*/
say
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart''yStop
/*stick a fork in it, we're all done. */

View file

@ -0,0 +1,27 @@
/*REXX program finds months that contain five weekends (given a date range). */
month. =31 /*days in "all" the months. */
month.2=0; month.4=0; month.6=0; month.9=0; month.11=0 /*not 31 day months.*/
month.4=30; month.6=30; month.9=30; month.11=30 /*all the months with thirty-days. */
parse arg yStart yStop . /*get the "start" and "stop" years.*/
if yStart=='' | yStart=="," then yStart= 1900 /*Not specified? Then use the default.*/
if yStop =='' | yStop =="," then yStop = 2100 /* " " " " " " */
years=yStop - yStart + 1 /*calculate the number of yrs in range.*/
haps=0 /*number of five weekends happenings. */
!.=0; @5w= 'five-weekend months' /*flag if a year has any five-weekends.*/
do y=yStart to yStop /*process the years specified. */
do m=1 for 12; if month.m==0 then iterate /*only test 31-day months.*/
dat_= y"-"right(m,2,0)'-01' /*get the date in the desired format. */
if left(date('W',dat_,"I"),2)\=='Fr' then iterate /*isn't not a Friday? */
say 'There are five weekends in' y date('M', dat_, "I")
haps=haps+1; !.y=1 /*bump counter; indicate yr has 5 WE's.*/
end /*m*/
end /*y*/
say
say 'There were ' haps " occurrence"s(haps) 'of' @5w "in year"s(years) yStart''yStop
#=0; say
do y=yStart to yStop; if !.y then iterate /*skip if OK.*/
#=#+1
say 'Year ' y " doesn't have any five-weekend months."
end /*y*/
say
say "There are " # ' year's(#) "that haven't any" @5w 'in year's(years) yStart''yStop