The n-omino fence problem asks how many cells can be surrounded by placing every n-omino exactly once in the grid. We present a new dynamic programming approach for this problem, allowing us to prove optimality for the pentomino and hexomino fence and to classify all possible pentomino orders by optimal area. For the first time we also provide strong heuristic solutions and upper bounds for all fences up to n = 15, after which we even approximate the 500-omino fence with computational experiments. Finally, we generalize the problem to three dimensions, where we prove optimality for pentacubes and derive heuristic solutions for hexacubes.
Last update: October 22, 2026.