We are playing a simplified version of IQpuzzler, with a smaller board of 4-by-5 spaces and just 5 pieces, as shown in the picture:
You are provided a cell array with one cell per piece. Each cell contains an N-by-M matrix with zeros and one unique value (the piece number) representing the positions of the 3 to 5 elements that define each piece. In our case, the pieces are provided as
pieces={ [1 1;
1 0],...
[0 2;
0 2;
2 2],...
[3 3 3;
0 3 0],...
[4 4 0;
0 4 4],...
[5 5 5;
5 5 0] };
Please note that the orientation of each piece in your solutions might be different from the one provided as input. For example, the red piece (number 4) was flipped from left to right before being placed on the board. The pieces can be rotated in steps of 90 degrees, flipped vertically or horizontally.
Your solution set needs to be provided as a 3-D array with 4 rows, 5 columns and N layers, where N is the number of possible arrangements of the given pieces. The order of your solution set along the 3rd dimension does not matter, as long as it provides all valid solutions without repetitions and without symmetric solutions (180° rotations or flippings of other solutions).
For example, the solution above would be represented as
[5 5 5 2 2;
5 5 4 4 2;
1 4 4 3 2;
1 1 3 3 3]
Please provide your entire search algorithm, not just hard coded solutions.
Hint: Maybe you can reuse some functions from the preparation phase. You can find a C++ implementation for the entire puzzle on https://github.com/deverw/IQpuzzler
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers3
Suggested Problems
-
17384 Solvers
-
Construct a string from letters and counts
146 Solvers
-
183 Solvers
-
Return unique values without sorting
999 Solvers
-
17576 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!