# Need Randomness within constraints

The wife wants to make a quilt from squares of fabric cut from my old shirt. Awesome.

## Situation:

2” x 4.5” blocks of fabric containing various patterns.

Quilt should be 17 across (4.5” the long way) and 36 down.

612 total blocks will be used.

Here’s the conundrum: She has 16 different designs of fabric. How can she make sure that using these 16 unique designs, the quilt looks completely random. No repeating.

Another kink in the pipe… she doesn’t have the same number of blocks for each pattern… here is the breakdown:

1. 43
2. 48
3. 56
4. 56
5. 60
6. 60
7. 70
8. 70
9. 71
10. 76
11. 51
12. 53
13. 43
14. 43
15. 76
16. 35

Remember, 1 … 16 contain different patterns and different counts of blocks. How can she most efficiently and nearly-randomly arrange these blocks on the quilt? I’ll need this is layman’s terms, please. I’m just a lowly front-end UI web developer. Don’t do much maths. :-P

-

## 2 Answers

I really think it is up to you to write a program that produces images of possible assignments, with perhaps a rectangle of a solid color for each of the 16 types, and the output a rectangle on the screen with a possible assignment, as in the answer by msh210. There is not much more mathematics than that...the total pattern is 36 rows by 17 columns. Begin with a matrix $M$ that is 36 by 17, initially all $M_{ij} =0.$

For each of the 43 occurrences of block 1, pick a random row number $i$ from 1 to 36 and a random column number $j$ from 1 to 17. If matrix element $M_{ij}$ is still $0,$ assign $M_{ij} = 1.$ However, if that $M_{ij}$ was already nonzero, try again. Eventually you are done with block number 1, then do the same for block type 2.

Actually, after block 15 is assigned, every blank place is assigned block 16.

Wait, I see that you have over 900 total blocks. So I suggest using 39 each of the 7 favorite blocks (other than number 16), then 38 each of the 8 other blocks not numbered 16, then the full 35 blocks available numbered 16. That makes $39 \cdot 7 + 38 \cdot 8 + 35 = 273 + 304 + 35 = 612,$ and is about as even-handed as you are going to get.

Finally, in the non-random direction, your wife might enjoy Symmetry: A Design System for Quiltmakers by Ruth B. McDowell, published by C & T publishing of Lafayette, California, copyright 1994. Lovely color pictures, single blocks and full quilts.

-

Whether something looks random is, like all things regarding how things look, a matter of opinion, so there's no one right answer. Thus, the best I can give you for an objective answer is something that actually is random:

Assign a number to each block of fabric and to each position in the grid the blocks of fabric are to go in, then match them up using a computer program that matches them pseudorandomly.

-