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,60 +0,0 @@
with Ada.Text_IO;
with Ada.Containers.Hashed_Sets;
procedure Mian_Chowla_Sequence
is
type Natural_Array is array(Positive range <>) of Natural;
function Hash(P : in Positive) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type(P);
end Hash;
package Positive_Sets is new Ada.Containers.Hashed_Sets(Positive, Hash, "=");
function Mian_Chowla(N : in Positive) return Natural_Array
is
return_array : Natural_Array(1 .. N) := (others => 0);
nth : Positive := 1;
candidate : Positive := 1;
seen : Positive_Sets.Set;
begin
while nth <= N loop
declare
sums : Positive_Sets.Set;
terms : constant Natural_Array := return_array(1 .. nth-1) & candidate;
found : Boolean := False;
begin
for term of terms loop
if seen.Contains(term + candidate) then
found := True;
exit;
else
sums.Insert(term + candidate);
end if;
end loop;
if not found then
return_array(nth) := candidate;
seen.Union(sums);
nth := nth + 1;
end if;
candidate := candidate + 1;
end;
end loop;
return return_array;
end Mian_Chowla;
length : constant Positive := 100;
sequence : constant Natural_Array(1 .. length) := Mian_Chowla(length);
begin
Ada.Text_IO.Put_Line("Mian Chowla sequence first 30 terms :");
for term of sequence(1 .. 30) loop
Ada.Text_IO.Put(term'Img);
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line("Mian Chowla sequence terms 91 to 100 :");
for term of sequence(91 .. 100) loop
Ada.Text_IO.Put(term'Img);
end loop;
end Mian_Chowla_Sequence;

View file

@ -1,6 +1,6 @@
mianChowla: function [n][
result: new [1]
sums: new [2]
result: [1]
sums: [2]
candidate: 1
while [n > size result][

View file

@ -1,45 +0,0 @@
' Mian-Chowla sequence - VBScript - 15/03/2019
Const m = 100, mm=28000
ReDim r(mm), v(mm * 2)
Dim n, t, i, j, l, s1, s2, iterate_t
ReDim seq(m)
t0=Timer
s1 = "1": s2 = ""
seq(1) = 1: n = 1: t = 1
Do While n < m
t = t + 1
iterate_t = False
For i = 1 to t * 2
v(i) = 0
Next
i = 1
Do While i <= t And Not iterate_t
If r(i) = 0 Then
j = i
Do While j <= t And Not iterate_t
If r(j) = 0 Then
l = i + j
If v(l) = 1 Then
r(t) = 1
iterate_t = True
End If
If Not iterate_t Then v(l) = 1
End If
j = j + 1
Loop
End If
i = i + 1
Loop
If Not iterate_t Then
n = n + 1
seq(n) = t
if n<= 30 then s1 = s1 & " " & t
if n>=91 and n<=100 then s2 = s2 & " " & t
End If
Loop
wscript.echo "t="& t
wscript.echo "The Mian-Chowla sequence for elements 1 to 30:"
wscript.echo s1
wscript.echo "The Mian-Chowla sequence for elements 91 to 100:"
wscript.echo s2
wscript.echo "Computation time: "& Int(Timer-t0) &" sec"

View file

@ -1,43 +0,0 @@
' Mian-Chowla sequence - VBScript - March 19th, 2019
Function Find(x(), val) ' finds val on a pre-sorted list
Dim l, u, h : l = 0 : u = ubound(x) : Do : h = (l + u) \ 2
If val = x(h) Then Find = h : Exit Function
If val > x(h) Then l = h + 1 Else u = h - 1
Loop Until l > u : Find = -1
End Function
' adds next item from a() to result (r()), adds all remaining items
' from b(), once a() is exhausted
Sub Shuffle(ByRef r(), a(), b(), ByRef i, ByRef ai, ByRef bi, al, bl)
r(i) = a(ai) : ai = ai + 1 : If ai > al Then Do : i = i + 1 : _
r(i) = b(bi) : bi = bi + 1 : Loop until bi = bl
End Sub
Function Merger(a(), b(), bl) ' merges two pre-sorted lists
Dim res(), ai, bi, i : ReDim res(ubound(a) + bl) : ai = 0 : bi = 0
For i = 0 To ubound(res)
If a(ai) < b(bi) Then Shuffle res, a, b, i, ai, bi, ubound(a), bl _
Else Shuffle res, b, a, i, bi, ai, bl, ubound(a)
Next : Merger = res
End Function
Const n = 100 : Dim mc(), sums(), ts(), sp, tc : sp = 1 : tc = 0
ReDim mc(n - 1), sums(0), ts(n - 1) : mc(0) = 1 : sums(sp - 1) = 2
Dim sum, i, j, k, st : st = Timer
wscript.echo "The Mian-Chowla sequence for elements 1 to 30:"
wscript.stdout.write("1 ")
For i = 1 To n - 1 : j = mc(i - 1) + 1 : Do
mc(i) = j : For k = 0 To i
sum = mc(k) + j : If Find(sums, sum) >= 0 Then _
tc = 0 : Exit For Else ts(tc) = sum : tc = tc + 1
Next : If tc > 0 Then
nu = Merger(sums, ts, tc) : ReDim sums(ubound(nu))
For e = 0 To ubound(nu) : sums(e) = nu(e) : Next
tc = 0 : Exit Do
End If : j = j + 1 : Loop
if i = 90 then wscript.echo vblf & vbLf & _
"The Mian-Chowla sequence for elements 91 to 100:"
If i < 30 or i >= 90 Then wscript.stdout.write(mc(i) & " ")
Next
wscript.echo vblf & vbLf & "Computation time: "& Timer - st &" seconds."