I have written a program to solve the lego counting problem - to count the number of different contiguous geometric structures that can be made from n identical 4 x 2 lego bricks, all connected orthogonally. the problem is solved for n up to 10 by Soren Eilers and others, see here.

My problem gives approximately the same answers as on that link, and match exactly for 1 and 2 bricks - giving 1 and 24 possibilities respectively.

But I get 1550 possibilities for 3 bricks whereas Eilers and others get 1560 bricks. For greater n they diverge further, but not massively. I have looked over my code and fixed a number of problems but cannot see any remaining errors. The only way I can see to fix the errors is to get a list of the 1560 n=3 configurations and compare it to the list of configurations my program generates.

For larger n it's not practical to generate a list of configs, because the number is so large. For instance n=6 gives 915m+ possibilities. But printing the approx 1.5k possibilities for n=3 is easy.

Does anybody know where I could find either a list of the configs, or a program that does the counting, which I could adapt to print out all configs found, then compare the list to my own?

I thought this question could go in the maths SE, on stack overflow, or on the "bricks" SE (for lego enthusiasts). I took a guess this might be the best one. IIRC SE discourages cross-posting.

thank you

  • $\begingroup$ I am unfamiliar with the Lego counting problem, so I won't be able to help directly. However, there may be a way to use mathSE to solve the problem. It is almost never a good idea to post software code on mathSE; reviewers will consider this beyond the scope of the website. However, if you are able to boil your code down to approximately 10-15 (maximum) lines of pseudocode, that merely demonstrate the logic of your code, a mathSE reviewer who happens to be knowledgeable in Lego blocks may look at it. I emphasize, no actual code, and keep the pseudocode short. $\endgroup$ Commented Apr 12, 2021 at 7:56
  • $\begingroup$ The alternative approach is to pretend that you were giving a mathematical analysis of the problem, and you explained each step that you took, in extremely clear mathematical language, so that you changed your query from analyzing code to analyzing mathematical analysis, that might also work. $\endgroup$ Commented Apr 12, 2021 at 8:00

1 Answer 1


I have now solved this problem, and have my own list of the 1560 configurations. I also have lists for configurations of 4 and of 5 blocks - both with cardinalities that match oeis.org. If you are working on this problem and would like to compare lists, contact me by message on this stackexchange platform.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .