All possible combination of 3x3 Grid

I have 6 unique modules that need to be placed in a 3x3 grid. Each arrangement should use all 6 modules, leaving exactly 3 positions as empty (voids). I want to know the total number of possible unique combinations that can be generated with this setup, ensuring that each configuration has 6 modules and 3 empty spots. How can I make this ? I tried with two list. Can anyone help with this. I need all the results.

1 Like

You could do something like this using python to find all permutations:

import itertools

items = ['A', 'B', 'C', 'D', 'E', 'F', 'X', 'X', 'X']
uniqp = set(itertools.permutations(items))

comb = [i for i in uniqp]

a = comb

FYI, there are 60,480.

6 Likes

Hello
quite the same thing using Nautilus plugin and Create Sets, I get old result that I get 30,240 and now 60480. A bit long ~8 minutes for the set.
For 9 elements 362 880 = 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9
for 3 elements 2 x 3 = 6
So the result must be like said by @Adam_M 362 880 / 6 = 60,480

See there for others references

2 Likes

If you had 9 different elements, you would have 9! = 362 880 combinations, but 3 elements are the same, so you basically have only a 3!th of the combinations, e.g. division by 6.

362_880 / 6 = 60_480

The error is probably that the component treats every “X” as a unique element, not as the “same”.

I don’t think so, it works here



and now it works !!! There is something strange, but Xreate set is VERY VERY long

or Create Set has a limitation ?
permutations 9 elements LD.gh (294.6 KB)

The permutations function takes a second parameter, enabling one to select N items:


241031_GridPermutationsN_00.gh (11.9 KB)

Also, note that finding the permutations isn’t actually that expensive. It’s outputting all that data that costs, where in this case one should probably wrap the grid cells in a Grasshopper curve type.

I get only 84. Adapted Python code from here:


Combos_2024Oct31a.gh (13.4 KB)

P.S. Added white group as a visual aid:


Combos_2024Oct31bb.gh (19.4 KB) UPDATED!

P.P.S. I noticed that the last two grids (top row) in my visual aid had the same pattern :interrobang: Fortunately it’s a simple off-by-one error, easily fixed. Top row now shows four grids, not five. UPDATED version ‘bb’ above.

2 Likes

Reading that more thoroughly, you probably want to use the combinations function instead. Which, as @Joseph_Oster points out, yields 84 unique combinations:


241031_GridCombinationsN_00.gh (12.9 KB)

Edit: Made them meshes and slapped them into a grid. I wonder if the same patterns rotated/mirrored would not count as a unique configuration. Either way, fun stuff:


241101_GridCombinationsN_00.gh (15.8 KB)

3 Likes

I made a bitmap with the 60480 permutations I have.


Plugins not mandatory if you have a tool that saves bitmap.
permutations 9 elements LD2.gh (295.9 KB)

2 Likes