The bees do no calculus. The combs grow like crystals-once an initial hexagon is created the bees simply replicate that shape and size. The original hexagon is an optimum shape programmed through instinctive behavior.
http://www.ars.usda.gov/ar/archive/may97/beecells0597.htm
-snip-
"The scientists did this by installing in the hive sheets of starter cells that are smaller than those typically used by beekeepers. Commercially managed honey bees use these starter cells as a blueprint for building their honeycomb. With wax they manufacture themselves, they form thousands of cells to create the many floors of the honeycomb. The smaller the starter cells, the smaller the cells the bees themselves construct."
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.