Open kripso opened 11 months ago
import random from functools import reduce def gen_avg(expected_avg=27, n=22, a=20, b=46): while True: l = [random.randint(a, b) for i in range(n)] avg = reduce(lambda x, y: x + y, l) / len(l) if avg == expected_avg: return l print(gen_avg())