Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
22
Task/Combinations/DuckDB/combinations.duckdb
Normal file
22
Task/Combinations/DuckDB/combinations.duckdb
Normal 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;
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
10
Task/Combinations/Pluto/combinations.pluto
Normal file
10
Task/Combinations/Pluto/combinations.pluto
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue