0

When I was a child, I had a square board tetris puzzle, and the instruction said there are >15 thousand solutions. I've always wondered how they counted the solutions, and I'd like to replicate that.

So I would like to search for divisions of NxN boards into 4-cell and 5-cell fragments. Rotation is allowed, flipping is not.

  • Problem A: Determine if a set of blocks can be assembled into a NxN grid.
  • Problem B: Find divisions without rectangular subdivisions, except for single fragments (4 cells, that is, 2x2 and 1x4).

I'm thinking of constraint programming. But if I encode the presence of each wall as boolean, how can I efficiently count the blocks? Is it better to work in terms of fragments and check for rectangles later?

What other technique could help?

note: this is just for fun, and not homework or anything.

h2kyeong
  • 447
  • 3
  • 13

1 Answers1

0

I once challenged solving pentomino variant in Prolog.

Program:

http://www2.koyahatataku.com/programming/pent.txt

Result:

http://www2.koyahatataku.com/programming/pent_out.txt

I tried with naive brute force Depth-first search algorithm.

Taku Koyahata
  • 558
  • 2
  • 13