Class: Fortune::Pn_repetition
- Inherits:
-
P_abstract
- Object
- P_abstract
- Fortune::Pn_repetition
- 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
Instance Method Summary collapse
-
#initialize(h) ⇒ Pn_repetition
constructor
A new instance of Pn_repetition.
Methods inherited from P_abstract
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 |