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
20
Task/Ordered-Partitions/Sidef/ordered-partitions.sidef
Normal file
20
Task/Ordered-Partitions/Sidef/ordered-partitions.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
func part(_, {.is_empty}) { [[]] }
|
||||
func partitions({.is_empty}) { [[]] }
|
||||
|
||||
func part(s, args) {
|
||||
gather {
|
||||
s.combinations(args[0], { |c|
|
||||
part(s - c, args.ft(1)).each{|r| take([c] + r) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func partitions(args) {
|
||||
part(@(1..args.sum), args)
|
||||
}
|
||||
|
||||
[[],[0,0,0],[1,1,1],[2,0,2]].each { |test_case|
|
||||
say "partitions #{test_case}:"
|
||||
partitions(test_case).each{|part| say part }
|
||||
print "\n"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue