Skip to content

Commit ea10cec

Browse files
committed
Merge branch 'master' of https://github.com/Samar-Upreti/Python
2 parents 50f1584 + 1614271 commit ea10cec

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

genetic_algorithm/basic_string.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def mutate(child: str, genes: list[str]) -> str:
5454
"""
5555
child_list = list(child)
5656
if random.uniform(0, 1) < MUTATION_PROBABILITY:
57-
random_index = random.randint(0, len(child)-1)
57+
random_index = random.randint(0, len(child) - 1)
5858
child_list[random_index] = random.choice(genes)
59-
59+
6060
return "".join(child_list)
6161

6262

@@ -178,8 +178,7 @@ def basic(target: str, genes: list[str], debug: bool = True) -> tuple[int, int,
178178
# Flush the old population, keeping some of the best evolutions.
179179
# Keeping this avoid regression of evolution.
180180
population_best = [
181-
item[0]
182-
for item in population_score[: int(N_POPULATION / 3)]
181+
item[0] for item in population_score[: int(N_POPULATION / 3)]
183182
]
184183
population.clear()
185184
population.extend(population_best)

0 commit comments

Comments
 (0)