input: Write a python function to find the fittest chromosome in a population using a genetic algorithm.
  assert genetic_algorithm(10, 0.01) < 1e-5
  assert genetic_algorithm(100, 0.01) < 1e-5
  assert genetic_algorithm(50, 0.001) < 1e-6
output: import random
  
  def genetic_algorithm(population_size, mutation_rate):
      def fitness(chromosome):
          return sum(x ** 2 for x in chromosome)
  
      def create_chromosome():
          return [random.uniform(-1, 1) for _ in range(10)]
  
      def mutate(chromosome):
          for i in range(len(chromosome)):
              if random.random() < mutation_rate:
                  chromosome[i] = random.uniform(-1, 1)
  
      def crossover(parent1, parent2):
          point = random.randint(1, len(parent1) - 1)
          return parent1[:point] + parent2[point:], parent2[:point] + parent1[point:]
  
      population = [create_chromosome() for _ in range(population_size)]
      generations = 1000
  
      for _ in range(generations):
          population = sorted(population, key=fitness)
          next_generation = population[:population_size // 2]
  
          while len(next_generation) < population_size:
              parent1, parent2 = random.sample(next_generation[:population_size // 4], 2)
              offspring1, offspring2 = crossover(parent1, parent2)
              mutate(offspring1)
              mutate(offspring2)
              next_generation.extend([offspring1, offspring2])
  
          population = next_generation
  
      return fitness(min(population, key=fitness))