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*

Draw a regular polygon

The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex).

  • The number of sides and the radius can be entered via a file, STDIN, or just a plain old variable. Use whatever is shorter in your language.
  • -25% of total characters/bytes if the image is actually drawn instead of ASCII art.

Answer*

Draft saved
Draft discarded
Cancel
2
  • \$\begingroup\$ Graphics@Polygon@Array[r{Sin@#,Cos@#}&,n+1,{0,2π}] \$\endgroup\$ Commented Jun 15, 2014 at 8:19
  • \$\begingroup\$ @chyaong ah, I tend to forget about Array . \$\endgroup\$ Commented Jun 15, 2014 at 8:24

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