Skip to main content
alt
Source Link
Adám
  • 30.6k
  • 2
  • 122
  • 286

APL (Dyalog Extended), 16 12 bytes

Anonymous tacit prefix function, port of Bubbler's J.

⊢⊂⍨1=1⊥2⊤⍳∘��

 the argument…

⊂⍨ partitioned by…

1= where one equals…

1⊥  the vertical sum (lit. base-1 evaluation) of…

2⊤ the binary representation (one number per column) of

⍳∘  the indices from 1 to the…

 length of the argument

Try it online!Try it online!

Alternative APL (Dyalog Unicode), 12 bytes

Anonymous tacit prefix function, port of noodle person's J.

⊢⊆⍨1+∘⌊2⍟⍳∘≢

 the argument…

⊂⍨ grouped by…

1+∘ incremented…

 floored…

2⍟ log₂ of…

⍳∘ the indices of…

 the argument length Try it online!

Old APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument

APL (Dyalog Extended), 16 12 bytes

Anonymous tacit prefix function, port of Bubbler's J.

⊢⊂⍨1=1⊥2⊤⍳∘≢

 the argument…

⊂⍨ partitioned by…

1= where one equals…

1⊥  the vertical sum (lit. base-1 evaluation) of…

2⊤ the binary representation (one number per column) of

⍳∘  the indices from 1 to the…

 length of the argument

Try it online!

Old APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument

APL (Dyalog Extended), 16 12 bytes

Anonymous tacit prefix function, port of Bubbler's J.

⊢⊂⍨1=1⊥2⊤⍳∘≢

 the argument…

⊂⍨ partitioned by…

1= where one equals…

1⊥  the vertical sum (lit. base-1 evaluation) of…

2⊤ the binary representation (one number per column) of

⍳∘  the indices from 1 to the…

 length of the argument

Try it online!

Alternative APL (Dyalog Unicode), 12 bytes

Anonymous tacit prefix function, port of noodle person's J.

⊢⊆⍨1+∘⌊2⍟⍳∘≢

 the argument…

⊂⍨ grouped by…

1+∘ incremented…

 floored…

2⍟ log₂ of…

⍳∘ the indices of…

 the argument length Try it online!

Old APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument

-4
Source Link
Adám
  • 30.6k
  • 2
  • 122
  • 286

APL (Dyalog Unicode)APL (Dyalog Extended), 1616 12 bytes

Anonymous tacit prefix function, port of Bubbler's J.

⊢⊂⍨1=1⊥2⊤⍳∘≢

 the argument…

⊂⍨ partitioned by…

1= where one equals…

1⊥  the vertical sum (lit. base-1 evaluation) of…

2⊤ the binary representation (one number per column) of

⍳∘  the indices from 1 to the…

 length of the argument

Try it online!

Old APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument

APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument

APL (Dyalog Extended), 16 12 bytes

Anonymous tacit prefix function, port of Bubbler's J.

⊢⊂⍨1=1⊥2⊤⍳∘≢

 the argument…

⊂⍨ partitioned by…

1= where one equals…

1⊥  the vertical sum (lit. base-1 evaluation) of…

2⊤ the binary representation (one number per column) of

⍳∘  the indices from 1 to the…

 length of the argument

Try it online!

Old APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument

Source Link
Adám
  • 30.6k
  • 2
  • 122
  • 286

APL (Dyalog Unicode), 16 bytes

Anonymous tacit prefix function. Requires 0-based indexing (⎕IO←0) which is default on many systems.

⊢⊂⍨≢↑∘∊1↑¨⍨2*⍳∘≢

Try it online!

 the argument…

⊂⍨ partitioned by…

 the length of the argument…

↑∘∊ -sized prefix of the the flattened…

1↑¨⍨ prefixes of 1 (padding with trailing 0s) of lengths…

2* two to the power of…

⍳∘≢ the indices (0…n−1) of the length of the argument