add other game scoring scripts

This commit is contained in:
swaits committed 2010-10-03 18:59:24 -07:00
1 parent 9a87aca70c
commit c864cf5cdb
73 files changed
+2311

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