Skip to main content
added 7 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 280 241 235235 233 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
p=0;exec"q=p*n;s+='M%fp=0;exec"s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(qp*n),49*sin(qp*n));p+=a;"*k
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required. 24 more by using exec instead of for i in range(k).

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

Python 2, 280 241 235 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
p=0;exec"q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q));p+=a;"*k
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required. 2 more by using exec instead of for i in range(k).

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

Python 2, 280 241 235 233 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
p=0;exec"s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(p*n),49*sin(p*n));p+=a;"*k
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required. 4 more by using exec instead of for i in range(k).

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

added 54 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 280 241241 235 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
for i in range(k):p=a*i;q=p*n;s+='M%fp=0;exec"q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q));p+=a;"*k
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required. 2 more by using exec instead of for i in range(k).

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

Python 2, 280 241 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
for i in range(k):p=a*i;q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q))
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required.

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

Python 2, 280 241 235 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
p=0;exec"q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q));p+=a;"*k
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required. 2 more by using exec instead of for i in range(k).

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

deleted 74 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39

Python 2, 280 241 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
for i in range(k):p=a*i;q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q))
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required.

Writes an SVG file named c.svg, which can be viewed, for example, in a browser or other graphics program. Look, ma! No graphics library! :)

Python 2, 280 241 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
for i in range(k):p=a*i;q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q))
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required.

Writes an SVG file named c.svg, which can be viewed, for example, in a browser or other graphics program. Look, ma! No graphics library! :)

Python 2, 280 241 bytes

from math import*
n,k=input()
a=2*pi/k
s='<svg viewBox="-49 -49 98 98"><circle r="49"/><path d="'
for i in range(k):p=a*i;q=p*n;s+='M%f,%f L%f,%f '%(49*cos(p),49*sin(p),49*cos(q),49*sin(q))
open('c.svg','w').write(s+'" stroke="red"/></svg>')

Try it online!

Saved 35 bytes due to removing xmlns attribute at the encouragement of qwr; and 4 more since %k was not required.

Writes an SVG file named c.svg. Look, ma! No graphics library! :)

added 92 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39
Loading
added 930 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39
Loading
Post Undeleted by Chas Brown
Post Deleted by Chas Brown
Source Link
Chas Brown
  • 9.8k
  • 1
  • 13
  • 39
Loading