Class Integer
In: combinations.rb
permutations.rb
Parent: Object

Methods

Public Instance methods

Yield a sequence of combinations taken k at a time from the numbers (0..n-1) where n is self. Returns the number of such combinations. Returns nil if the parameter or self value are out of range.

[Source]

# File combinations.rb, line 100
        def combinations(k)
                c = Combinations.new(self, k)
                if block_given?
                        c.each { |a| yield a}
                else
                        c.each
                end
        end

Yield all permutations of 0..self-1. Return the number of permutations.

[Source]

# File permutations.rb, line 59
        def permutations
                p = Permutations.new(self)
                if block_given?
                        p.each {|a| yield a}
                else
                        p.each
                end
        end

[Validate]