Class: Fortune::Pn_repetition

Inherits:
P_abstract show all
Defined in:
lib/fortune/pn_repetition.rb

Overview

Permutation with repetition example: how many different options you can dress up if there are three sweaters two skirts and two hats (3*2*2, if all thing is equal 3, then: Pn_repetition(:n => 3, :k => 3), k - element groups, n - elements count in group)

Pnr.calc(:groups => 10, :elements => 5)

Instance Attribute Summary

Attributes inherited from P_abstract

#k, #n, #value

Instance Method Summary collapse

Methods inherited from P_abstract

calc

Constructor Details

#initialize(h) ⇒ Pn_repetition

Returns a new instance of Pn_repetition.



7
8
9
10
# File 'lib/fortune/pn_repetition.rb', line 7

def initialize(h)
  super(h, {:n => :groups, :k => :elements})
  self.value = self.n**self.k
end