td1 ={}
td2 = {}
td3 = {}
td4 = {}
test.json
{
"a1":"a11",
"b1":"b11",
"c1":"c11",
"sub1":
{
"d1":"d11",
"e1":"e11",
"f1":"f11",
......
......
......
"f10":"f100"
},
"sub2":
{
"g1":"g11",
"h1":"h11",
"i1":"i11",
......
......
......
"j10":"j100"
}
}
输出应为:
td1 = {"d1":"sub1","g1":"sub2","f20":"sub1"}
td2 = {"e1":"sub1","h1":"sub2","d20":"sub1"}
td3 = {"e10":"sub1","h12":"sub2","d15":"sub1"}
td4 = {"f10":"sub1","j10":"sub2","f12":"sub1"}
JSON
和sub1
的{{1}}内容的所有元素应平均分布在4个字典中(sub2
)
假设,如果sub1有12个元素,则每个词典将获得3个元素分布。
如果存在2、3、5、13或14个元素,则应进行相应分配。
也与td1,td2,td3,td4
类似。
sub2
。如果No duplication
已分配给d1
,则不能分配给任何其他字典。
如何实现? td1,
?还是任何其他机制,例如By grouping
或round-robin
元素概念?