14
\$\begingroup\$

Background

In 1796, 18-year-old Carl Friedrich Gauss proved that a regular 17-gon can be constructed with compass and straightedge — the first such discovery in over 2,000 years. The stonemason tasked with his tombstone refused to carve a 17-gon ("nobody could tell it from a circle") and made a 17-pointed star instead. This {17/8} heptadecagram adorns the https://commons.wikimedia.org/wiki/File:Braunschweig_Gauss-Denkmal_17-eckiger_Stern.jpg.

Challenge

Draw the Gauss star with:

  • Gold/yellow fill (no internal edges visible)
  • Black outline

Specifications

Geometry: The 17 outer vertices lie on a circle, connected as a {17/8} star polygon:

vertex[i] = (cos(2π·8i/17), sin(2π·8i/17)) for i = 0..16

Equivalently, construct a 34-vertex boundary polygon alternating between outer radius R and inner radius r ≈ 0.337R, with tolerance r/R ∈ [1/2, 1/3].

Fill: The entire star interior must be filled — no crossing lines or holes visible.

Colors:

  • Fill: Hue between 45° and 65° (gold to yellow range), saturation ≥ 80%, lightness ≥ 50%
  • Stroke: Black or near-black (lightness ≤ 20%)

Size: Minimum 200×200 pixels, star reasonably centered.

Rotation: Any orientation is acceptable.

Rules

  1. Compute vertices using language built-ins only — no geometry/polygon libraries
  2. Standard graphics libraries (Canvas, SVG, PIL, etc.) allowed for rendering
  3. Output: displayed graphic, image file, or valid SVG

Scoring

[code-golf] — shortest code in bytes wins.

Reference

Target output:

gauss-star-reference.png

Gold (#FFD700) fill, black outline, {17/8} star polygon with winding fill.


The monument photo is already linked in the Background section for historical context.

New contributor
Jan Popelka is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
4
  • \$\begingroup\$ What is the tolerance for r/R? \$\endgroup\$ Commented 18 hours ago
  • 1
    \$\begingroup\$ @LuisMendo Let's say r/R ∈ [1/2, 1/3], apology for lacking formulation \$\endgroup\$ Commented 17 hours ago
  • \$\begingroup\$ Thanks. Please edit that into the challenge text, so people won't have to read the comments \$\endgroup\$ Commented 10 hours ago
  • \$\begingroup\$ Is the output of my (not yet posted) GFA Basic answer invalid because of the small holes? \$\endgroup\$ Commented 8 hours ago

6 Answers 6

7
\$\begingroup\$

Logo, 58+18=76 bytes

pu setxy 14 -49pd for[i 0 33][rt 148+:i%2*42.8fd 99]pu fd 9setpencolor 6fill 

Saved 1 byte using for loop and :i%2 to alternate between angles. Added 18 bytes to move the turtle before drawing so that the image is centred on the origin (the turtle direction is reversed so that the x offset is positive, saving a single byte)

Logo, 59 bytes

repeat 17[lt 148fd 99rt 169.2fd 99]pu fd 9setpencolor 6fill 

Run at https://www.calormen.com/jslogo/

The following may be useful if running more than once:

 cs                clears the screen
 pd                puts the pen back down after pu
 setpencolor 0     returns pen colour to black
 ht / st           hides turtle / shows turtle
\$\endgroup\$
3
  • \$\begingroup\$ Very nice, not centered, but reasonably centered! I cannot upvote yet, sorry. \$\endgroup\$ Commented 22 hours ago
  • \$\begingroup\$ @JanPopelka I'm not sure if you're saying you can't upvote because the star isn't perfectly centred or if it's because you don't have the reputation. It's another 18 bytes to move the cursor so that the star will be perfectly centred (it still may not look centred because the turtle ends in a weird place) However it was to my mind already reasonably centred which I understood to be the requirement. \$\endgroup\$ Commented 16 hours ago
  • \$\begingroup\$ Reputation, already upvoted! Thank you. \$\endgroup\$ Commented 15 hours ago
6
\$\begingroup\$

R, 36 bytes

A slightly modified version of pajonk in R.

symbols(0,st=t(rep(c(1,3),17)),bg=7)

Replace "gold" with 7. Replace 0.337 with .3 or even .337 to remove the leading 0. 7 here is the equivalent of "gold" with 5 less characters. And the leading 0 is not necessary, and perhaps the .037 is also not necessary?

Star picture

Try it out.

New contributor
test qa is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
5
\$\begingroup\$

R, 45 44 bytes

symbols(0,st=t(rep(c(1,.337),17)),bg="gold")

Try it on rdrr.io!

R has a built in function to draw a whole range of symbols.

\$\endgroup\$
2
\$\begingroup\$

Red, 179 bytes

s: collect/into [r: 180 c: 0.337 a: 0. loop 34[r: r * c keep 200x200 + as-pair r * sin a r * cos a c: 1 / c a: pi / 17 + a]]
[fill-pen gold polygon]view[base 400x400 white draw s]

Gauss Star

\$\endgroup\$
1
\$\begingroup\$

Vyxal 3, 72 bytes

"/ɾᏜ≛÷Ẅ6x+XGσ«L<$⅟=~½`↸∥ʁ⊖±ᴥ⦷k)¿=∺”②ʁƛ8×17÷kid×:∆s$∆c;70×70+',j}„+"M≓t”+

Vyxal It Online!

outputs a valid svg element containing a polygon. click the html button button to render the svg in your browser, or use the snippet below.

"/ɾᏜ≛÷Ẅ6x+XGσ«L<$⅟=~½`↸∥ʁ⊖±ᴥ⦷k)¿=∺”②ʁƛ8×17÷kid×:∆s$∆c;70×70+',j}„+"M≓t”+­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏⁠‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏⁠‎⁡⁠⁢⁣⁡‏⁠‎⁡⁠⁢⁣⁢‏⁠‎⁡⁠⁢⁣⁣‏⁠‎⁡⁠⁢⁣⁤‏⁠‎⁡⁠⁢⁤⁡‏⁠‎⁡⁠⁢⁤⁢‏⁠‎⁡⁠⁢⁤⁣‏⁠‎⁡⁠⁢⁤⁤‏⁠‎⁡⁠⁣⁡⁡‏⁠‎⁡⁠⁣⁡⁢‏⁠‎⁡⁠⁣⁡⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣⁡⁤‏⁠‎⁡⁠⁣⁢⁡‏⁠‎⁡⁠⁣⁢⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁢⁣‏⁠‎⁡⁠⁣⁢⁤‏⁠‎⁡⁠⁣⁣⁡‏⁠‎⁡⁠⁣⁣⁢‏⁠‎⁡⁠⁣⁣⁣‏⁠‎⁡⁠⁣⁣⁤‏⁠‎⁡⁠⁣⁤⁡‏⁠‎⁡⁠⁣⁤⁢‏⁠‎⁡⁠⁣⁤⁣‏⁠‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁣⁤⁤‏⁠‎⁡⁠⁤⁡⁡‏⁠‎⁡⁠⁤⁡⁢‏⁠‎⁡⁠⁤⁡⁣‏⁠‎⁡⁠⁤⁡⁤‏⁠‎⁡⁠⁤⁢⁡‏⁠‎⁡⁠⁤⁢⁢‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁤⁢⁣‏⁠‎⁡⁠⁤⁢⁤‏⁠‎⁡⁠⁤⁣⁡‏⁠‎⁡⁠⁤⁣⁢‏⁠‎⁡⁠⁤⁣⁣‏⁠‎⁡⁠⁤⁣⁤‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁤⁤⁡‏⁠‎⁡⁠⁤⁤⁢‏⁠‎⁡⁠⁤⁤⁣‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁤⁤⁤‏⁠‎⁡⁠⁢⁡⁡⁡‏⁠‎⁡⁠⁢⁡⁡⁢‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁢⁡⁡⁣‏⁠‎⁡⁠⁢⁡⁡⁤‏⁠‎⁡⁠⁢⁡⁢⁡‏⁠‎⁡⁠⁢⁡⁢⁢‏⁠‎⁡⁠⁢⁡⁢⁣‏⁠‎⁡⁠⁢⁡⁢⁤‏‏​⁡⁠⁡‌⁣⁡​‎‏​⁢⁠⁡‌­
"/ɾᏜ≛÷Ẅ6x+XGσ«L<$⅟=~½`↸∥ʁ⊖±ᴥ⦷k)¿=∺”                                       # ‎⁡compressed literal string "<svg><polygon fill=gold stroke=black paint-order=stroke points=\""
                                   ②ʁƛ                                    # ‎⁢from 0 to 16 map:
                                      8×17÷kid×                           # ‎⁣n*8/17*tau
                                               :∆s$∆c;                    # ‎⁤make a sine/cosine pair
                                                      70×70+              # ‎⁢⁡offset and scale by 70px for display
                                                            ',j           # ‎⁢⁢join pairs on commas
                                                               }„+        # ‎⁢⁣join the pairs on spaces, append to the previous string
                                                                  "M≓t”+  # ‎⁢⁤append compressed string "\"/>"
# ‎⁣⁡implicit output at the end of the program
💎

Created with the help of Luminespire.

 
<script type="module">
import { Vyxal } from "https://vyxal.github.io/Vyxal/vyxal.js";

var code = "\"/ɾᏜ≛÷Ẅ6x+XGσ«L<$⅟=~½`↸∥ʁ⊖±ᴥ⦷k)¿=∺”②ʁƛ8×17÷kid×:∆s$∆c;70×70+',j}„+\"M≓t”+"

// Load the short dictionary
const shortDictPromise = fetch("https://vyxal.github.io/Vyxal/ShortDictionary.txt")
.then(response => response.text())
.then(data => Vyxal.setShortDict(data))
.catch(error => console.error("Failed to load short dictionary:", error));

// Load the long dictionary
const longDictPromise = fetch("https://vyxal.github.io/Vyxal/LongDictionary.txt")
.then(response => response.text())
.then(data => Vyxal.setLongDict(data))
.catch(error => console.error("Failed to load long dictionary:", error));

// Wait for both dictionaries to load before proceeding
Promise.all([shortDictPromise, longDictPromise]).then(() => {

  const out = document.body.appendChild(document.createElement("div"));
  out.id = "vyxal-output";
  var vyxalout = []
  Vyxal.execute(code , [], "", vyxalout.push.bind(vyxalout), vyxalout.push.bind(vyxalout));
  out.insertAdjacentHTML("beforeend", vyxalout.join(""));
})
  
</script>

\$\endgroup\$
1
  • \$\begingroup\$ Why are you multiplying by children? :p \$\endgroup\$ Commented 3 hours ago
0
\$\begingroup\$

JavaScript (Node.js), 157 bytes

_=>`<svg height=999><polygon fill=gold stroke=black paint-order=stroke points=${[...Array(i=17)].map(_=>[(g=t=>Math.sin(t)*99+99)(i-=2.9568),g(i-1.5708)])}>`

Try it online!

port

\$\endgroup\$
1
  • \$\begingroup\$ black -> #000 \$\endgroup\$ Commented 12 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.