-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.py
More file actions
29 lines (26 loc) · 842 Bytes
/
array.py
File metadata and controls
29 lines (26 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def rand_num_cr():
import random
rand_num = random.randint(0, 10)
return rand_num
a = [rand_num_cr(), rand_num_cr(), rand_num_cr(), rand_num_cr(), rand_num_cr(), rand_num_cr()]
average = int(sum(a)/len(a))
print(f'average: {average}')
count = 0
while True:
for i in range(len(a)):
if a[i] <= average:
continue
elif a[i] > average:
surplus = a[i]-average
if i == len(a) - 1 and a[-1] > average:
surplus = a[i] - average
a[0] += surplus
a[i] = average
else:
a[i+1] += surplus
a[i] = average
count += 1
print(f'Array: {a} -- Cycles counter: {count}')
if all(x >= average for x in a):
print("Done!")
exit(0)