Skip to main content
added 855 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 2525 24 bytes

⭆¹ΣE∕X⊘⊕×⟦¹±¹⟧₂⁵N₂⁵⎇μ⁻⁰λλ⭆¹ΣE∕X⊘⊕⟦₂⁵±₂⁵⟧N₂⁵⎇μ⁻⁰λλ 

Try it online!Try it online! Link is to verbose version of code. Explanation:

 ⟦¹±¹⟧  Literal list `1, -1`  Literal `5`  ×  Vectorised multiplySquare byroot  Literal `5`   Square root   of ± Negated    Make Literalinto `5`list ⊕ Vectorised increment ⊘ Vectorised halved X Vectorised raised to power    Input as a number ∕ Vectorised divide by     Square rootLiteral of`5`   LiteralSquare `5`root  ⎇μ⁻⁰λλ  Negate the second element Σ Sum the elements ⭆¹ Stringify 

The version of Charcoal on TIO doesn't really support complex numbers, but as it happens the Power of a negative number to a floating-point value will return a complex result; I just have to be careful not to use operations such as Negate and Cast where Charcoal will get confused as to which overload to use.

18 bytes using the newer version of Charcoal on ATO:

I↨∕X⊘⊕⟦±₂⁵₂⁵⟧N₂⁵±¹ 

Attempt This Online! Link is to verbose version of code. Explanation: The version of Charcoal on ATO can use "base -1" conversion to take the difference of a list of two complex numbers saving 5 bytes and also can directly cast a complex number to string saving a further 1 byte. (Note that the difference has the opposite sign to the TIO code so I've swapped the two list elements to compensate.)

Charcoal, 25 bytes

⭆¹ΣE∕X⊘⊕×⟦¹±¹⟧₂⁵N₂⁵⎇μ⁻⁰λλ 

Try it online! Link is to verbose version of code. Explanation:

 ⟦¹±¹⟧ Literal list `1, -1`  × Vectorised multiply by ₂ Square root of  Literal `5` ⊕ Vectorised increment ⊘ Vectorised halved X Vectorised raised to power   N Input as a number ∕ Vectorised divide by    Square root of  Literal `5`  ⎇μ⁻⁰λλ Negate the second element Σ Sum the elements ⭆¹ Stringify 

Charcoal doesn't really support complex numbers, but as it happens the Power of a negative number to a floating-point value will return a complex result; I just have to be careful not to use operations such as Negate and Cast where Charcoal will get confused as to which overload to use.

Charcoal, 25 24 bytes

⭆¹ΣE∕X⊘⊕⟦₂⁵±₂⁵⟧N₂⁵⎇μ⁻⁰λλ 

Try it online! Link is to verbose version of code. Explanation:

   Literal `5`   Square root  Literal `5`   Square root    ± Negated   Make into list ⊕ Vectorised increment ⊘ Vectorised halved X Vectorised raised to power N  Input as a number ∕ Vectorised divide by  Literal `5`  Square root E ⎇μ⁻⁰λλ  Negate the second element Σ Sum the elements ⭆¹ Stringify 

The version of Charcoal on TIO doesn't really support complex numbers, but as it happens the Power of a negative number to a floating-point value will return a complex result; I just have to be careful not to use operations such as Negate and Cast where Charcoal will get confused as to which overload to use.

18 bytes using the newer version of Charcoal on ATO:

I↨∕X⊘⊕⟦±₂⁵₂⁵⟧N₂⁵±¹ 

Attempt This Online! Link is to verbose version of code. Explanation: The version of Charcoal on ATO can use "base -1" conversion to take the difference of a list of two complex numbers saving 5 bytes and also can directly cast a complex number to string saving a further 1 byte. (Note that the difference has the opposite sign to the TIO code so I've swapped the two list elements to compensate.)

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Charcoal, 25 bytes

⭆¹ΣE∕X⊘⊕×⟦¹±¹⟧₂⁵N₂⁵⎇μ⁻⁰λλ 

Try it online! Link is to verbose version of code. Explanation:

 ⟦¹±¹⟧ Literal list `1, -1` × Vectorised multiply by ₂ Square root of ⁵ Literal `5` ⊕ Vectorised increment ⊘ Vectorised halved X Vectorised raised to power N Input as a number ∕ Vectorised divide by ₂ Square root of ⁵ Literal `5` E ⎇μ⁻⁰λλ Negate the second element Σ Sum the elements ⭆¹ Stringify 

Charcoal doesn't really support complex numbers, but as it happens the Power of a negative number to a floating-point value will return a complex result; I just have to be careful not to use operations such as Negate and Cast where Charcoal will get confused as to which overload to use.