import random


def crossover(mum, dad, klass):
    """
    Given two parent genomes and a Genome class, randomly selects a midpoint
    and then swaps the ends of each genome's chromosome to create two new
    genomes that are returned in a tuple.
    """
    # Check if the parents are the same,
    if mum == dad:
        # and do nothing if they are.
        return (mum, dad)

    crossover_point = random.randint(0, len(mum))

    baby1 = klass(mum[:crossover_point] + dad[crossover_point:])
    baby2 = klass(dad[:crossover_point] + mum[crossover_point:])

    return (baby1, baby2)