Quantcast
Channel: Active questions tagged tiling - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 35

Triangular domino tiling of an almost regular hexagon

$
0
0

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, and z, find the number of x-by-y arrays whose elements are between 0 and z 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 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 => 21,1,2 => 31,2,3 => 102,3,1 => 10 (the order of inputs doesn't matter, since it's the same hexagon)2,3,4 => 4903,4,2 => 4903,3,5 => 14112

Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>