added comments and fix er

This commit is contained in:
ada-dmitry
2023-08-24 12:34:10 +03:00
parent 121bc010cf
commit 7227efa00e
4 changed files with 24 additions and 9 deletions
+13
View File
@@ -5,7 +5,20 @@
# print(d)
import random
def role_distribution(userIDs):
user_count = len(userIDs)
userIDs = list(userIDs)
resp = {} # resp = {userIDs[i]: 0 for i in range(len(userIDs))}
ls = [0, 0, 1, 1, 0]
ls[4] = user_count//4
ls[1] = user_count - ls[4]-2
random.shuffle(userIDs)
for i in range(5):
for j in range(ls[i]):
print(type(userIDs))
resp[userIDs.pop()] = str(i)
return resp
a = ["a", "b", "c", "d", "e", "f", "g"]
print(role_distribution(a))