Post History
BQN, 31 28 bytes {1+(1≠𝕩)◶¯1‿𝕊2(|⊑÷˜∾1+3×⊢)𝕩} Try it online! An anonymous function which takes a number. the ¯1 branch is a bit tacky but saves a byte over (1+𝕊).
Answer
#2: Post edited
# [BQN], 31 bytes{1+(1=𝕩)◶𝕊‿¯1(2|𝕩)⊑(𝕩÷2)∾1+3×𝕩}- [Try it online!][TIO-ktkck6vv]
- [BQN]: https://mlochbaum.github.io/BQN
[TIO-ktkck6vv]: https://mlochbaum.github.io/BQN/try.html#code=RuKGkHsxKygxPfCdlakp4pe28J2ViuKAv8KvMSgyfPCdlakp4oqRKPCdlanDtzIp4oi+MSszw5fwnZWpfQoKRsKoMSvihpUxMAo=- An anonymous function which takes a number.
- the `¯1` branch is a bit tacky but saves a byte over `(1+𝕊)`.
- # [BQN], ~~31~~ 28 bytes
- {1+(1≠𝕩)◶¯1‿𝕊2(|⊑÷˜∾1+3×⊢)𝕩}
- [Try it online!][TIO-ktkck6vv]
- [BQN]: https://mlochbaum.github.io/BQN
- [TIO-ktkck6vv]: https://mlochbaum.github.io/BQN/try.html#code=RuKGkHsxKygx4omg8J2VqSnil7bCrzHigL/wnZWKMih84oqRw7fLnOKJjTErM8OX4oqiKfCdlal9CgpGwqgxK+KGlTEw
- An anonymous function which takes a number.
- the `¯1` branch is a bit tacky but saves a byte over `(1+𝕊)`.
#1: Initial revision
# [BQN], 31 bytes {1+(1=𝕩)◶𝕊‿¯1(2|𝕩)⊑(𝕩÷2)∾1+3×𝕩} [Try it online!][TIO-ktkck6vv] [BQN]: https://mlochbaum.github.io/BQN [TIO-ktkck6vv]: https://mlochbaum.github.io/BQN/try.html#code=RuKGkHsxKygxPfCdlakp4pe28J2ViuKAv8KvMSgyfPCdlakp4oqRKPCdlanDtzIp4oi+MSszw5fwnZWpfQoKRsKoMSvihpUxMAo= An anonymous function which takes a number. the `¯1` branch is a bit tacky but saves a byte over `(1+𝕊)`.