add other game scoring scripts
This commit is contained in:
1 parent
9a87aca70c
commit
c864cf5cdb
73 files changed
+2311
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user