How many unit hexagonal tiles can be placed inside a larger hexagon of sides $a,b,c,a,b,c$? I originally came across this puzzle on the codeforces website.
My first question: what is the mathematics behind solving these kind of puzzles? Just plain algebra?
My second question, more philosophical: how many of you solved this instantly? I could not solve it even after a bit of googling. I am interested in developing my intuition or mathematical aptitude for solving these kind if problems. Any advice? Its been many years since I am out of college.
Some test cases for you to check your answers before you post them. Input 2 3 4 Answer 18
Input 2 2 2 Answer 7
Input 7 8 13 Answer 224
Input 985 2 2 Answer 2956
View the border hexagon as a projection of box, so that the hexagonal tiles appear to represent somewhat-lumpy spheres stacked in layers.
How does the number of visible spheres (that is, the number of tiles) compare to the area of the three visible faces of the box?
(Image adapted from the figure given on the Codeforces web site.)
To answer your personal questions: I solved this instantly, once I adopted the proper (ahem) perspective; at that point, "the mathematics behind solving" this particular problem became almost-trivial. My advice about such problems in general is to seek out similar insights; reading contest books ---and anything by Martin Gardner--- can help in building your intuition.
By the way, I can't take too much credit for the box insight. Years ago, I came across a fairly classic puzzle about how many unit double-equilateral-triangle rhombi fit into one of these elongated hexagons; the answer becomes clear upon coloring the rhombi based upon which direction (out of three) the long diagonal points: the coloring immediately creates an illusion of stacked cubes, with each color corresponding to the direction in which each cube face ... um ... faces (up, forward, sideways). Ever since then, I've tended to see projected cubes whenever I look at hexagons ... which underscores my point that exposure to mathematical puzzles builds intuition.