我的问题有点复杂,但是这个问题可以用一个例子来写得相当笼统:我有一个池列表(pools)需要有一个子列表(children)均匀分布在列表中pools。
该children列表已经排序,因此可以安全地假设它可以按pools当前顺序分布在 上。
例如,如果我有并且[pool1, pool2]我[child1, child2, child3]希望pool1被分配child1并且将被分配:child3pool2child2
pools = ['pool1', 'pool2']
children = ['child1', 'child2', 'child3']
def print_assignment(pool, child)
print('{} assigned to {}'.format(child, pool)
# The expectation is that distribute would perform the core logic and
# call print_assignment during each assignment
distribute(pools, children, print_assignment)
预期输出为:
child1 assigned to pool1
child2 assigned to pool2
child3 assigned to pool1
期望pools和的数量children可以是任意大小,但是,以下情况始终为真:len(pools) < len(children)。
守着一只汪
潇潇雨雨
子衿沉夜
相关分类