Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View 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"
}