Post History
Uiua, 19 17 bytes (SBCS) Takes argument as integer (decimal), returns lone ones count. /+↧↧∩¬⊸∩⌟⬚0↻¯∩1⊥₂ Uiua pad this online Explanation Rotates binary representation left and right (negate...
#2: Post edited
# [Uiua][uiua], 19 bytes (SBCS)- Takes argument as integer (decimal), returns lone ones count.
- ```uiua
/+/↧⊂⊟∩¬⊸∩⌟⬚0↻¯∩1⊥₂- ```
[Uiua pad this online](https://uiua.org/pad?src=0_19_0-dev_2__eJxdjjEKwzAMRfecwnuHWJIt2xfIwTKE1DTQtV2ypJRAoWuhW46ikxQXWhSP4on3X2dkOJv20Mpwl9xLnmVct4fkl4yrnGZ5XK0M7-0p4wqSb9L3jUyLLBc5Tsaaztjqdphc4oDJKwCmMwguuEjsYgVA3agfU6VOkayrnoHABtQRRVkimBKDjtjVaU8B_9FQqQgREL0LOvO38VWRBlxckYkAPO2yCgFHwN4HrrsgQEiRE8TmA_C7ooE=)- ## Explanation
- Rotates binary representation left and right (negated), then checks that the "neighbourhood" is empty.
- ```uiua
/+/↧⊂⊟∩¬⊸∩⌟⬚0↻¯∩1⊥₂ # 17 example input⊥₂ # [1 0 0 0 1] base-2 digits¯∩1 # -1 1 [...] push -1 and 1 to stack⊸ # while keeping input argument on stack∩ # apply the following function twice⌟ # while keeping its second ("right") argument constant⬚0↻ # function being: rotate array,filling with zeros instead of wrapping around# resulting stack:# [0 1 0 0 0] [0 0 0 1 0] [1 0 0 0 1]∩¬ # [1 0 1 1 1] [1 1 1 0 1] [1 0 0 0 1] negate two top arrays⊂⊟ # ╭─ stack all three arrays# ╷ 1 0 1 1 1 (alternatively written as ⊟₃)# 1 1 1 0 1# 1 0 0 0 1# ╯/↧ # [ 1 0 0 0 1] reduce by minimum/+ # 2 sum- ```
- [uiua]: https://uiua.org/
- # [Uiua][uiua], <del>19</del> 17 bytes (SBCS)
- Takes argument as integer (decimal), returns lone ones count.
- ```uiua
- /+↧↧∩¬⊸∩⌟⬚0↻¯∩1⊥₂
- ```
- [Uiua pad this online](https://uiua.org/pad?src=0_19_0-dev_2__eJxdjjsKwkAQQPucYnsLdz47u3uBHCxFiMGArTY2EQkItoJdjjInkRWUycI0wxvevNZpf3L7nfb3MsOyPnR86bDo8aqPi9f-vT51WEDHm3Zdo9Os81kPk_Oudb7aGTNniZiDAeBah8CREwmnCoDZ0R7mSp0Tea6OgcBHtBFFWSKEsoCN2NRZTwH_p7FSESIgBo428_fjqyILpLiSEAEE2mQVAkwgIUSpuyBCzEkypOYDq4igaA==)
- ## Explanation
- Rotates binary representation left and right (negated), then checks that the "neighbourhood" is empty.
- ```uiua
- /+↧↧∩¬⊸∩⌟⬚0↻¯∩1⊥₂ # 17 example input
- ⊥₂ # [1 0 0 0 1] base-2 digits
- ¯∩1 # -1 1 [...] push -1 and 1 to stack
- ⊸ # while keeping input argument on stack
- ∩ # apply the following function twice
- ⌟ # while keeping its second ("right") argument constant
- ⬚0↻ # function being: rotate array,
- filling with zeros instead of wrapping around
- # resulting stack:
- # [0 1 0 0 0] [0 0 0 1 0] [1 0 0 0 1]
- ∩¬ # [1 0 1 1 1] [1 1 1 0 1] [1 0 0 0 1] negate two top arrays
- ↧↧ # [ 1 0 0 0 1] element-wise minimum of all 3 array
- /+ # 2 sum
- ```
- ### Changes
- * -2 bytes: `/↧⊂⊟` is simply `↧↧`
- [uiua]: https://uiua.org/
#1: Initial revision
# [Uiua][uiua], 19 bytes (SBCS)
Takes argument as integer (decimal), returns lone ones count.
```uiua
/+/↧⊂⊟∩¬⊸∩⌟⬚0↻¯∩1⊥₂
```
[Uiua pad this online](https://uiua.org/pad?src=0_19_0-dev_2__eJxdjjEKwzAMRfecwnuHWJIt2xfIwTKE1DTQtV2ypJRAoWuhW46ikxQXWhSP4on3X2dkOJv20Mpwl9xLnmVct4fkl4yrnGZ5XK0M7-0p4wqSb9L3jUyLLBc5Tsaaztjqdphc4oDJKwCmMwguuEjsYgVA3agfU6VOkayrnoHABtQRRVkimBKDjtjVaU8B_9FQqQgREL0LOvO38VWRBlxckYkAPO2yCgFHwN4HrrsgQEiRE8TmA_C7ooE=)
## Explanation
Rotates binary representation left and right (negated), then checks that the "neighbourhood" is empty.
```uiua
/+/↧⊂⊟∩¬⊸∩⌟⬚0↻¯∩1⊥₂ # 17 example input
⊥₂ # [1 0 0 0 1] base-2 digits
¯∩1 # -1 1 [...] push -1 and 1 to stack
⊸ # while keeping input argument on stack
∩ # apply the following function twice
⌟ # while keeping its second ("right") argument constant
⬚0↻ # function being: rotate array,
filling with zeros instead of wrapping around
# resulting stack:
# [0 1 0 0 0] [0 0 0 1 0] [1 0 0 0 1]
∩¬ # [1 0 1 1 1] [1 1 1 0 1] [1 0 0 0 1] negate two top arrays
⊂⊟ # ╭─ stack all three arrays
# ╷ 1 0 1 1 1 (alternatively written as ⊟₃)
# 1 1 1 0 1
# 1 0 0 0 1
# ╯
/↧ # [ 1 0 0 0 1] reduce by minimum
/+ # 2 sum
```
[uiua]: https://uiua.org/
