Background
An almost regular hexagon is a hexagon where
- all of its internal angles are 120 degrees, and
- pairs of the opposite sides are parallel and have equal lengths (i.e. a zonogon).
The following is an example of an almost regular hexagon, with side lengths 2 (red), 4 (blue), and 3 (yellow).
A triangular domino is a domino made of two unit triangles. A triangular domino tiling is a tiling on a shape using triangular dominoes. The following is a possible triangular domino tiling of the above shape (each color represents an orientation of each triangular domino):
Challenge
Given the lengths of the three sides of an almost regular hexagon, find the number of distinct triangular domino tilings. The three sides will be always positive integers.
Alternative description
The second image shows that such a tiling can be viewed as an isometric view of stacked unit cubes. Now let's assign three directions to three axes in 3D:
x
= down-right / southeast / SE (blue edges in the first image)y
= down-left / southwest / SW (red edges)z
= up / north / N (yellow edges)
Then the stacked unit cubes can be represented as an x
-by-y
2D array, whose items represent the height of the stack at that position. So the above challenge is equivalent to the following:
Given three positive integers
x
,y
, andz
, find the number ofx
-by-y
arrays whose elements are between 0 andz
inclusive and all rows and columns are in decreasing order.
It happens that this is one definition of plane partition in the form of \$ PL(x,y,z) \$, and it has a closed-form formula:
$$ PL(x,y,z) = \prod_{i=1}^x \prod_{j=1}^y \prod_{k=1}^z \frac{i+j+k-1}{i+j+k-2} $$
Scoring and winning criterion
Standard code-golf rules apply. The shortest code in bytes wins.
Note that a submission is valid even if it suffers from integer overflows or floating-point inaccuracies, as long as the underlying algorithm is correct.
Test cases
x,y,z => output
---------------
1,1,1 => 2
1,1,2 => 3
1,2,3 => 10
2,3,1 => 10 (the order of inputs doesn't matter, since it's the same hexagon)
2,3,4 => 490
3,4,2 => 490
3,3,5 => 14112