区域内的排列量?
Amount of permutations inside an area?
我有以下情况:
- 一个 GridPane 划分为多个单元格,所以 f.e。 6 x 6 = 36 个单元格
- 需要放入该区域的具体元素数量,f.e。 6
- 每个元素都有一个面积,f.e。 {3, 6, 4, 5, 6, 12},这样总面积又是总的(36)
这是我的问题:我如何计算有多少可能的选择 我必须:
计算元素的行/列跨度(高度/宽度):对于 6 的区域,不同的选项可以是例如 6x1、1x6、3x2 和 2x3 .. 必要条件 就是元素需要是正方形或者长方形,所以f.e。不是 U 形或 T 形占据单元格中的网格。这就是我挣扎的地方!
那么我应该像 if 案例那样做案例吗?我想有一种更有效的方法可以做到这一点!什么是条件?
将这些元素放在区域内
我正在 java 和 javafx 编程。
到目前为止,我尝试了以下方法来计算跨度 /height/width:
int NumberRow = 6;
int NumberColum = 6;
int columspan;
int rowspan;
int area = 6;
if (area / NumberRow == 1) {
columspan = 1;
rowspan = area;}
if (area/NumberColum== 1) {
columspan = area;
rowspan = 1;
}
// if area modulo NumberColum or NumberRow == 0 it's an multiple..
if (area % NumberColum == 0 ) {
???? --> what would make sense here ?
}
VBox v = new VBox();
v.getChildren().addAll(h1, t, image);
grid.add(v, colum, row, columspan, rowspan);
元素数组可以按大小递减排序。
由于要填满整个区域,可以从上到下,从左到右填满。
对于每个区域元素,都必须遍历可能的形式;对于 6: (1, 6), (6, 1), (2, 3), (3, 2):寻找因子对。
带回溯的递归;递归看起来像:
if (free space == 0)
print success with placements
++solution count
return;
for every candidate:
if (candidate fits here)
place candidate here
recurse (candidates without candidate)
remove candidate here
我不会破坏摆在你面前的令人费解的谜题。
我有以下情况:
- 一个 GridPane 划分为多个单元格,所以 f.e。 6 x 6 = 36 个单元格
- 需要放入该区域的具体元素数量,f.e。 6
- 每个元素都有一个面积,f.e。 {3, 6, 4, 5, 6, 12},这样总面积又是总的(36)
这是我的问题:我如何计算有多少可能的选择 我必须:
计算元素的行/列跨度(高度/宽度):对于 6 的区域,不同的选项可以是例如 6x1、1x6、3x2 和 2x3 .. 必要条件 就是元素需要是正方形或者长方形,所以f.e。不是 U 形或 T 形占据单元格中的网格。这就是我挣扎的地方! 那么我应该像 if 案例那样做案例吗?我想有一种更有效的方法可以做到这一点!什么是条件?
将这些元素放在区域内
我正在 java 和 javafx 编程。
到目前为止,我尝试了以下方法来计算跨度 /height/width:
int NumberRow = 6;
int NumberColum = 6;
int columspan;
int rowspan;
int area = 6;
if (area / NumberRow == 1) {
columspan = 1;
rowspan = area;}
if (area/NumberColum== 1) {
columspan = area;
rowspan = 1;
}
// if area modulo NumberColum or NumberRow == 0 it's an multiple..
if (area % NumberColum == 0 ) {
???? --> what would make sense here ?
}
VBox v = new VBox();
v.getChildren().addAll(h1, t, image);
grid.add(v, colum, row, columspan, rowspan);
元素数组可以按大小递减排序。
由于要填满整个区域,可以从上到下,从左到右填满。
对于每个区域元素,都必须遍历可能的形式;对于 6: (1, 6), (6, 1), (2, 3), (3, 2):寻找因子对。
带回溯的递归;递归看起来像:
if (free space == 0)
print success with placements
++solution count
return;
for every candidate:
if (candidate fits here)
place candidate here
recurse (candidates without candidate)
remove candidate here
我不会破坏摆在你面前的令人费解的谜题。