Method: NLife::Helper.golly_to_array
- Defined in:
- lib/nlife/helper.rb
.golly_to_array(string) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/nlife/helper.rb', line 33 def golly_to_array(string) match = %r{^B([0-8]*)\/S([0-8]*)$}.match(string) raise ArgumentError 'wrong input format' unless match birth = (0..8).map { |i| match[1].include? i.to_s } survival = Array.new(9, false) match[2].split(//).map(&:to_i).each { |i| survival[i] = true } return birth, survival end |