Quantcast
Channel: Distance Between Two Points Travelling on a Polar Graph Chart - Code Golf Stack Exchange
Browsing all 8 articles
Browse latest View live

Answer by DELETE_ME for Distance Between Two Points Travelling on a Polar...

Wolfram Language (Mathematica), 47 bytesMinMax@Abs@{##}.{Min[Abs[Arg@#-Arg@#2]-1,1],1}&Try it online!(beats the current 66-byte answer)Take input as 2 complex numbers.May have some issues if the...

View Article



Image may be NSFW.
Clik here to view.

Answer by Kelly Lowder for Distance Between Two Points Travelling on a Polar...

Mathematica 66 BytesThis takes rectangular coordinates and can output an exact symbolic...

View Article

Answer by R. Kap for Distance Between Two Points Travelling on a Polar Graph...

Python 2, 164126125 132 bytes:def A(a,b,c,d,p=3.1415926535):z=abs(a-c);M=lambda f:2*p*f*abs(b-d)/360.0;print min((a==c)*min(a+c,M(a))+(b==d)*z or'',M(a)+z,M(c)+z)I am currently looking into golfing...

View Article

Answer by Level River St for Distance Between Two Points Travelling on a...

Ruby, 64 bytesFirst, my submission. Lambda function with arguments distance 1, angle 1, distance 2, angle2.->r,a,s,b{([d=(b-a).abs,?i.to_c.arg*4-d,2].min-2)*[r,s].min+s+r}Now here's two different...

View Article

Answer by Luis Mendo for Distance Between Two Points Travelling on a Polar...

MATL, 22 bytes|ttsGZ}/X/bX<*|bd|+hX<Input is an array of two complex numbers.Try it online! Or verify all test cases.Explanation| % Implicitly input array and take absolute value of its entriestt...

View Article


Answer by Neil for Distance Between Two Points Travelling on a Polar Graph Chart

JavaScript (ES6), 65 byteswith(Math)(r,t,s,u,v=acos(cos(t-u)))=>v<2?abs(r-s)+v*min(r,s):r+sTakes polar coordinates. Uses @Angs' trick for reducing an angle to between 0 and π. For rectangular...

View Article

Answer by Angs for Distance Between Two Points Travelling on a Polar Graph Chart

Haskell, 49 48 bytes(a!q)c r=min(q+r)$abs(q-r)+acos(cos$a-c)*min q rUsage:> let rect2polar (x,y)=(atan2 y x, sqrt(x^2+y^2))> let test c1 c2=let [(a1,r1),(a2,r2)]=rect2polar<$>[c1,c2] in...

View Article

Image may be NSFW.
Clik here to view.

Distance Between Two Points Travelling on a Polar Graph Chart

Brief Problem ExplanationWrite a program to find the minimum distance between two points traveling only on rays emanating from the origin and circles centered on the origin.Explanation of PremiseNow...

View Article

Browsing all 8 articles
Browse latest View live




Latest Images