import random


def uni_crossover(parent1, parent2):
    """
    This function implements the uniform crossover method,where each gene of the parent1 has 50% of chance to swap
    with the correspondent gene of parent2
    :param parent1:List represent the parent1
    :param parent2:List represent the parent2
    :return:Return a tuple with 2 elements representing the new individuals generated
    """
    size = min(len(parent1), len(parent2))
    for i in range(size):
        if random.randint(0, 1) < 0.5:
            parent1[i], parent2[i] = parent2[i], parent1[i]

    return parent1, parent2