Post History
JavaScript (Node.js), 47 40 50 49 bytes -1 (possibly -3) bytes thanks to Shaggy! f=(n,s='0')=>n?f(n/3+n%3/2|0,'')+"+-0+-"[n%3+2]:s Try it online! A basic recursive solution.
Answer
#5: Post edited
# [JavaScript (Node.js)], ~~47~~ ~~40~~ 50 bytes*-7 bytes thanks to Shaggy!**Why is fixing the zero case so expensive*- ```
- f=(n,s='0')=>n?f(n/3+n%3/2|0,'')+"+-0+-"[n%3+2]:s
- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kt6t7cyt]: https://tio.run/##JcjBCoIwGADgcz7FjxTb@J1OhQ7a6iE6RuBQFwvZxI0u5rMvodvH91Yf5fvFzIFbN4wxaklt5iURhMmrvWlqixrtqS6qr8gIYZgiF8jTx35YPRsftVvoNAYwIIGXQrS7LvAHIoM1OfTOejeN@eRetDuuZmugy2c13INaAj0zQNDUMNYmW/wB "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], ~~47~~ ~~40~~ ~~50~~ 49 bytes
- *-1 (possibly -3) bytes thanks to Shaggy!*
- ```
- f=(n,s='0')=>n?f(n/3+n%3/2|0,'')+"+-0+-"[n%3+2]:s
- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kt6t7cyt]: https://tio.run/##JcjBCoIwGADgcz7FjxTb@J1OhQ7a6iE6RuBQFwvZxI0u5rMvodvH91Yf5fvFzIFbN4wxaklt5iURhMmrvWlqixrtqS6qr8gIYZgiF8jTx35YPRsftVvoNAYwIIGXQrS7LvAHIoM1OfTOejeN@eRetDuuZmugy2c13INaAj0zQNDUMNYmW/wB "JavaScript (Node.js) – Try It Online"
#4: Post edited
- # [JavaScript (Node.js)], ~~47~~ ~~40~~ 50 bytes
- *-7 bytes thanks to Shaggy!*
- *Why is fixing the zero case so expensive*
- ```
f=(n,s='0')=>n?f(n/3+(n%=3)/2|0,'')+"+-0+-"[n+2]:s- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kt6t7cyt]: https://tio.run/##JcZBDoIwEADAs7xiQ2K6m6VS4QZWH2I8EKSmpNkaSryob68knmbm4TWkcfHPVUu8Tzk7i1Ilq4wie5aLQ6lbRtnblurmYyqliEvWhnV5FW5uXcouLhimFTxY0Edj@m0n@IeZ4F3sxigphukQ4gM9MKgO1IZDT9QX3/wD "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], ~~47~~ ~~40~~ 50 bytes
- *-7 bytes thanks to Shaggy!*
- *Why is fixing the zero case so expensive*
- ```
- f=(n,s='0')=>n?f(n/3+n%3/2|0,'')+"+-0+-"[n%3+2]:s
- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kt6t7cyt]: https://tio.run/##JcjBCoIwGADgcz7FjxTb@J1OhQ7a6iE6RuBQFwvZxI0u5rMvodvH91Yf5fvFzIFbN4wxaklt5iURhMmrvWlqixrtqS6qr8gIYZgiF8jTx35YPRsftVvoNAYwIIGXQrS7LvAHIoM1OfTOejeN@eRetDuuZmugy2c13INaAj0zQNDUMNYmW/wB "JavaScript (Node.js) – Try It Online"
#3: Post edited
# [JavaScript (Node.js)], ~~47~~ 40 bytes- *-7 bytes thanks to Shaggy!*
- ```
f=n=>n?f(n/3+(n%=3)/2|0)+"+-0+-"[n+2]:''- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kt6t7cyt]: https://tio.run/##JcZBDoIwEADAs7xiQ2K6m02lwg2sPsR4INiakmZrgHBB315JPM2M/drPwxTei5b0dDl7K/YqN49SNYxytA1V9ccQl6wN6/IuXD9apbJPE0a3QAAL@mxMt@8C/zATbMVhSDKn6E4xvTAAg2pB7XgMRF3xzT8 "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], ~~47~~ ~~40~~ 50 bytes
- *-7 bytes thanks to Shaggy!*
- *Why is fixing the zero case so expensive*
- ```
- f=(n,s='0')=>n?f(n/3+(n%=3)/2|0,'')+"+-0+-"[n+2]:s
- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kt6t7cyt]: https://tio.run/##JcZBDoIwEADAs7xiQ2K6m6VS4QZWH2I8EKSmpNkaSryob68knmbm4TWkcfHPVUu8Tzk7i1Ilq4wie5aLQ6lbRtnblurmYyqliEvWhnV5FW5uXcouLhimFTxY0Edj@m0n@IeZ4F3sxigphukQ4gM9MKgO1IZDT9QX3/wD "JavaScript (Node.js) – Try It Online"
#2: Post edited
# [JavaScript (Node.js)], 47 bytes- ```
f=(n,r=n%3)=>n?f(n/3+(r/2|0)|0)+"+-0+-"[r+2]:''- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kt6t7cyt]: https://tio.run/##JcZBCsIwEEDRtT3FUJBMmMbGdtcaPYi4KDWRSJhIWtxozx4Dwof/ntN7WubkX6vieLc5O4PcJMP7XpozXxxy2xOmtvtqWaKalCZVXxN1t0GI7GLCYFfwYEAdtR6LTvAHkYRPtZsjLzHYQ4gP9EAgBhBlDr2UY7XlHw "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], ~~47~~ 40 bytes
- *-7 bytes thanks to Shaggy!*
- ```
- f=n=>n?f(n/3+(n%=3)/2|0)+"+-0+-"[n+2]:''
- ```
- [Try it online!][TIO-kt6t7cyt]
- A basic recursive solution.
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kt6t7cyt]: https://tio.run/##JcZBDoIwEADAs7xiQ2K6m02lwg2sPsR4INiakmZrgHBB315JPM2M/drPwxTei5b0dDl7K/YqN49SNYxytA1V9ccQl6wN6/IuXD9apbJPE0a3QAAL@mxMt@8C/zATbMVhSDKn6E4xvTAAg2pB7XgMRF3xzT8 "JavaScript (Node.js) – Try It Online"
#1: Initial revision
# [JavaScript (Node.js)], 47 bytes ``` f=(n,r=n%3)=>n?f(n/3+(r/2|0)|0)+"+-0+-"[r+2]:'' ``` [Try it online!][TIO-kt6t7cyt] A basic recursive solution. [JavaScript (Node.js)]: https://nodejs.org [TIO-kt6t7cyt]: https://tio.run/##JcZBCsIwEEDRtT3FUJBMmMbGdtcaPYi4KDWRSJhIWtxozx4Dwof/ntN7WubkX6vieLc5O4PcJMP7XpozXxxy2xOmtvtqWaKalCZVXxN1t0GI7GLCYFfwYEAdtR6LTvAHkYRPtZsjLzHYQ4gP9EAgBhBlDr2UY7XlHw "JavaScript (Node.js) – Try It Online"