My friend has this game called Pentominos. It's a tiling game. You have 11 pieces, all shaped like an L with a peg on the back:

*
**
**

You have an 8x8 chessboard. The object is to place all 11 pieces in any flat orientation onto the chessboard. After losing too many hours to the thing, I decided to lose some more, but in a productive way, namely de-rusting some of my perl skills (indeed, I haven't been seen here since Azatoth was my level.)

It took about 3 hours to get the base structure, then 6 hours of optimizations (so it'd run in my lifetime) and (lots of) debugging. I'd love to hear anyone's suggestions for optimizations or improvements.

On an Athlon 900 MHz with 1GB ram, it took about 215 seconds, completing around 2.25 million 'boards'. (you'll notice some of them are optimized away, but still counted, and many aren't counted at all... really, the counting is very subjective).

Square polyominos were obfuscated a long time ago
using regexps. The program won as most creative of the OPC3
: the
sources. If you remove the printing code that shows the progression of the search, it is relatively fast too. The trick used is to fold the board to make the problem unidimensional. I used it as a obfuscation trick to use regexp but it can be used as well as a performance boost.

BTW: there are 12 pentominoes, not eleven. Finding all of them is already quite a challenge.

You should check a Knuth paper
that talks about dancing links to solve polyominoes problems and the N-Queens problem. The best book about about polyominos was written by Samuel Golomb and aptly
titled
polyominoes.

The board is already kinda unidirectional, albeit in a hacked way. I figure the problem is already either optimally solved or runnable a couple orders of magnatude faster than my code, but researching it would take longer than writing my code, and it just wasn't that important of a project (although I am a math major, and would easily be distracted into researching that as it's own project :).
Anyway, here are the three heuristics I used:

# If piece is efficiently placed, try the next pentomino
# (tend to cluster them towards origin)
if (!exceeds_hole_count($index)) { solve ($index+1); }

There are 9 holes in pentominos (I assume that's the mythical 12'th pentomino that you refer to). Clearly we better leave holes sparingly. The exact forumula relates the indexth of the pentomino to the indexth diagonal, namely that there are less than or equal to index holes up to and including the indexth diag.

($x, $y) = next_position_accross ( $x, $y );
# if the pentomino has run off the board, backup
# and try again. (n_p_a returns (-1,-1) in this case
if ($x < 0) { return }
$SOLVE_COUNT++;
# Start the piece well out onto the board
if (($x+$y) < $index) { next };

And we keep them close to home in two ways. First, they need to stay within a radius of twice their index, and second they need never exceed the indexth row. This somewhat prevents reflection across the x-y plane.
And now that I've thought about it some more, I have a glimmering of a far more elegant way to capture all that. But that's allright, I have other projects to work on.
Back to your post, Regexps would have been super elegant. I'm off to check it out presently. Thanks!

You might want to check out Polya's Theorem. It may or may not be worth your time. The gist of Polya's theorem is the enumeration of things under rotations and flips. For instance, let's take a 3x3 board and place an L-shaped triomino on it. The following are considered equivilant:

because any one can be obtained from any other by a rotation of the board. This should drastically cut down on the number of boards that you have deal with. Then again, it may not. I haven't used this in years, and it may only be good for counting such things, though my memory tells me otherwise.

I wrote one in Pascal in 1986. It took four CPU-*months* on an 80286 to run through the whole solution set. I had to make the program resumable and ran it on any unused IBM AT I could find.

The normal form is to put all TWELVE pieces into a known 60-unit shape. For a 6x10 rectangle area, there are 2339 unique solutions (with symmetric equivalents filtered out). For a 3x20 rectangle, there are TWO solutions.

There are two optimizations of note.

(1) Since there are twelve pieces, and you only want solutions that are unique (with symmetries filtered out), then lock one of the pieces into a single quadrant of the table. If the X-shaped piece stays in the upper left quadrant, then you won't get any equivalent solutions with the whole board flipped horizontally or vertically.

(2) After you place a piece, look for any neighboring empty spaces. For each neighboring empty space, count the contiguously connected empty spaces. If any such space is not divisible by five, then you know you'll fail to put all the remaining pieces. Abort the current piece/position and move on.

Went to join the gridlock to see it
Held an eclipse party
Watched a live feed
I cn"t see tge kwubosd to amswr thus
I tried to see it, but 8000 miles of rock got in the way
What eclipse?
Wanted to see it, but they wouldn't reschedule it
Read the book instead