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

saved 5 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES10), 9893 bytes

This is really just a port of @xnor's answer.

Expects (a)(b).

a=>g=(b,r=1,x=(aq=a/=2)+(d=((1+a)**2++q*q-b)**.5),y=a-d)=>x+y=>x?Array(r).fill(ya-d?[x,y]a-d]:x).flat():g(b**.5,r*2)

Try it online! Try it online!

JavaScript (ES10), 98 bytes

This is really just a port of @xnor's answer.

Expects (a)(b).

a=>g=(b,r=1,x=(a/=2)+(d=((1+a)**2-b)**.5),y=a-d)=>x+y?Array(r).fill(y?[x,y]:x).flat():g(b**.5,r*2)

Try it online!

JavaScript (ES10), 93 bytes

This is really just a port of @xnor's answer.

Expects (a)(b).

a=>g=(b,r=1,x=(q=a/=2)+(d=(++q*q-b)**.5))=>x?Array(r).fill(a-d?[x,a-d]:x).flat():g(b**.5,r*2)

Try it online!

saved 2 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES10), 10098 bytes

This is really just a port of @xnor's answer.

Expects (a)(b).

f=a=>g=(a,b,r=1,x=(a/=2)+(d=((1+a)**2-b)**.5),y=a-d)=>x||y=>x+y?Array(r).fill(y?[x,y]:x).flat():fg(a,b**.5,r*2)

Try it online! Try it online!

JavaScript (ES10), 100 bytes

This is really just a port of @xnor's answer.

f=(a,b,r=1,x=(a/=2)+(d=((1+a)**2-b)**.5),y=a-d)=>x||y?Array(r).fill(y?[x,y]:x).flat():f(a,b**.5,r*2)

Try it online!

JavaScript (ES10), 98 bytes

This is really just a port of @xnor's answer.

Expects (a)(b).

a=>g=(b,r=1,x=(a/=2)+(d=((1+a)**2-b)**.5),y=a-d)=>x+y?Array(r).fill(y?[x,y]:x).flat():g(b**.5,r*2)

Try it online!

Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES10), 100 bytes

This is really just a port of @xnor's answer.

f=(a,b,r=1,x=(a/=2)+(d=((1+a)**2-b)**.5),y=a-d)=>x||y?Array(r).fill(y?[x,y]:x).flat():f(a,b**.5,r*2)

Try it online!

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