I don't assume the bees do calculus but your use of the word "programmed" is appropriate. I don't believe it's an evolved instinct.
The bees build the original hexagon shape. And while they can be coaxed to build smaller hexagons through the use of a starter row, I doubt they can be coaxed to build anything other than hexagons.
Just to clarify, the calculus I was referring to comes into play when setting the displacement of the pointed tetrahedral apex (on the hidden part of the comb) so that the surface area is minimized - not on the choice of a hexagon (although that minimizes as well).
Then they need to read "Tiling the Plane" for a bit of diversity in their busy, humdrum lives.