Module: Combinatorics::Derange

Defined in:
lib/combinatorics/derange/mixin.rb,
lib/combinatorics/derange/cardinality.rb

Defined Under Namespace

Modules: Mixin

Class Method Summary collapse

Class Method Details

.cardinality(n) ⇒ Object

Compute the number of derangements for a data structure of given size

See Also:



12
13
14
# File 'lib/combinatorics/derange/cardinality.rb', line 12

def self.cardinality(n)
  Math.subfactorial(n)
end

.D(n) ⇒ Object

Note:

The letter `D' is academic representation for derangements

Wrapper for derangement cardinality method defined above



21
22
23
# File 'lib/combinatorics/derange/cardinality.rb', line 21

def self.D(n)
  cardinality(n)
end