简体   繁体   English

带分组的数组填充

[英]Array Fill w/Grouping

This is one of those, " I wish I had listened better, retained more of my math class info..", questions. 这就是“我希望我能听得更好,保留更多我的数学课信息..”的问题之一。 I did this with brute force, but I know there's a better more correct way of accomplishing this. 我是用蛮力做到的,但是我知道有一种更好的,更正确的方法来实现。

Given a 4 x 4 array of stations, and 8 groups(ah). 给定4 x 4站阵列和8组(ah)。 How to fill the array with group pair combinations so each pair(ab, ba) occurs only once, and each group occurs only once in each row and column? 如何用组对组合填充数组,以便每个对(ab,ba)仅出现一次,并且每个组在每一行和每一列中仅出现一次? (If a is part of a pair in 1,1, it can no long appear in a grouping in row 1 or column 1) (如果a是1,1中的对的一部分,则它不能再出现在第1行或第1列的分组中)

Of course not all possible groupings happen. 当然,并非所有可能的分组都发生。

是的,我认为蛮力是要走的路,尽管您可以根据需要更明智地投资于修剪分支机构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM