Lots of progress in the past week, and quite a busy week, but no cigar as yet in terms of a full solution to the 12 piece pentominoes problem. The various modifications are summarised as follows.
- Using DATA statements to define each piece.
The use of data statements was a quicker way of defining each piece in terms of a 5×5 array. In the future then the piece can more easily be rotated and its edges can be automatically detected for fitting inside the chosen box. This modification was tested on the 5×5 test data.
- Rotating Each Piece using Matrix multiplication
Having defined each piece as a matrix, we can then use rotation of a matrix by 90 degrees to generate more possible pieces for each defined Pentomino. The logic used to rotate a matrix by 90 degrees was to take the matrix transpose (for which a function is already defined) and then swap matrix columns. I admit I found this solution on the internet, but I still havn’t used the internet to find possible solutions for the main Pentomino problem I’m trying to solve.
Finally I added some routines to remove spare rows and columns from the rotated matrix such that the Pentomino is always packed into the bottom left corner.
- Testing Solution on 5 pieces in 5×5 square
I had to change some small parts of the original logic, but the extension to rotating pieces worked well in terms of finding several additional solutions of this particular 5×5 problem.
Two such solutions are shown and generally less than 200 iterations were required.
- Extension to 12 pieces
The solution so far is restricted in that it doesn’t allow for reflections of the pieces, just rotations. The order of the pieces is fixed to either running from 1 to 12 or 12 to 1. However it still should be possible to find a solution. Since the end of the month was approaching, I quickly coded up the remaining 4 pieces and let the code iterate away at the entire problem I was trying to solve.
No solution found !! Disappointing !!
I think I left the code to run for 50,000 iterations before I gave up and tried it again. Still no joy. Then I found some small errors in defining the actual pieces, but each time I tried the code I obtained no solution. Unless there is a bug in the code, I’m pretty sure this brute force search should find one of the solutions …eventually…. but maybe I’m just not leaving it to run for long enough. Time for some thinking….