Monday, February 14, 2022

Finding shapes to make (Hexahexes Edition)

This isn't touched on nearly enough on other sites: the process of finding which shapes are possible to construct with a given set of pieces. Sure, with squares or parallelograms it's easy enough - just factorise all the numbers from the total area of the pieces upwards and hope there's one that breaks nicely into two large enough side lengths to work with. And hope that the number of holes lets you do something nice with them too. Nothing worse than realising your potential even x even rectangle needs an odd number of holes, guaranteeing at least one of them will be hideously off-centre.

But when it comes to more adventurous shapes, you need to get a little bit creative. Generally, I try to find a formula that gives the total area when fed in the values for however many edge lengths. In the case of hexahexes, for example, a hexagon with two lines of symmetry should be workable, and the formula A = ab(a-1) + (a-1)² gives the total area for a hexagon with a unit hexagons in its shorter diagonal and b unit hexagons in the longer diagonal.

Determining these formulae is an art unto itself. The usual approach is to break your shape up into squares or rectangles (in the case of polyominoes), or parallelograms and triangles (in the case of polyhexes), then get expressions for the areas of those separate bits individually. All of this goes to hell when you try it on polyiamonds though.

Once I've got the formula it's then a case of making a big, ugly and confusing-to-the-untrained-eye Excel spreadsheet (actually, it's an OpenOffice spreadsheet because I'm cheap) where every possible combination of values for a and b are evaluated. Then it's just a case of going through and finding the values that are equal to or slightly greater than the total area you want. For hexahexes it's 492 (6x82), and all the likely candidates will fall on roughly a nice curve like in the picture below.

Click the image for bigger (if you're into dull spreadsheets)

Then after this step it's easy. Take a punt at sketching out the shape with a configuration of holes that looks half way presentable, then dig out the hexahexes and clear a flat surface and get some solving done. Admittedly, feeding the shape and the pieces into some solver software will yield much the same results in a fraction of the time, but where's the fun in that?


Here's the case where a = 13 and b = 14. And below we've got a = 11 and b = 19 with seven holes.