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,56 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Combinations is
generic
type Integers is range <>;
package Combinations is
type Combination is array (Positive range <>) of Integers;
procedure First (X : in out Combination);
procedure Next (X : in out Combination);
procedure Put (X : Combination);
end Combinations;
package body Combinations is
procedure First (X : in out Combination) is
begin
X (1) := Integers'First;
for I in 2..X'Last loop
X (I) := X (I - 1) + 1;
end loop;
end First;
procedure Next (X : in out Combination) is
begin
for I in reverse X'Range loop
if X (I) < Integers'Val (Integers'Pos (Integers'Last) - X'Last + I) then
X (I) := X (I) + 1;
for J in I + 1..X'Last loop
X (J) := X (J - 1) + 1;
end loop;
return;
end if;
end loop;
raise Constraint_Error;
end Next;
procedure Put (X : Combination) is
begin
for I in X'Range loop
Put (Integers'Image (X (I)));
end loop;
end Put;
end Combinations;
type Five is range 0..4;
package Fives is new Combinations (Five);
use Fives;
X : Combination (1..3);
begin
First (X);
loop
Put (X); New_Line;
Next (X);
end loop;
exception
when Constraint_Error =>
null;
end Test_Combinations;

View file

@ -1 +0,0 @@
type Five is range 0..4;

View file

@ -10,7 +10,7 @@ Numbers(n)
^ Array.allocate(n).populate::(int n => n)
}
public program()
public Program()
{
var numbers := Numbers(N);
Combinator.new(M, numbers).forEach::(row)

View file

@ -1,11 +0,0 @@
(defun comb-recurse (m n n-max)
(cond ((zerop m) '(()))
((= n-max n) '())
(t (append (mapcar #'(lambda (rest) (cons n rest))
(comb-recurse (1- m) (1+ n) n-max))
(comb-recurse m (1+ n) n-max)))))
(defun comb (m n)
(comb-recurse m 0 n))
(comb 3 5)

View file

@ -1,35 +0,0 @@
$source = @'
using System;
using System.Collections.Generic;
namespace Powershell
{
public class CSharp
{
public static IEnumerable<int[]> Combinations(int m, int n)
{
int[] result = new int[m];
Stack<int> stack = new Stack<int>();
stack.Push(0);
while (stack.Count > 0) {
int index = stack.Count - 1;
int value = stack.Pop();
while (value < n) {
result[index++] = value++;
stack.Push(value);
if (index == m) {
yield return result;
break;
}
}
}
}
}
}
'@
Add-Type -TypeDefinition $source -Language CSharp
[Powershell.CSharp]::Combinations(3,5) | Format-Wide {$_} -Column 3 -Force

View file

@ -1,10 +1,3 @@
# both from https://github.com/Omnikar/uiua-math/blob/main/lib.ua
PowerSet ← ⍚▽⋯⇡ⁿ:2⧻⟜¤
Perms ← ☇1⍉∧(≡↻⇡⟜↯+1⟜⊂):¤¤°⊂
Permute ← ≡⊏⊙¤⊸(Perms⇡⧻) # Optional helper function.
# Order is unimportant here. If order is important prepend `☇1≡Permute` to the results.
Choose ← ≡°□▽=⊙(⊸(≡◇⧻)PowerSet)
⊏⊸⍏Choose 3 ⇡5 # Choose and sort results
3 5 # 3 combo 5
⊙⇡ # Create the array of numbers
⧅< # Get the permutations

View file

@ -1,40 +0,0 @@
Function Dec2Bin(n)
q = n
Dec2Bin = ""
Do Until q = 0
Dec2Bin = CStr(q Mod 2) & Dec2Bin
q = Int(q / 2)
Loop
Dec2Bin = Right("00000" & Dec2Bin,6)
End Function
Sub Combination(n,k)
Dim arr()
ReDim arr(n-1)
For h = 0 To n-1
arr(h) = h + 1
Next
Set list = CreateObject("System.Collections.Arraylist")
For i = 1 To 2^n
bin = Dec2Bin(i)
c = 0
tmp_combo = ""
If Len(Replace(bin,"0","")) = k Then
For j = Len(bin) To 1 Step -1
If CInt(Mid(bin,j,1)) = 1 Then
tmp_combo = tmp_combo & arr(c) & ","
End If
c = c + 1
Next
list.Add Mid(tmp_combo,1,(k*2)-1)
End If
Next
list.Sort
For l = 0 To list.Count-1
WScript.StdOut.Write list(l)
WScript.StdOut.WriteLine
Next
End Sub
'Testing with n = 5 / k = 3
Call Combination(5,3)