from math import hypot from random import expovariate from itertools import permutations, starmap, repeat from collections import Counter def test(trials, n): lambdas = [1.0E-3 ** exp for exp in range(n)] for i in repeat(None, trials): data = list(map(expovariate, lambdas)) assert len(set(starmap(hypot, permutations(data)))) == 1, data test(trials = 1_000_000_000, n=5) print('Done')