我正在尝试某种方式来实现这个概念(在Python中,但我可以翻译,这不是问题)但不知道从哪里开始:
这是设置:
#"collection" "oNum" "object"
object_collection = [[o01, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o02, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o03, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o04, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o05, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o06, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o07, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o08, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o09, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o10, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o11, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o12, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o13, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o14, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o15, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o16, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o17, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o18, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o19, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o20, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o21, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o22, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o23, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]],
[o24, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]]]
我知道,这可能更好地概括为字典,所以这不是限制。
问题的参数是:
1.需要对“对象”的值求和
---->所有“对象”将是0和15之间的随机整数
---->所有“对象”总和不能超过100(但它们可以小于100)
例如:
object_collection = [[o01, [11]], # 0 + 11 = 11
[o02, [2]], # 11 + 2 = 13
[o03, [1]], # 13 + 1 = 14
[o04, [6]], # 14 + 6 = 20
[o05, [5]], # 20 + 5 = 25
[o06, [4]], # 25 + 4 = 29
[o07, [3]], # 29 + 3 = 32
[o08, [2]], # 32 + 2 = 34
[o09, [1]], #...
# X + Y <= 100
#... you get the point
如果所有24个值都设置为最大值,则总值将超过100,但问题的基础集中在识别 比率 之间的相关性,而不是各个原始数据点。从技术上讲,每个“对象”的最大值为100,但将一个对象的值设置为100会为任何其他对象留下0。
我已经尝试了一些东西,但是你可能会有任何帮助。
谢谢。