Tilted square geometry: turning the grid inside a square tray
When the cells of a tray puzzle are turned inside a square tray: the angles at which the grid repeats, which cells stay whole and where they are, how many fit, and why a tiny allowance at the edge changes the count
In short
- "1 down, n over" is the angle θ = arctan(1/n): 45°, 26.57°, 18.43°, 14.04°, …, falling toward 0° with no end.
- At these angles the turned grid repeats along the tray's own edges every √(n²+1) cell widths, so the cells the edge cuts make a regular pattern.
- A cell is whole exactly when its center is at least w/2 from every edge, where w = cos θ + sin θ. The whole cells are the ones whose centers fall inside that smaller square.
- Averaged over every placement of the grid, an L × L tray holds exactly (L − w)² whole cells. The best placement holds a few more. The exact best is a small counting problem with no smooth formula.
- Many cells reach the edge together at these angles. A corner allowed to poke out by 1 to 5 hundredths of a cell can add a whole row of cells.
1. The question
A tray puzzle is a flat square tray filled with pieces made of unit squares. Normally the cells line up with the tray, and a 6 × 6 tray holds 36 of them. Turn the cells a little, keep them the same size, and some cells along the edge no longer fit: the wall of the tray cuts through them. A set of drawings that started this page found turns at which the cells still sit "nicely" in the tray. The first is 45°, a pattern of 1 down and 1 over. Then come 1 down and 2 over, 1 down and 3 over, and so on, each turned a little less than the last.
This page answers three questions about those turns. Can the angles be predicted? Why do they look regular? And how many whole cells does a tray of a given size hold, and where are they?
2. The angles
"1 down, n over" describes the grid lines: walk n cells along a row of the tray and the row has dropped by one cell. The lines have slope 1/n, so the grid is turned by
θ = arctan(1/n)
For large n this is close to 1/n radians, about 57.3°/n. The angles shrink toward the straight grid without reaching it, so the series has no end.
| Slope | Angle θ | Repeat s = √(n²+1) | Cells per repeat square | Box w | Inset w/2 |
|---|---|---|---|---|---|
| 1 down, 1 over | 45.000° | 1.414 | 2 | 1.414 | 0.707 |
| 1 down, 2 over | 26.565° | 2.236 | 5 | 1.342 | 0.671 |
| 1 down, 3 over | 18.435° | 3.162 | 10 | 1.265 | 0.632 |
| 1 down, 4 over | 14.036° | 4.123 | 17 | 1.213 | 0.606 |
| 1 down, 5 over | 11.310° | 5.099 | 26 | 1.177 | 0.588 |
| 1 down, 6 over | 9.462° | 6.083 | 37 | 1.151 | 0.575 |
| 1 down, 7 over | 8.130° | 7.071 | 50 | 1.131 | 0.566 |
| 1 down, 8 over | 7.125° | 8.062 | 65 | 1.116 | 0.558 |
| straight | 0° | 1 | 1 | 1 | 0.5 |
3. Why these angles look regular
Start at a corner of a cell, take n steps along its row and then one step across, down the column. The point reached is exactly level with the start, √(n²+1) away. (The two legs, n and 1, are at right angles, so this is Pythagoras.) Do the same turned a quarter turn and you go straight up by the same distance. So the turned grid has a repeat square whose sides run along the tray's own edges. Its side is s = √(n²+1) and its area is n²+1 cells.
This is the familiar "tilted square" of a pegboard. A square drawn with side 1 down and n over has area n²+1, the picture often used to prove Pythagoras's theorem. In the language of Gaussian integers, the repeat square is the grid multiplied by n − i.
So along each edge of the tray, the cells are cut in the same way every s cell widths. Within one repeat the edge crosses n + 1 cells. That repetition is the regular look of the drawings. At an angle whose slope is not a fraction, the edge never cuts two cells in the same way.
Other angles with the same property
Any slope that is a fraction q/p (in lowest terms) works the same way. The repeat is √(p²+q²) and holds p²+q² cells. The "1 down, n over" series is the case q = 1. When p²+q² is a perfect square, as for the Pythagorean slopes 3/4, 5/12 and 8/15, the repeat is a whole number of cells. Then, with one corner placed on a corner of the straight grid, other corners of the turned cells also land exactly on corners of the straight grid: one in every five at slope 3/4, √5 apart. That never happens in the 1/n series, because n²+1 falls strictly between n² and (n+1)² and so is never a square.
| Slope q/p | Angle | Repeat √(p²+q²) | Cells per repeat square | Repeat a whole number? | 8 × 8 best |
|---|---|---|---|---|---|
| 1/1 | 45.000° | 1.414 | 2 | no | 50 |
| 1/2 | 26.565° | 2.236 | 5 | no | 45 |
| 2/3 | 33.690° | 3.606 | 13 | no | 45 |
| 3/4 | 36.870° | 5.000 | 25 | yes, 5 | 48 |
| 1/3 | 18.435° | 3.162 | 10 | no | 49 |
| 2/5 | 21.801° | 5.385 | 29 | no | 49 |
| 5/12 | 22.620° | 13.000 | 169 | yes, 13 | 47 |
| 8/15 | 28.072° | 17.000 | 289 | yes, 17 | 45 |
4. Which cells are whole, and where they are
A unit cell turned by θ needs an upright box of side
w = cos θ + sin θ = (n+1) / √(n²+1)
It lies inside the tray exactly when that box does, which means exactly when its center is at least w/2 from every edge. So the whole cells of any layout are the cells whose centers fall inside an inner square of side a = L − w, set in by w/2 from each side. The inset is 0.707 at 45°, 0.671 at 1:2, 0.632 at 1:3, and it approaches 0.5 as the grid straightens. Everything outside the inner square is a ring of cut cells.

5. How many fit
The centers of the turned grid lie in level rows. For slope 1/n:
- the rows are 1/s apart;
- in each row the centers are s apart;
- each row is shifted sideways by n/s from the one below. After n²+1 rows the shifts have visited every multiple of 1/s once and the pattern starts again.
Counting the centers inside the inner square therefore gives the exact count. Row m's first center past the inner square's left edge is φm in from it, so
N = Σrows inside ( ⌊(a − φm) / s⌋ + 1 ), φm = (φ0 + m n/s) mod s
Every row holds either ⌊a/s⌋ or one more center, depending on its shift. The tray holds ⌊a s⌋ or ⌊a s⌋+1 rows, depending on where the grid sits. Averaged over every placement the count is exactly
Naverage = (L − w)²
because every cell has an equal chance of having its center in any spot, and the centers are one per unit of area. Turning costs about 2wL cells against the straight tray: roughly one row and one column on each side, a little more at 45°, where w is largest.
The best placement does better than the average, and how much better depends on the fractions a s and a/s. When both are just above a whole number, the tray can take its largest number of rows with the largest number of centers in each, and the simple bound "most rows times most per row" is reached. For 8 × 8 that happens at 45° and at 1:2. For the later members of the series the rows hold 2 or 3 centers in turn, the bound is loose, and only the sum above gives the answer.
| 8 × 8 | Average (L − w)² | Best | Worst | Most rows × most per row |
|---|---|---|---|---|
| 1:1 | 43.4 | 50 | 40 | 10 × 5 = 50 |
| 1:2 | 44.3 | 45 | 39 | 15 × 3 = 45 |
| 1:3 | 45.4 | 49 | 44 | 22 × 3 = 66 |
| 1:4 | 46.1 | 48 | 41 | 28 × 2 = 56 |
| 1:5 | 46.6 | 48 | 43 | 35 × 2 = 70 |
| 1:6 | 46.9 | 48 | 45 | 42 × 2 = 84 |
The best and worst counts below are exact. They were found by treating every cell as the rectangle of grid placements that keep it whole and sweeping over all those rectangles at once. The worst count is in brackets.
| Tray | straight | 1:1 | 1:2 | 1:3 | 1:4 | 1:5 | 1:6 |
|---|---|---|---|---|---|---|---|
| 4 × 4 | 16 | 8 (4) | 8 (5) | 9 (6) | 9 (6) | 9 (6) | 9 (6) |
| 5 × 5 | 25 | 18 (12) | 17 (12) | 15 (12) | 16 (13) | 16 (13) | 16 (13) |
| 6 × 6 | 36 | 25 (18) | 25 (20) | 24 (19) | 24 (21) | 25 (22) | 25 (22) |
| 7 × 7 | 49 | 32 (24) | 34 (28) | 37 (32) | 35 (30) | 35 (32) | 36 (33) |
| 8 × 8 | 64 | 50 (40) | 45 (39) | 49 (44) | 48 (41) | 48 (43) | 48 (45) |
| 9 × 9 | 81 | 61 (50) | 65 (57) | 64 (57) | 65 (60) | 63 (56) | 63 (58) |
| 10 × 10 | 100 | 85 (72) | 80 (72) | 79 (72) | 81 (76) | 80 (73) | 80 (73) |
| 11 × 11 | 121 | 98 (84) | 97 (88) | 97 (90) | 100 (93) | 101 (96) | 99 (92) |
| 12 × 12 | 144 | 113 (98) | 116 (105) | 116 (108) | 121 (112) | 121 (116) | 120 (113) |
No angle beats the straight tray. A turned tray keeps roughly (L − 1)² cells, sometimes a few more and sometimes fewer. In small trays the loss is large: a 4 × 4 tray at 45° keeps only 8 of its 16 cells. Among the turned trays the counts do not fall in a steady order. The best angle for a given tray depends on how L − w lines up with the row spacing, as section 6 shows.
6. A tiny allowance at the edge
At these angles many cells reach the edge at the same moment, because of the repeat in section 3. In an 8 × 8 tray at 1:2:
- the inner square is a = 8 − 3/√5 = 6.658 wide;
- centers in a row are √5 = 2.236 apart, so four of them need 3 × 2.236 = 6.708;
- the shortfall is 0.050 cell widths, just under 0.025 on each side.
With every corner strictly inside, each row keeps 3 cells and the tray keeps 45. Let a corner poke past the wall by 0.025 of a cell and every row can take a fourth. The best count jumps to 52, more than the 50 at 45°.
An overhang of d at a corner cuts off only a tiny triangle, of area d² / sin 2θ. At 45° and d = 0.05 that is a quarter of one percent of the cell. It is less than a drawing's line width, and less than the slack a real tray needs so the pieces can go in. So whether a design counts "strict" or "allowing a little" changes its count by whole rows. The allowance should be chosen on purpose and stated.
| 6 × 6 | 0 | 0.01 | 0.02 | 0.05 | 0.1 |
|---|---|---|---|---|---|
| 1:1 | 25 | 25 | 25 | 25 | 25 |
| 1:2 | 25 | 25 | 25 | 25 | 25 |
| 1:3 | 24 | 26 | 26 | 26 | 26 |
| 1:4 | 24 | 24 | 24 | 26 | 26 |
| 8 × 8 | 0 | 0.01 | 0.02 | 0.05 | 0.1 |
|---|---|---|---|---|---|
| 1:1 | 50 | 50 | 50 | 50 | 50 |
| 1:2 | 45 | 45 | 45 | 52 | 52 |
| 1:3 | 49 | 49 | 49 | 49 | 49 |
| 1:4 | 48 | 50 | 50 | 50 | 50 |
| 1:5 | 48 | 48 | 48 | 50 | 50 |
| 1:6 | 48 | 48 | 48 | 50 | 50 |
The drawings that started this page
The hand drawings behind this page were measured: their 8 × 8 trays are about 8.06 cells wide, and a few cells there touch or cross the line. Six of their ten counts are more than a strict fit allows, and all ten are within what a 0.05 overhang allows. The angles in the drawings match arctan(1/n) to within about half a degree.
| Tray | Slope | Drawn | Strict best | Best with 0.05 overhang |
|---|---|---|---|---|
| 6 × 6 | 1:1 | 25 | 25 | 25 |
| 6 × 6 | 1:2 | 25 | 25 | 25 |
| 6 × 6 | 1:3 | 26 | 24 | 26 |
| 6 × 6 | 1:4 | 25 | 24 | 26 |
| 8 × 8 | 1:1 | 50 | 50 | 50 |
| 8 × 8 | 1:2 | 50 | 45 | 52 |
| 8 × 8 | 1:3 | 49 | 49 | 49 |
| 8 × 8 | 1:4 | 49 | 48 | 50 |
| 8 × 8 | 1:5 | 49 | 48 | 50 |
| 8 × 8 | 1:6 | 50 | 48 | 50 |
7. Recipe
- Pick the slope: 1 down and n over, θ = arctan(1/n). Or any fraction q/p.
- Work out w = cos θ + sin θ, and decide the allowance t (0 for strict).
- The whole cells are those with their center in the square set in by w/2 − t from every edge.
- Expect about (L − w + 2t)² of them. Slide the grid to find the best placement. Shifts within one cell are enough, because the grid repeats under its own steps.
Sources
- The counts, figures and tables were computed for this page by a short program in exact geometry (no sampling). It was checked against thousands of random grid placements, which also confirm the average (L − w)².
- Tilted squares on a pegboard and their area: the classic dissection proof of Pythagoras's theorem, and the "Tilted Squares" problem on NRICH (University of Cambridge).
- Gaussian integers, whose multiplication turns and scales a square grid: C. F. Gauss, Theoria residuorum biquadraticorum (1832).
- The angles at which a turned square grid shares points with the straight one, the Pythagorean slopes of section 3, are the coincidence site lattices of crystallography: M. L. Kronberg and F. H. Wilson, "Secondary recrystallization in copper", Trans. AIME 185 (1949).
