Evaluate how similar the item is with the target by just counting each char in the right position >>> evaluate("Helxo Worlx", "Hello World") ('Helxo Worlx', 9.0)
(item: str, main_target: str)
| 22 | |
| 23 | |
| 24 | def evaluate(item: str, main_target: str) -> tuple[str, float]: |
| 25 | """ |
| 26 | Evaluate how similar the item is with the target by just |
| 27 | counting each char in the right position |
| 28 | >>> evaluate("Helxo Worlx", "Hello World") |
| 29 | ('Helxo Worlx', 9.0) |
| 30 | """ |
| 31 | score = len([g for position, g in enumerate(item) if g == main_target[position]]) |
| 32 | return (item, float(score)) |
| 33 | |
| 34 | |
| 35 | def crossover(parent_1: str, parent_2: str) -> tuple[str, str]: |