Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
17
Task/Combinations/Sidef/combinations-2.sidef
Normal file
17
Task/Combinations/Sidef/combinations-2.sidef
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
func combine(n, set) {
|
||||
|
||||
set.len || return []
|
||||
n == 1 && return set.map{[_]}
|
||||
|
||||
var (head, result)
|
||||
head = set.shift
|
||||
result = combine(n-1, [set...])
|
||||
|
||||
for subarray in result {
|
||||
subarray.prepend(head)
|
||||
}
|
||||
|
||||
result + combine(n, set)
|
||||
}
|
||||
|
||||
combine(3, @^5).each {|c| say c }
|
||||
Loading…
Add table
Add a link
Reference in a new issue