Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,22 @@
CREATE OR REPLACE FUNCTION combinations(n, k) as table (
WITH RECURSIVE cte(current, remaining) AS (
-- start with empty combination and the full list
SELECT
[],
range(1, n + 1)
UNION ALL
-- recursive case: add one item to the current combination
SELECT
current || remaining[j:j],
remaining[j+1:]
FROM cte, range(1, length(remaining)+1) _(j)
WHERE length(current) < k
)
SELECT current AS combination
FROM cte
WHERE length(current) = k
);
## Example:
FROM combinations(5,3)
ORDER BY combination;

View file

@ -15,8 +15,8 @@ public program()
var numbers := Numbers(N);
Combinator.new(M, numbers).forEach::(row)
{
console.printLine(row.toString())
Console.printLine(row.toString())
};
console.readChar()
Console.readChar()
}

View file

@ -0,0 +1,10 @@
require "perm"
local fmt = require "fmt"
local a = range(0, 4)
local co = coroutine.create(comb.generate)
while true do
local _, res = coroutine.resume(co, a, 3)
if !res then break end
fmt.lprint(res)
end