scoring is functional!

This commit is contained in:
swaits committed 2008-08-28 18:52:35 -07:00
1 parent 781bb1aa5a
commit 6ad0b7e9d2
4 files changed
+169 -74

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
class Array
def combinations n
result = Array.new
if n > 0
(0 .. self.length - n).each do |i|
combs = self[i + 1 .. -1].combinations(n - 1)
combs = [[]] if combs.empty?
combs.collect {|comb| [self[i]] + comb}.each {|x| result << x}
end
end
return result
end
end