Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Combinations/Seed7/combinations.seed7
Normal file
35
Task/Combinations/Seed7/combinations.seed7
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const type: combinations is array array integer;
|
||||
|
||||
const func combinations: comb (in array integer: arr, in integer: k) is func
|
||||
result
|
||||
var combinations: combResult is combinations.value;
|
||||
local
|
||||
var integer: x is 0;
|
||||
var integer: i is 0;
|
||||
var array integer: suffix is 0 times 0;
|
||||
begin
|
||||
if k = 0 then
|
||||
combResult := 1 times 0 times 0;
|
||||
else
|
||||
for x key i range arr do
|
||||
for suffix range comb(arr[succ(i) ..], pred(k)) do
|
||||
combResult &:= [] (x) & suffix;
|
||||
end for;
|
||||
end for;
|
||||
end if;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var array integer: aCombination is 0 times 0;
|
||||
var integer: element is 0;
|
||||
begin
|
||||
for aCombination range comb([] (0, 1, 2, 3, 4), 3) do
|
||||
for element range aCombination do
|
||||
write(element lpad 3);
|
||||
end for;
|
||||
writeln;
|
||||
end for;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue