A lego question


Something that I did during school but can't recollect now...

Have 20 different unique lego shapes, each one can fit into another and form a new shape. First can fit into second and form a new shape, second can fit into third or all the remaining 18 to bring about new shapes.

What would be the formula for this permutation / combination? How many total permutations / combination can be there with these 20?
Who is Participating?
TommySzalapskiConnect With a Mentor Commented:
Yes, there is no way to answer this question without knowing how many different ways each piece could fit with another.

Even if you did have all the pieces, it would be a very complicated problem because how you attach one piece will affect how many different ways you can connect the next piece.

If you are just stacking them (second one on top of first, etc) then it's a standard permutation and the answer is 20! which is 2,432,902,008,176,640,000 so billions doesn't even scratch the surface.

2^20 is just how many different combinations of pieces there are. As in, there are 2^20 different ways you could pick a subset of the pieces to attach. (2^20 - 1 is if you skip the case where you pick none of them).

20! may be more what you were remembering, but that doesn't take into account the different shapes and how they can connect differently.
this is the power set problem

the answer is   (2^20 - 1) = 1048575
actually, the answer is going to be a lot bigger.

once you have a subset of n pieces, there may be n! (or more) unique ways to put them together.
you would have to look at the shapes and connection rules in more detail.
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

fahimAuthor Commented:
I thought so, the answer should be in millions...even billions.
d-glitchConnect With a Mentor Commented:
If you look at the numbers in Paschal's triangle, that will tell you how many subsets there are for each number of pieces.  Then you can assume n! combinations for each subset.

This is probably closer but still very rough.
Of course that is still assuming only one way of connecting them. The exact same numbers would work for the different ways to build a deck out of 20 cards. There's nothing special yet about them being Legos.
>> TommySzalapski
     Of course that is still assuming only one way of connecting them.

I agree.  The approximation I gave is geared toward a 2-D stacking solution, more like domimos than cards.  But Legos can certainly take on complex 3D shapes as well.
Huh, I thought it would come out cleaner. Looks like we have an incomplete gamma function problem now
...and form a new shape.
Also, define "shape". Any given combination of pieces might give the same 'shape' that some other combination might give as a result.

Combinations of attachments and order of attachments isn't quite the same as 'shapes'.

ozoConnect With a Mentor Commented:
If all 20 pieces are different shapes, and you only stack them linearly, than any different combination would also be a different shape.

I looked at the pick-a-brick page on the lego.com site, and only found 14 different basic rectangular brick shapes.
If the rest of your 20 unique shapes are rectangular plates, we can deal with that as combinatorially equivalent to a brick, but if your 20 unique shapes also include slopes, angles or other specials that could make it harder.
If you also want to include combinations where more than one piece can be put on a given side of another piece, then that introduces interdependent constraints that can make the enumeration impossibly complex.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.