Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Lone ​​​​​​ones

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...

posted 6mo ago by ojdo‭  ·  edited 6mo ago by ojdo‭

Answer
#2: Post edited by user avatar ojdo‭ · 2026-03-26T23:59:06Z (6 months ago)
  • # [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 by user avatar ojdo‭ · 2026-03-18T16:11:07Z (6 months ago)
# [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/