Skip to main content
Changed to more unique alternative to remove the empty trailing strings
Source Link
Kevin Cruijssen
  • 128.3k
  • 12
  • 141
  • 381

05AB1E, 6 bytes

gÝo£õÜ

Try it online.

Or minor alternative:

ā<o£õKā<o£ʒĀ

Try it online.Try it online.

Explanation:

g       #  Push the length of the (implicit) input-list
 Ý      #  Pop and push a list in the range [0,length]
        # OR:
ā       #  Push a list in the range [1, (implicit) input-length]
 <      #  Decrease each by 1 to the range [0,length)
  o     # Map each value to 2 to the power this value
   £    # Split the (implicit) input-string into parts of those sizes
    õÜ  #  Trim all trailing ""
        # OR:
    õKʒ   #  RemoveFilter allthese string-parts:
     Ā  #   Check if truthy (where "" is falsey)
        # (after which the result is output implicitly)

05AB1E, 6 bytes

gÝo£õÜ

Try it online.

Or minor alternative:

ā<o£õK

Try it online.

Explanation:

g       #  Push the length of the (implicit) input-list
 Ý      #  Pop and push a list in the range [0,length]
        # OR:
ā       #  Push a list in the range [1, (implicit) input-length]
 <      #  Decrease each by 1 to the range [0,length)
  o     # Map each value to 2 to the power this value
   £    # Split the (implicit) input-string into parts of those sizes
    õÜ  #  Trim all trailing ""
        # OR:
    õK  #  Remove all ""
        # (after which the result is output implicitly)

05AB1E, 6 bytes

gÝo£õÜ

Try it online.

Or minor alternative:

ā<o£ʒĀ

Try it online.

Explanation:

g       #  Push the length of the (implicit) input-list
 Ý      #  Pop and push a list in the range [0,length]
        # OR:
ā       #  Push a list in the range [1, (implicit) input-length]
 <      #  Decrease each by 1 to the range [0,length)
  o     # Map each value to 2 to the power this value
   £    # Split the (implicit) input-string into parts of those sizes
    õÜ  #  Trim all trailing ""
        # OR:
    ʒ   #  Filter these string-parts:
     Ā  #   Check if truthy (where "" is falsey)
        # (after which the result is output implicitly)
Source Link
Kevin Cruijssen
  • 128.3k
  • 12
  • 141
  • 381

05AB1E, 6 bytes

gÝo£õÜ

Try it online.

Or minor alternative:

ā<o£õK

Try it online.

Explanation:

g       #  Push the length of the (implicit) input-list
 Ý      #  Pop and push a list in the range [0,length]
        # OR:
ā       #  Push a list in the range [1, (implicit) input-length]
 <      #  Decrease each by 1 to the range [0,length)
  o     # Map each value to 2 to the power this value
   £    # Split the (implicit) input-string into parts of those sizes
    õÜ  #  Trim all trailing ""
        # OR:
    õK  #  Remove all ""
        # (after which the result is output implicitly)