Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,23 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar.Formatting; use Ada.Calendar;
use Ada.Calendar.Formatting;
procedure Five_Weekends is
Months : Natural := 0;
begin
for Year in Year_Number range 1901..2100 loop
for Month in Month_Number range 1..12 loop
begin
if Day_Of_Week (Formatting.Time_Of (Year, Month, 31)) = Sunday then
Put_Line (Year_Number'Image (Year) & Month_Number'Image (Month));
Months := Months + 1;
end if;
exception
when Time_Error =>
null;
end;
end loop;
end loop;
Put_Line ("Number of months:" & Integer'Image (Months));
end Five_Weekends;

View file

@ -1,41 +0,0 @@
#include <Date.au3>
#include <Array.au3>
$array = Five_weekends(1)
_ArrayDisplay($array)
$array = Five_weekends(2)
_ArrayDisplay($array)
$array = Five_weekends(3)
_ArrayDisplay($array)
Func Five_weekends($ret = 1)
If $ret < 1 Or $ret > 3 Then Return SetError(1, 0, 0)
Local $avDateArray[1]
Local $avYearArray[1]
Local $avMonthArray[1]
For $iYear = 1900 To 2100
Local $checkyear = False
For $iMonth = 1 To 12
If _DateDaysInMonth($iYear, $iMonth) <> 31 Then ContinueLoop ; Month has less then 31 Days
If _DateToDayOfWeek($iYear, $iMonth, "01") <> 6 Then ContinueLoop ;First Day is not a Friday
_ArrayAdd($avMonthArray, $iYear & "-" & _DateToMonth($iMonth))
$checkyear = True
For $s = 1 To 31
Local $Date = _DateToDayOfWeek($iYear, $iMonth, $s)
If $Date = 6 Or $Date = 7 Or $Date = 1 Then ; if Date is Friday, Saturday or Sunday
_ArrayAdd($avDateArray, $iYear & "\" & StringFormat("%02d", $iMonth) & "\" & StringFormat("%02d", $s))
EndIf
Next
Next
If Not $checkyear Then _ArrayAdd($avYearArray, $iYear)
Next
$avDateArray[0] = UBound($avDateArray) - 1
$avYearArray[0] = UBound($avYearArray) - 1
$avMonthArray[0] = UBound($avMonthArray) - 1
If $ret = 1 Then
Return $avDateArray
ElseIf $ret = 2 Then
Return $avYearArray
ElseIf $ret = 3 Then
Return $avMonthArray
EndIf
EndFunc ;==>Five_weekends

View file

@ -1,53 +0,0 @@
program-id. five-we.
data division.
working-storage section.
1 wk binary.
2 int-date pic 9(8).
2 dow pic 9(4).
2 friday pic 9(4) value 5.
2 mo-sub pic 9(4).
2 months-with-5 pic 9(4) value 0.
2 years-no-5 pic 9(4) value 0.
2 5-we-flag pic 9(4) value 0.
88 5-we-true value 1 when false 0.
1 31-day-mos pic 9(14) value 01030507081012.
1 31-day-table redefines 31-day-mos.
2 mo-no occurs 7 pic 99.
1 cal-date.
2 yr pic 9(4).
2 mo pic 9(2).
2 da pic 9(2) value 1.
procedure division.
perform varying yr from 1900 by 1
until yr > 2100
set 5-we-true to false
perform varying mo-sub from 1 by 1
until mo-sub > 7
move mo-no (mo-sub) to mo
compute int-date = function
integer-of-date (function numval (cal-date))
compute dow = function mod
((int-date - 1) 7) + 1
if dow = friday
perform output-date
add 1 to months-with-5
set 5-we-true to true
end-if
end-perform
if not 5-we-true
add 1 to years-no-5
end-if
end-perform
perform output-counts
stop run
.
output-counts.
display "Months with 5 weekends: " months-with-5
display "Years without 5 weekends: " years-no-5
.
output-date.
display yr "-" mo
.
end program five-we.

View file

@ -1,42 +0,0 @@
--Five Weekend task from Rosetta Code wiki
--User:Lnettnay
include std/datetime.e
atom numbermonths = 0
sequence longmonths = {1, 3, 5, 7, 8, 10, 12}
sequence yearsmonths = {}
atom none = 0
datetime dt
for year = 1900 to 2100 do
atom flag = 0
for month = 1 to length(longmonths) do
dt = new(year, longmonths[month], 1)
if weeks_day(dt) = 6 then --Friday is day 6
flag = 1
numbermonths += 1
yearsmonths = append(yearsmonths, {year, longmonths[month]})
end if
end for
if flag = 0 then
none += 1
end if
end for
puts(1, "Number of months with five full weekends from 1900 to 2100 = ")
? numbermonths
puts(1, "First five and last five years, months\n")
for count = 1 to 5 do
? yearsmonths[count]
end for
for count = length(yearsmonths) - 4 to length(yearsmonths) do
? yearsmonths[count]
end for
puts(1, "Number of years that have no months with five full weekends = ")
? none

View file

@ -1,4 +1,6 @@
//
// Using FutureBasic 7.0.34, July 2025 R.W
//
// Calculate months having 5 Fridays,
// 5 Saturdays, and 5 Sundays
// from year 1900 through 2100

View file

@ -1,3 +1,5 @@
using Dates
isweekend(dt::Date) = Dates.dayofweek(dt) (Dates.Friday, Dates.Saturday, Dates.Sunday)
function hasfiveweekend(month::Integer, year::Integer)

View file

@ -1,33 +1,31 @@
(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">m31</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"January"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"March"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"May"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"July"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"August"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"October"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"December"</span><span style="color: #0000FF;">}</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">nmonths</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">months</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{},</span>
<span style="color: #000000;">none</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
with javascript_semantics
sequence m31 = {"January",0,"March",0,"May",0,"July","August",0,"October",0,"December"}
integer y,m,
nmonths = 0
string months
sequence res = {},
none = {}
<span style="color: #008080;">for</span> <span style="color: #000000;">y</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1900</span> <span style="color: #008080;">to</span> <span style="color: #000000;">2100</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">months</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">m</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">12</span> <span style="color: #008080;">do</span>
<span style="color: #008080;">if</span> <span style="color: #004080;">string</span><span style="color: #0000FF;">(</span><span style="color: #000000;">m31</span><span style="color: #0000FF;">[</span><span style="color: #000000;">m</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">and</span> <span style="color: #7060A8;">day_of_week</span><span style="color: #0000FF;">(</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">)=</span><span style="color: #008000;">"Friday"</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">months</span><span style="color: #0000FF;">)!=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #000000;">months</span> <span style="color: #0000FF;">&=</span> <span style="color: #008000;">", "</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">months</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">m31</span><span style="color: #0000FF;">[</span><span style="color: #000000;">m</span><span style="color: #0000FF;">]</span>
<span style="color: #000000;">nmonths</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">months</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">none</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">none</span><span style="color: #0000FF;">,</span><span style="color: #000000;">y</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">else</span>
<span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%d : %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">months</span><span style="color: #0000FF;">}))</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
for y=1900 to 2100 do
months = ""
for m=1 to 12 do
if string(m31[m])
and day_of_week(y,m,1,true)="Friday" then
if length(months)!=0 then months &= ", " end if
months &= m31[m]
nmonths += 1
end if
end for
if length(months)=0 then
none = append(none,y)
else
res = append(res,sprintf("%d : %s\n",{y,months}))
end if
end for
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Found %d months with five full weekends\n"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">nmonths</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">res</span><span style="color: #0000FF;">[</span><span style="color: #000000;">6</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">6</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">" ...\n"</span><span style="color: #0000FF;">}</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">))</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Found %d years with no month having 5 weekends:\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">none</span><span style="color: #0000FF;">)})</span>
<span style="color: #000000;">none</span><span style="color: #0000FF;">[</span><span style="color: #000000;">6</span><span style="color: #0000FF;">..-</span><span style="color: #000000;">6</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">".."</span><span style="color: #0000FF;">}</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">none</span>
<!--
printf(1,"Found %d months with five full weekends\n",nmonths)
res[6..-6] = {" ...\n"}
puts(1,join(res,""))
printf(1,"Found %d years with no month having 5 weekends:\n",{length(none)})
none[6..-6] = {".."}
?none

View file

@ -1,20 +0,0 @@
$fiveWeekends = @()
$yearsWithout = @()
foreach ($y in 1900..2100) {
$hasFiveWeekendMonth = $FALSE
foreach ($m in @("01","03","05","07","08",10,12)) {
if ((Get-Date "$y-$m-1").DayOfWeek -eq "Friday") {
$fiveWeekends += "$y-$m"
$hasFiveWeekendMonth = $TRUE
}
}
if ($hasFiveWeekendMonth -eq $FALSE) {
$yearsWithout += $y
}
}
Write-Output "Between the years 1900 and 2100, inclusive, there are $($fiveWeekends.count) months with five full weekends:"
Write-Output "$($fiveWeekends[0..4] -join ","),...,$($fiveWeekends[-5..-1] -join ",")"
Write-Output ""
Write-Output "Extra Credit: these $($yearsWithout.count) years have no such month:"
Write-Output ($yearsWithout -join ",")

View file

@ -1,11 +0,0 @@
For y = 1900 To 2100
For m = 1 To 12
d = DateSerial(y, m + 1, 1) - 1
If Day(d) = 31 And Weekday(d) = vbSunday Then
WScript.Echo y & ", " & MonthName(m)
i = i + 1
End If
Next
Next
WScript.Echo vbCrLf & "Total = " & i & " months"