import random


def random_partition(factors,n_factors):
    """
    factors = list of prime factors of a number
    n_factors = three-tuple [#px, #py, #pz] indicating the number
    of prime factors that should be chosen (at random) for each direction
    
    returns [px,py,pz]
    
    """
    
    l_factors = factors[:] # make a local copy
    
    p_list = [1,1,1]
    
    for d in range(3):
        for i in range(n_factors[d]):
            c = random.choice(l_factors)
            l_factors.remove(c)
            p_list[d]*=c
    return p_list