79655327

Date: 2025-06-06 01:38:48
Score: 1
Natty:
Report link

How about this method? although a little bit bulky :P

lst = ['A','B','C','D','E','F','G']
count = {i: 0 for i in lst}
n = 3  # length of output list
m = 3  # how many output lists you want

result = []
while len(result) < m:
    r = []
    for i in range(n):
        tmp = min(count, key=lambda k:count[k])
        count[tmp] = count.get(tmp, 0) + 1
        r.append(tmp)
    result.append(r)

print(result)

The output is

[['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'A', 'B']]
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): How
  • Low reputation (0.5):
Posted by: vassiliev