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

Return to Answer

Commonmark migration
Source Link

#MATL , 11 bytes

MATL , 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total change of angle will be a multiple of 2*pi because 
 % the path is closed. Total change of angle coincides with last unwrapped
 % angle because the first angle is always 0
2/ % divide by 2
YP/ % divide by pi

#MATL , 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total change of angle will be a multiple of 2*pi because 
 % the path is closed. Total change of angle coincides with last unwrapped
 % angle because the first angle is always 0
2/ % divide by 2
YP/ % divide by pi

MATL , 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total change of angle will be a multiple of 2*pi because 
 % the path is closed. Total change of angle coincides with last unwrapped
 % angle because the first angle is always 0
2/ % divide by 2
YP/ % divide by pi
added 6 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total angle change of angle will be a multiple of 2*pi because 
 % the path is closed. Total angle change of angle coincides with last unwrapped angle because
 % angle because the first angle is always 0
2/ % divide by 2
YP/ % divide by pi

#MATL, 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total angle change will be a multiple of 2*pi because 
 % the path is closed. Total angle change coincides with last unwrapped angle because
 % the first angle is always 0
2/ % divide by 2
YP/ % divide by pi

#MATL, 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total change of angle will be a multiple of 2*pi because 
 % the path is closed. Total change of angle coincides with last unwrapped
 % angle because the first angle is always 0
2/ % divide by 2
YP/ % divide by pi
added 10 characters in body; deleted 2 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles (inin radians) by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total angle change will be a multiple of 2*pi because 
 % the path is closed. Total angle change coincides with last unwrapped angle because
 % the first angle is always 0
2/ % divide by 2
YP/ % divide by pi

#MATL, 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles (in radians) by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total angle change will be a multiple of 2*pi because 
 % the path is closed. Total angle change coincides with last angle because
 % the first angle is always 0
2/ % divide by 2
YP/ % divide by pi

#MATL, 11 bytes

X/Z/0)2/YP/

Input is a sequence of complex numbers including the end point.

Try it online!

###Explanation

Most of the work is done by the Z/ function (unwrap), which unwraps angles in radians by changing absolute jumps greater than or equal to pi to their 2*pi complement.

X/ % compute angle of each complex number
Z/ % unwrap angles
0) % pick last value. Total angle change will be a multiple of 2*pi because 
 % the path is closed. Total angle change coincides with last unwrapped angle because
 % the first angle is always 0
2/ % divide by 2
YP/ % divide by pi
deleted 30 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading

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