This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
Point = namedtuple('Point', ['x', 'y']) | |
def circle(distance): | |
return lambda point: (point.x ** 2. + point.y ** 2.) ** (1/2.) < distance | |
def offset(region, position): | |
return lambda point: region(Point(x=point.x-position.x, y=point.y-position.y)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 72.217263 seconds generating 10.000.000 chromosomes | |
def generate_chromosome_1(length, alleles) | |
(1..length).collect { alleles[rand(alleles.size)] }.join | |
end | |
# 64.619006 seconds generating 10.000.000 chromosomes | |
def generate_chromosome_2(length, alleles) | |
chromosome = String.new | |
for i in 1..length |