My wife is making a quilt. We are trying to figure out a way to arrange the squares that meets her aesthetic "requirements." I see a similar question here, but we've got two aspect variables and different rules. I'm wondering if somebody can work this out.
The squares:
- There are 126 squares.
- The squares come in 7 patterns (I will assign them numbers 1-7).
- Each pattern comes in 3 colors (but there are 5 colors total: white(w), red(r), light blue(b) teal(t), navy(n))
- For each pattern, there are 6 of each of its colors.
The break down is like this:
- Pattern 1: 1w, 1b, 1n
- Pattern 2: 2b, 2t, 2n
- Pattern 3: 3w, 3r, 3n
- Pattern 4: 4w, 4t, 4n
- Pattern 5: 5w, 5b, 5r
- Pattern 6: 6w, 6t, 6n
- Pattern 7: 7w, 7t, 7n
The rules:
- Making a quilt 9 squares by 14 squares
- No two squares of the same color can be adjacent (vertically or horizontally; diagonal is fine)
- No two squares of the same pattern (but different colors) can have fewer than 2 other patterns in between them, vertically or horizontally (so 1|2||,1 is fine; 1|2|1 or 1|1 are not).
- Squares of the same pattern AND color also must follow this rule, with the additional rule that they must have at least 1 square of a different pattern AND a different color between them diagonally.
Is this a solvable problem?
BONUS: She'd also be interested in a 11x11 arrangement and 10x12 arrangement with the same rules (though these would not use every square, of course - would appreciate the leftovers [5 and 6, respectively] each be a different pattern).
Your problem is typical constraint satisfaction problem which in your case can be formulated as a generalized cover set problem. Some condition should be satisfied exactly once (there is one and only one patch per place); some should be satisfied at most once (one or zero patches adjacent to the edge can be white); some conditions should be satisfied no more than 2 times (among patches on diagonal 1w 5w 1w, we can have any two of them, but not 3).
Unfortunately, I couldn't easily find the solver for a generalized cover set problem and I was too lazy to write it myself. So instead, I strengthened the last condition which is now:
In that case, we don't have “no more than 2 times condition” and we can reformulate the problem in terms of graphs.
Consider all the possible placements of all the possible patches as nodes of a graph (21 patches × 9 rows × 14 columns = 2646 nodes). For example, node
1a1wmeans row1, columna, pattern1w. Now, if two nodes share the placement or the rule, we connect them by an edge. For example,5b1w—5b6t(two patches cannot be at the same place);5a4t-6a6t(two adjacent patches cannot have the same color) etc.By doing that, We will get a big graph (2646 nodes, 80081 edges):
In that graph we want to find an independent set of vertices of size 9×14. Luckily there is a function for that in Wolfram Mathematica.
Below I will show a couple of quilts I found, so your wife can choose the best-looking one: