Custom protective packaging · Oak Ridge, Tennessee · Since 1991 (865) 481-3801

Research

Progress on Ed Pegg’s 38-Square Packing Problem

Vol Case strives to move packaging design and manufacturing forward by investigating the mathematics behind everyday production decisions. This article examines the problem “Packing squares 1 to 38 in a size 138 square”: can 38 square parts, with side lengths from 1 through 38, all fit on a sheet measuring 138 by 138?

We found one layout that fits 34 of the parts, including every size from 8 through 38, and another that fits 37, leaving out only the 11 × 11 square. We provide exact coordinates and checks for both layouts. Neither settles whether all 38 can fit.

For packaging and manufacturing, the useful lesson is that leftover area alone does not tell us whether another part will fit. The shape and location of the gaps matter too. These layouts show geometric fit under ideal rules; real cutting plans must also allow for tool width, spacing and cut order.

Independent results awaiting third-party verification.The Python checks were repeated internally for this draft. The supplied Lean certificates were reviewed and Lean was not rerun.
Question
Can one square of every side length from 1 through 38 fit in a 138 × 138 square?
Result
A 34-piece layout contains sizes 1–3 and 8–38. A separate 37-piece layout contains every size except 11.
Model
Edges parallel to the sheet; boundary contact allowed; no overlap; zero cut width.
Evidence
Exact coordinates, Python checks, supplied Lean certificates and four diagrams. The Python layout and gap checks were rerun for this draft.
Limits
No full 38-square solution, impossibility proof, physical cutting test or third-party verification.
On this page

1. A sheet with only 25 square units to spare

A packaging designer can compare the area of a list of parts with the area of a stock sheet before drawing a single cut. For this list, that first calculation comes tantalizingly close to answering the whole question.

1² + 2² + ··· + 38² = (38 × 39 × 77) / 6 = 19,019

A 137 × 137 sheet has only 18,769 square units. A 138 × 138 sheet has 19,044, leaving an allowance of 25 square units for every gap in the layout combined. That is the area of a single 5 × 5 square, or about 0.13% of the sheet. A one-unit strip running the length of the sheet would consume more than five times that allowance.

Area therefore rules out every smaller integer-sided sheet. To establish that 138 works, someone still has to place the parts.

2. Ed Pegg’s challenge

Erich Friedman’s catalog illustrates a packing of all 38 squares in a square of side 139. In December 2016, Ed Pegg posted a drawing inside the tighter 138 × 138 boundary. His drawing included every size from 10 through 38. Could a layout include the 9 as well? Could it include the 8? Those questions gave us two concrete targets on the way to the full set. Friedman’s catalog · Pegg’s original challenge

We used one square of each specified size. Every edge runs parallel to an edge of the sheet. Squares may touch along an edge or at a corner. Their interiors must be disjoint, and each square must lie entirely inside the sheet. Cut width is zero. We could move every part, including those in Pegg’s drawing.

4. Two ways to get closer to 38

In Figure 1, find the 8 and 9 just to the left of the large 38. The layout holds both of them and every larger size. The side-1, side-2, and side-3 squares occupy small gaps elsewhere. Figure 2 uses a different arrangement and fits every requested size except 11.

Labeled 138 by 138 layout with sides 1–3 and 8–38. The 8 and 9 lie just left of the 38. Insets locate the three smallest pieces.Open full-size figure
Figure 1. The 34-piece layout answers both of Pegg’s intermediate questions. White areas are unused sheet. Numbers give side lengths.

Full-size diagram Coordinates (CSV)

Labeled 37-piece layout containing sides 1–10 and 12–38. Squares 20, 24, 29, 31, and 34 span the bottom edge.Open full-size figure
Figure 2. The 37-piece layout omits side 11. Along the bottom edge, sides 20, 24, 29, 31, and 34 span exactly 138 units.

Full-size diagram Coordinates (CSV)

LayoutPiecesOccupied areaUnused area
Pegg · sizes 10–382918,734310
Vol Case · sizes 1–3 and 8–383418,893151
Vol Case · all except 113718,898146

The two Vol Case layouts differ by three pieces but cover nearly the same area. Figure 1 leaves out the 4, 5, 6, and 7. Their areas sum to 126. Figure 2 leaves out one 11 × 11 square, with area 121. Filling three more entries on the parts list gains just five square units of coverage.

5. How to verify a layout

Each row in our coordinate files gives a side length s and a lower-left corner (x, y). For containment, both coordinates must be at least zero, and both x + s and y + s must be at most 138. For each pair of squares, one must end at or before the other begins along at least one axis.

Consider the two largest squares in Figure 2. The 38 starts at (65, 31), so its top is at 31 + 38 = 69. The 37 starts at (65, 69). They share 37 units of horizontal edge. The equality at 69 is exactly the contact the rules permit.

We checked the layouts two ways. A Python program marks every unit cell covered by each square and rejects a cell claimed twice. Because every listed edge lies on an integer grid line, overlapping interiors would share at least one full cell. A separate Lean proof checks the required side list, containment, the separation inequalities for every pair, and the occupied area. The supplied verification record reports Lean checks of all 561 pairs in Figure 1 and all 666 in Figure 2. Readers can rerun either check on the supplied coordinates. Figure 1 certificate · Figure 2 certificate

For this website draft, we reran the Python checks for both Vol Case layouts and the reconstructed Pegg baseline, along with the separate gap scan. They passed. The supplied Lean certificates and recorded verification results were reviewed, but Lean was not rerun during this draft review. The two checking methods are separate implementations; they do not constitute third-party verification.

6. What the offcuts tell a packaging designer

Suppose the 37 placements in Figure 2 have been fixed and someone brings the missing 11 × 11 part to the cutting table. It needs 121 square units. The drawing still has 146 free. Where could that part go?

We mapped the free unit cells, joining neighbors wherever they shared an edge. The unused material falls into 19 separate regions. The largest contains only 22 square units. Its top row is 12 cells wide, but only five cells continue into each of the next two rows. Across the entire layout, the largest empty square with its edges parallel to the sheet is just 3 × 3. An axis-parallel 11 × 11 square cannot be inserted while the 37 squares stay in place. A fresh arrangement of the parts is a different question.

The largest connected gap, an irregular 22-cell shape containing a 3 by 3 square, next to the missing 11 by 11 square at the same scale.Open full-size figure
Figure 3. The highlighted 3 × 3 fits at (38, 60) in Figure 2. Each small cell in both drawings represents one square unit. The gap measurements come from a separate scan of the certified coordinates. Gap-checking script

This is the part of the puzzle that carries over to packaging work. A material-utilization percentage tells us how much stock remains. A drawing of the remainder tells us which blanks we can still cut from it. Two jobs with almost identical utilization can leave very different options for the next part.

A production drawing would also need the actual cutting rules. For example, the shared edge between the 37 and the 38 is valid here. A design that needs a web of material between two insert pockets must budget space for that web. A common-line cut through sheet stock must account for the material the tool removes when setting the finished dimensions. A machine limited to straight cuts across the remaining stock also needs a workable cut sequence. Our certificates establish geometric fit under the stated assumptions. Tooling and cut order would need their own checks.

In custom foam inserts, the material between pockets, support around the equipment and access for removal all affect the layout. Our in-house design process uses dimensions and drawings to review those practical requirements before production.

7. What remains open

We verified that every size from 8 through 38 fits simultaneously and that a separate layout fits 37 of the 38 requested parts. The open question is whether one layout can hold all 38. A solver run with all positions free returned UNKNOWN after 180 seconds. The run produced neither a complete layout nor an impossibility certificate.

A January 2026 research paper lists the 38-square optimum among the unresolved cases. The original study’s literature check, dated November 28, 2026, reported no later resolution; the layouts presented here do not settle that question. Together, the area bound and the published 139-square layout leave two possible optimal integer side lengths, 138 and 139. Dósa, Lángi, and Tuza, introduction · Friedman’s catalog

To settle the question affirmatively, it would suffice to supply all 38 coordinates and check them. A negative result would require a proof covering every allowed arrangement, with a verifiable certificate for any exhaustive computation. Our Lean statement of that full question was merged into Left to Solve’s repository on November 29, 2026. This records the question, not a solution: its main proof remains deliberately open with sorry. The merge does not verify the results in this article. The completed Lean proofs in this article concern the specific layouts shown above. Vol Case’s merged problem statement

Appendix A. Exact coordinates and labeled diagrams

The origin is the lower-left corner of the sheet, with x increasing to the right and y increasing upward. The CSV files use the same units as the figures. In the table, a dash means that the layout omits that side length. 34-piece CSV · 37-piece CSV · Pegg baseline CSV

Coordinates for all three layouts
Side34 pieces37 piecesPegg baseline
1(53, 107)(67, 106)—
2(64, 69)(65, 29)—
3(17, 44)(28, 60)—
4—(40, 25)—
5—(38, 55)—
6—(59, 69)—
7—(31, 55)—
8(55, 48)(51, 68)—
9(55, 57)(43, 54)—
10(54, 66)(30, 45)(30, 43)
11(17, 47)—(54, 63)
12(54, 76)(18, 45)(18, 43)
13(42, 48)(52, 55)(60, 111)
14(28, 47)(51, 76)(59, 124)
15(56, 107)(57, 107)(50, 48)
16(56, 122)(57, 122)(57, 75)
17(0, 41)(48, 90)(55, 91)
18(46, 30)(0, 39)(0, 39)
19(47, 88)(0, 20)(0, 20)
20(0, 21)(0, 0)(0, 0)
21(0, 0)(19, 24)(19, 22)
22(25, 87)(26, 86)(20, 0)
23(21, 0)(28, 63)(42, 0)
24(20, 23)(20, 0)(0, 57)
25(0, 86)(40, 29)(40, 23)
26(28, 61)(0, 85)(24, 55)
27(0, 111)(0, 111)(28, 81)
28(0, 58)(0, 57)(0, 81)
29(27, 109)(44, 0)(0, 109)
30(44, 0)(27, 108)(29, 108)
31(74, 0)(73, 0)(73, 75)
32(72, 106)(73, 106)(73, 106)
33(105, 0)(105, 105)(105, 105)
34(104, 104)(104, 0)(104, 71)
35(103, 69)(103, 34)(103, 36)
36(102, 33)(102, 69)(102, 0)
37(66, 69)(65, 69)(65, 0)
38(64, 31)(65, 31)(65, 37)
Redrawn baseline from Ed Pegg’s diagram with each side from 10 through 38 labeled.Open full-size figure
Figure A1. Our labeled reconstruction of Ed Pegg’s 2016 diagram, adapted by Vol Case and shared under CC BY-SA 3.0. The original GIF is included with attribution in the verification packet. Pegg’s original image · CC BY-SA 3.0

Appendix B. Reproduce the checks

Download the complete research article (PDF)

Download the verification packet (ZIP)

Extract the packet and run the following commands from its directory with Python 3.10 or later and Lean 4.33.1. The Python layout checker uses the standard library. The Lean certificate files import only Std. Each packing check takes an explicit list of required sizes, so omitting a requested square causes the check to fail.

python check.py best.json --sides 1-3,8-38
python check.py most-pieces.json --sides 1-10,12-38
python check.py pegg-original.json --sides 10-38
lean best.lean
lean most-pieces.lean
lean pegg-original.lean

For Figure 3, save the script beside most-pieces.csv and run python check-gaps.py most-pieces.csv. It counts the free cells and connected regions, then measures the largest axis-parallel empty square. An axis-parallel square wider than three units would meet the interiors of at least four consecutive unit rows and four consecutive unit columns. Since each occupied cell belongs entirely to one piece, that would require a free 4 × 4 block. The scan finds none. Download the gap-checking script.

Why an integer search covers real coordinates. Start with any axis-parallel packing with real lower-left coordinates. For every pair separated horizontally, an inequality such as xᵢ + sᵢ ≤ xⱼ remains true after both coordinates are rounded down, because the side length sᵢ is an integer. The same holds for vertical separation. Rounding every coordinate down therefore preserves containment and every pair’s separation. An exhaustive integer search could in principle settle the full problem. Our time-limited run did not exhaust it.

References

  1. Ed Pegg. “Packing squares 1 to 38 in a size 138 square.” Mathematics Stack Exchange, December 8, 2016. Read the challenge.
  2. Erich Friedman. “Problem of the Month (October 1999),” question 3. Updated October 10, 2010. Packing catalog · Side-139 diagram.
  3. György Dósa, Zsolt Lángi, and Zsolt Tuza. “Covering a square by congruent squares.” arXiv:2601.16535, January 23, 2026. The introduction discusses the separate problem of packing consecutive squares. Read the introduction.
  4. Left to Solve. “Packing squares 1 to 38 in a size 138 square.” Problem entry · Vol Case’s Lean statement, PR #50893.

Tell us about your project

What do you
need to protect?

Tell us what you need to pack, how it will travel and when you need it. We can help you choose a case, foam insert or wood crate.

  • Free design and quoting
  • Direct access to our team
  • No obligation to purchase
Prefer to talk?(865) 481-3801

Start your project

Provide a general project description. Do not include CUI or export-controlled information.

PDF, images, CAD files, or ZIP. Up to 5 files, 20 MB each. ZIPs may contain up to 20 files, totaling 20 MB when opened. No password-protected or nested ZIPs.

Use non-sensitive sample files only. Do not attach CUI or export-controlled technical data. Contact our team to arrange an approved transfer method.