• + 0 comments
    def solve(y):
        y, n  = sorted(y,reverse=True), len(y) 
        num_replicas, total = 0, 1
        factorial_i_minus_1 = 1
        
        for i in range(2,n+1):
            factorial_i_minus_1 *= i-1
            is_replica = y[i-1]==y[i-2]
            num_replicas = is_replica * (is_replica + num_replicas)
            total += i * total + factorial_i_minus_1 * (i - num_replicas)
            
        return ["{0:.2f}".format(total/factorial_i_minus_1/n)]