SERVING THE QUANTITATIVE FINANCE COMMUNITY

outrun
Topic Author
Posts: 2420
Joined: April 29th, 2016, 1:40 pm

### Stacking 2x4 Lego bricks

How many different ways can you connect two 2x4 Lego brick? The two bricks need to be connected, and rotating a configuration doesn't give you a new solution. Also, the bricks are identical, it doesn't matter which one of the two is at the bottom.

Posts: 21919
Joined: September 20th, 2002, 8:30 pm

### Re: Stacking 2x4 Lego bricks

Interesting!

It seems that the feasible sets of connections would involve: 1, 2, 3, 4, 6, 8 overlapping bumps.

There are some open questions of what constitutes a "different way":

1. Chirality: If one snaps the top block on to the bottom one to form an "L", there's the question of whether a right-handed L is "different" from a left-handed L.

2. Swivel DOF: If the blocks are connected by only 1 bump, the blocks can swivel through a range of angles which might be counted as 1 way or an infinite number of ways.

---

There may be a quick way to calculate the number from the range of relative (X,Y) coordinates of the top block's corner WRT the bottom block with two cases for parallel vs. perpendicular relative orientation and then minus some cases that are congruent under rotation.

outrun
Topic Author
Posts: 2420
Joined: April 29th, 2016, 1:40 pm

### Re: Stacking 2x4 Lego bricks

Yes, there are many interpretations with different answers. I'm sticking to the one I read about (this is just a warm up question ) but there is no "right" or "wrong" definition.

1) There is a difference left- and handedness.
2) DOF is *property* of a specific solution. Some solutions can swivel, others can't. So if't more about counting the number of ways you can snap them together?

Posts: 21919
Joined: September 20th, 2002, 8:30 pm

### Re: Stacking 2x4 Lego bricks

Re: DOF: The swivel case is a property of a solution generating/enumerating process. Imagine an infinite supply of 2x4 blocks and a horde of monkeys trying every possible configuration and then an analyzer that constructs equivalence classes from myriad assembled block-pairs.

The analyzer would assign rotationally congruent block-pairs to the same equivalence class and left-handed/right-handed assemblies to different classes. But what does it do if it has one block-pair with a 37° swivel angle and another block-pair with a 38° swivel angle? They are not congruent in their snapped-together configuration.

If we ignore the swivel issue, the one answer can be constructed using relative coordinates method (with culling for some symmetries). For parallel-oriented blocks, I get 3x3+2 = 10 configurations. For perpendicular-oriented blocks, I get 5x2+3 = 13 configurations. SO the total seems to be 23.

---EDIT---

For parallel-oriented blocks, I get 3x3+2 = 11 configurations. For perpendicular-oriented blocks, I get 5x2+3 = 13 configurations. SO the total seems to be 24
Last edited by Traden4Alpha on February 15th, 2017, 2:12 pm

outrun
Topic Author
Posts: 2420
Joined: April 29th, 2016, 1:40 pm

### Re: Stacking 2x4 Lego bricks

Very close! It's 24.
Below you see all combinations, the green ones have duplicated when you rotate them pi, the blue ones are unique.

Posts: 21919
Joined: September 20th, 2002, 8:30 pm

### Re: Stacking 2x4 Lego bricks

24! Where's my error... Ah, there it is! 3x3+2 !=10, it = 11 and 11+13 = 24.

With the offset-coordinate method, one coordinate ranges over the full left-to-right range whereas the other coordinate ranges over half the top-to-bottom range except for the offset that centers to top brick over the bottom brick in which left-to-right is only half the range, too. I'd initially made an error in that half-rangecase and written 3x3+1 = 10 in my post, caught the error, corrected to 3x3+2 but forgot to recalculate. (It's the curse of procedural programming!)

The coloration of the solution seems strange in that there's other block-pairs that don't have left-right types. All of the "T" configurations are "unique" in this way, too.

outrun
Topic Author
Posts: 2420
Joined: April 29th, 2016, 1:40 pm

### Re: Stacking 2x4 Lego bricks

I often have the same problem, when Mrs Outrun updated the set of house rules with new addendums that cover corner cases, I often forget to recalculate. Luckily she know where to find my F9 button.

Posts: 21919
Joined: September 20th, 2002, 8:30 pm

### Re: Stacking 2x4 Lego bricks

Indeed! For good or ill, spouses often know one's keyboard shortcuts!

House rules suffer from Godel's Syndrome -- they are either incomplete or inconsistent which leads to discord!

Methinks Mrs Traden4Alpha and Mrs Outrun would assert that the answer to this brainteaser is 1. The only acceptable solution is the block-aligned-with-block configuration because that minimizes space and gets the damned legos off the carpet!

Paul
Posts: 7163
Joined: July 20th, 2001, 3:28 pm

### Re: Stacking 2x4 Lego bricks

Yes, I got 11 but immediately assumed I had to be wrong!

katastrofa
Posts: 4319
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Stacking 2x4 Lego bricks

Assuming that the blocks have the same size n x m and a two-fold rotational symmetry, is the general formula:
$(2n-1) \cdot \lceil \frac{m+1}{2}\rceil + (m+n-1) \cdot \lceil \frac{m+1}{2}\rceil$
?
It can be readily generalised to d dimensions. Imagine Lego in 10D

BTW, in William Gibson's Pattern Recognition, he says about its two protagonists "Their boy-girl Lego doesn't click." (to explain why they are just friends, not in a romantic relationship). I've never actually understood what that meant. Do you know?