thenapolitan
Board Regular
- Joined
- Sep 5, 2014
- Messages
- 52
Hey Guys,
I've been racking my brain and can't seem to figure out the coding logic for what I'm doing. Basically, what I want to do is get all the combinations for a subset of parts to eventually come up with a gap/tolerance stack equation (not automated, yet).
I ask the user how many unique parts exist (in the example below, the user entered 3, but could be any number). I then ask how many duplicates of each (in this case 3 of part 1, 3 of part 2, and 2 of part 3, but again, these numbers could vary). It populates TABLE 1 below.
I populate a 2D array like this, but I'm not sure this is really how it should be done.
<tbody>
</tbody>
Now, I want to make a matrix to show all combinations of those parts. There should be 18 combinations (3*3*2). And I want the matrix to look like TABLE 2.
I just can't wrap my head around how to get this to work for any number of unique parts, with any number of duplicates and any number of dimensions.
Any ideas?
Thanks,
Chris
TABLE 1
<tbody>
</tbody>
TABLE 2
<tbody>
</tbody>
I've been racking my brain and can't seem to figure out the coding logic for what I'm doing. Basically, what I want to do is get all the combinations for a subset of parts to eventually come up with a gap/tolerance stack equation (not automated, yet).
I ask the user how many unique parts exist (in the example below, the user entered 3, but could be any number). I then ask how many duplicates of each (in this case 3 of part 1, 3 of part 2, and 2 of part 3, but again, these numbers could vary). It populates TABLE 1 below.
I populate a 2D array like this, but I'm not sure this is really how it should be done.
part | # of parts | dims |
1 | 3 | 3 |
2 | 3 | 2 |
3 | 2 | 1 |
<tbody>
</tbody>
Now, I want to make a matrix to show all combinations of those parts. There should be 18 combinations (3*3*2). And I want the matrix to look like TABLE 2.
I just can't wrap my head around how to get this to work for any number of unique parts, with any number of duplicates and any number of dimensions.
Any ideas?
Thanks,
Chris
TABLE 1
A | B | C | D | E | F | G | H | I |
Part: | 1 | Number of Parts: | 3 | Number of Dimensions: | 3 | |||
Dim 1 | Dim 2 | Dim 3 | ||||||
Part 1 of 1: | 111 | 112 | 113 | |||||
Part 2 of 1: | 121 | 122 | 123 | |||||
Part 3 of 1: | 131 | 132 | 133 | |||||
Part: | 2 | Number of Parts: | 3 | Number of Dimensions: | 2 | |||
Dim 1 | Dim 2 | |||||||
Part 1 of 2: | 211 | 212 | ||||||
Part 2 of 2: | 221 | 222 | ||||||
Part 3 of 2: | 231 | 232 | ||||||
Part: | 3 | Number of Parts: | 2 | Number of Dimensions: | 1 | |||
Dim 1 | ||||||||
Part 1 of 3: | 311 | |||||||
Part 2 of 3: | 321 |
<tbody>
</tbody>
TABLE 2
Combo # | Part 1 | Part 2 | Part 3 | Part 1 Dim 1 | Part 1 Dim 2 | Part 1 Dim 3 | Part 2 Dim 1 | Part 2 Dim 2 | Part 3 Dim 1 | Gap Formula |
1 | 1 | 1 | 1 | 111 | 112 | 113 | 211 | 212 | 311 | |
2 | 1 | 1 | 2 | 111 | 112 | 113 | 211 | 212 | 321 | |
3 | 1 | 2 | 1 | 111 | 112 | 113 | 221 | 222 | 311 | |
4 | 1 | 2 | 2 | 111 | 112 | 113 | 221 | 222 | 321 | |
5 | 1 | 3 | 1 | 111 | 112 | 113 | 231 | 232 | 311 | |
6 | 1 | 3 | 2 | 111 | 112 | 113 | 231 | 232 | 321 | |
7 | 2 | 1 | 1 | 121 | 122 | 123 | 211 | 212 | 311 | |
8 | 2 | 1 | 2 | 121 | 122 | 123 | 211 | 212 | 321 | |
9 | 2 | 2 | 1 | 121 | 122 | 123 | 221 | 222 | 311 | |
10 | 2 | 2 | 2 | 121 | 122 | 123 | 221 | 222 | 321 | |
11 | 2 | 3 | 1 | 121 | 122 | 123 | 231 | 232 | 311 | |
12 | 2 | 3 | 2 | 121 | 122 | 123 | 231 | 232 | 321 | |
13 | 3 | 1 | 1 | 131 | 132 | 133 | 211 | 212 | 311 | |
14 | 3 | 1 | 2 | 131 | 132 | 133 | 211 | 212 | 321 | |
15 | 3 | 2 | 1 | 131 | 132 | 133 | 221 | 222 | 311 | |
16 | 3 | 2 | 2 | 131 | 132 | 133 | 221 | 222 | 321 | |
17 | 3 | 3 | 1 | 131 | 132 | 133 | 231 | 232 | 311 | |
18 | 3 | 3 | 2 | 131 | 132 | 133 | 231 | 232 | 321 |
<tbody>
</tbody>