cristi:~ diciu$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> def generator(low=20, high=67, count=100, avg=42):
... L=[]
... while 1:
... sum=reduce(lambda x,y:x+y, L, 0)
... rnd = random.randrange(low, high+1)
... if sum + rnd < avg*count:
... L.append(rnd)
... else:
... L.append(avg*count - sum)
... break
... return L
...
>>> generator()
[26, 44, 53, 64, 57, 62, 22, 63, 24, 39, 41, 26, 22, 31, 51, 22, 57, 20, 29, 62, 24, 38, 26, 60, 50, 23, 45,
37, 21, 43, 43, 40, 65, 53, 38, 34, 46, 21, 49, 43, 53, 51, 39, 20, 45, 40, 45, 63, 23, 25, 26, 35, 23, 39,
32, 27, 47, 63, 38, 35, 50, 37, 45, 55, 44, 29, 51, 35, 51, 52, 45, 66, 38, 62, 32, 23, 59, 54, 38, 64, 62,
42, 26, 54, 59, 48, 32, 28, 27, 56, 50, 40, 44, 56, 60, 52, 62, 30, 38, 21]