September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
9
Task/Combinations/Jq/combinations.jq
Normal file
9
Task/Combinations/Jq/combinations.jq
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
def combination(r):
|
||||
if r > length or r < 0 then empty
|
||||
elif r == length then .
|
||||
else ( [.[0]] + (.[1:]|combination(r-1))),
|
||||
( .[1:]|combination(r))
|
||||
end;
|
||||
|
||||
# select r integers from the set (0 .. n-1)
|
||||
def combinations(n;r): [range(0;n)] | combination(r);
|
||||
Loading…
Add table
Add a link
Reference in a new issue