Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Draw the GKMS aperiodic tile

Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically:

Indeed they found a one-parameter family of such aperiodic monotiles or "einsteins". The edges of all tiles in this family meet at 90° or 120° and are made out of two distinct lengths:

Let \$a\$ and \$b\$ be nonnegative real numbers and define the following turtle graphics commands:

  • \$A,B\$: move forwards by \$a\$ or \$b\$ respectively (blue and purple edges in the image above)
  • \$L,R\$: turn left or right by 90° respectively
  • \$S,T\$: turn left or right by 60° respectively

Then the aperiodic tile \$T(a,b)\$ associated with \$a\$ and \$b\$ is traced by the command sequence $$ASAR\ BSBR\ ATAL\ BTBR\ ATAL\ BTBBTBR$$ It is clear that \$T(a,b)\$ is similar to \$T(ka,kb)\$ for any scaling constant \$k\$, so we can reduce the number of parameters to one by defining $$T(p)=T(p,1-p)\qquad0\le p\le1$$ The tile in this challenge's first picture – the "hat" of the GKMS paper – is \$T\left(\frac{\sqrt3}{\sqrt3+1}\right)\$. \$T(0)\$, \$T(1)\$ and \$T(1/2)\$ admit periodic tilings, but the first two of these exceptions are polyiamonds and play a central role in the proof that \$T(p)\$ for all other \$p\in[0,1]\$ is aperiodic.

Task

Given a real number \$p\$ satisfying \0ドル\le p\le1\$, draw \$T(p)\$ as defined above.

  • The image can be saved to a file or piped raw to stdout in any common image file format, or it can be displayed in a window.
  • The polygon may be drawn in any orientation and may be flipped from the schematic above (though of course the aspect ratio must not be changed). It may be filled with any colour or pattern and may optionally be outlined with any colour, but the polygon's boundary must be clear.
  • Raster images must be at least 400 pixels wide, and an error of 2 pixels/1% is allowed.

This is ; fewest bytes wins.

Test cases

\$p\$ \$T(p)\$
0
0.2
\$\frac1{\sqrt3+1}=\$
0.36602540378443865
0.5
\$\frac{\sqrt3}{\sqrt3+1}=\$
0.6339745962155613
0.8
1

Answer*

Draft saved
Draft discarded
Cancel

AltStyle によって変換されたページ (->オリジナル) /