Module: RotationMutator
- Defined in:
- lib/charlie/permutation/permutation.rb
Overview
Rotates the representation of the permutation (i.e. effectively does nothing if it represents a cycle)
-
Example: [1 2 3 4] to [3 4 1 2]
Instance Method Summary collapse
Instance Method Details
#mutate! ⇒ Object
70 71 72 73 74 |
# File 'lib/charlie/permutation/permutation.rb', line 70 def mutate! new_start = @genes.rand_index @genes = @genes[new_start..-1] + @genes[0...new_start] self end |