Simple genetic algorithm in Python