Class: Fortune::A
- Inherits:
-
P_abstract
- Object
- P_abstract
- Fortune::A
- Defined in:
- lib/fortune/a.rb
Overview
Permutation without repetition with select k elements (accommodation) example: 20 different elements and you need select 5 of them (how many ways of selection exists?)
elements is ordered ([a,b,c] != [b,c,a])
A.calc(:elements => 10, :select => 5)
Instance Attribute Summary
Attributes inherited from P_abstract
Instance Method Summary collapse
-
#initialize(h) ⇒ A
constructor
A new instance of A.
Methods inherited from P_abstract
Constructor Details
#initialize(h) ⇒ A
Returns a new instance of A.
8 9 10 11 |
# File 'lib/fortune/a.rb', line 8 def initialize(h) super(h) self.value = Math.factorial(self.n)/Math.factorial(self.n - self.k) end |