Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,34 @@
with Ada.Text_IO;
with Ada.Calendar.Formatting;
with Ada.Calendar.Arithmetic;
procedure Palindrome_Dates is
Desired_Count : constant := 15;
Start_Date : constant String := "2020-01-01 00:00:00";
use Ada.Calendar;
function Is_Palindrome_Date (Date : Time) return Boolean is
Image : String renames Formatting.Image (Date);
begin
return
Image (1) = Image (10) and
Image (2) = Image (9) and
Image (3) = Image (7) and
Image (4) = Image (6);
end Is_Palindrome_Date;
Date : Ada.Calendar.Time := Formatting.Value (Start_Date);
Count : Natural := 0;
use type Ada.Calendar.Arithmetic.Day_Count;
begin
loop
if Is_Palindrome_Date (Date) then
Ada.Text_IO.Put_Line (Formatting.Image (Date) (1 .. 10));
Count := Count + 1;
end if;
exit when Count = Desired_Count;
Date := Date + 1;
end loop;
end Palindrome_Dates;

View file

@ -0,0 +1,10 @@
count = 0
(2020..).each do |year|
digits = year.digits
month = digits[0]*10 + digits[1]
next unless 1 <= month <= 12
day = digits[2]*10 + digits[3]
next unless 1 <= day <= Time.days_in_month(year, month)
puts "%4d-%02d-%02d" % {year, month, day}
break if (count += 1) == 15
end

View file

@ -0,0 +1,109 @@
!
! Palindrome dates
! tested with Intel ifx (IFX) 2025.2.1 20250806 on Kubuntu 26.04
! GNU gfortran (Ubuntu 15.2.0-16ubuntu1) 15.2.0 on Kubuntu 26.04
! VSI Fortran x86-64 V8.7-001 on OpenVMS V9.2-3
! U.B., April 2026
!
program PalindromeDates
implicit none
integer :: yyyy, mm, dd
integer :: nPals=0
yyyy=2030 ! Start value, for 1st palindromic date after 2020-02-02
do while (nPals .lt. 15 .and. yyyy .lt. 10000) ! year 10000 would produce run-time error
call yyyytommdd (yyyy,mm,dd) ! calculate mm,dd from yyyy so that yyyymmdd is a palindrome
if (isPlausibleDate (yyyy,mm,dd)) then ! exclude invalid dates such as 2031-13-02 or 4321-12-34
write (*, '(I4,"-",i2.2,"-",i2.2)') yyyy,mm,dd ! print the rest: valid palindromic dates
nPals = nPals + 1 ! Count valid palindromic dates
end if
yyyy = yyyy+1 ! Try again next year
enddo
contains
! =========================================
! Decide if a given date Y-m-d is plausible
! =========================================
function isPlausibleDate (y,m,d) result (YN)
integer, intent(in) :: y,m,d
logical :: YN
! Max number of Days in each month, Feb is 29 in leap years only.
integer, dimension(12),parameter :: nDays =[31,29,31,30,31,30,31,31,30,31,30,31]
YN = .false.
if (m .lt. 1 .or. m .gt. 12) then ! Impossible Month
return ! Early return .false.
endif
if (d .lt. 1 .or. d .gt. nDays(m)) then ! Impossible day
return ! Early return .false.
endif
! Special case: feb-29
if (m .eq. 2 .and. d .eq. 29) then ! 20-Feb: only OK if Y is a leap year
! Check for leap year
if (isLeapYear (y)) then
YN = .true. ! in a leap year, Feb 29 is correct date
else
return ! Early return .false.
endif
endif
!
! Any date not excluded by now is plausible.
!
YN = .true.
end function isPlausibleDate
! ===============================
! Decide if year y is a leap year
! ===============================
function isLeapYear (y) result (YN)
integer, intent(in) :: y
logical :: YN
!
! Rule: A year is a leap year if it is divisible by 4,
! unless it is divisible by 100 but not by 400.
! e.g. 1900 is NOT a leap year
YN = (mod (y, 4) .eq. 0 .and. (mod(y, 400) .eq. 0 .or. mod(y, 100) .ne. 0))
end function isLeapYear
! =====================================================================
! calculate month m,day d from year y so that yyyymmdd is a palindrome
! =====================================================================
subroutine yyyytommdd (y,m,d)
integer, intent(in) :: y
integer, intent(out) :: m,d
character(len=4) strYear, raeYrts
write (strYear, '(i4)') y ! Convert integer Year to string
raeYrts = reverse (strYear) ! reverse order of characters in strYear so that strYearraeYrts is palindrome
read (raeYrts, '(i2,i2)') m, d ! extract integer month m and day d from reversed year
end subroutine yyyytommdd
! ==========================================================================
! return a 4-letter string in the reverse order of its letters: abcd -> dcba
! ==========================================================================
function reverse (chr) result(rhc)
character (len=4), intent(in) :: chr
character (len=4) :: rhc
integer :: ii
do ii=1, 4
rhc(ii:ii) = chr (5-ii:5-ii)
enddo
end function reverse
end program PalindromeDates

View file

@ -0,0 +1,13 @@
d = #2020-02-02 12:00#
count = 0
do
{
d = d + 1 day
str = (d -> ### yyyyMMdd ###)
if str == reverse[str]
{
println[d -> ### yyyy-MM-dd ###]
count = count + 1
}
} until count == 15

View file

@ -1,18 +1,18 @@
// [dependencies]
// chrono = "0.4"
// chrono = "0.4.44"
fn is_palindrome(s: &str) -> bool {
s.chars().rev().eq(s.chars())
}
fn main() {
let mut date = chrono::Utc::today();
let mut date = chrono::Utc::now().date_naive();
let mut count = 0;
while count < 15 {
if is_palindrome(&date.format("%Y%m%d").to_string()) {
println!("{}", date.format("%F"));
count += 1;
}
date = date.succ();
date = date.succ_opt().unwrap();
}
}

View file

@ -0,0 +1,21 @@
import time
fn is_palindrome(sg string) bool {
return sg == sg.reverse()
}
fn main() {
limit := 15
mut dt, mut num := 0, 0
println("First 15 palindromic dates:\n")
for num < limit {
dt++
date := time.now().add_days(dt)
new_date := "${date.year:04}${date.month:02}${date.day:02}"
new_date_2 := "${date.year:04}-${date.month:02}-${date.day:02}"
if is_palindrome(new_date) {
num++
println(new_date_2)
}
}
}