23
3
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
2@LuisMendo If you're referring to the second figure, each color represents an orientation of each domino. A domino is a rhombus (i.e. diamond) bounded by solid black edges. – Bubbler – 2019-11-18T23:46:23.480
1Of course, they are rhombi, not triangles. My bad. Still, I'd clarify that the colour just indicates orientation for easier viewing of the figure – Luis Mendo – 2019-11-18T23:48:27.440
1Distinct up to what symmetry group? – Peter Taylor – 2019-11-19T08:16:04.260
@PeterTaylor Symmetry is not considered. For example, 180 degrees rotation of the second image is distinct from the original. – Bubbler – 2019-11-19T08:23:20.550