Skip to main content
-1 byte by Jakque.
Source Link

Python 3.8 (pre-release),  66   65   50   49   46  42 42  41 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().
-3 bytes by moving some stuff around.
-4 bytes by using and instead of the ternary ... if ... else ....
-1 byte by Jakque.

f=lambda x,n=1:[*x]and[x[x and[x[:n]]+fn],*f(x[n:],2*n)]

Try it online!Try it online!

Python 3.8 (pre-release),  66   65   50   49   46  42 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().
-3 bytes by moving some stuff around.
-4 bytes by using and instead of the ternary ... if ... else ....

f=lambda x,n=1:[*x]and[x[:n]]+f(x[n:],2*n)

Try it online!

Python 3.8 (pre-release),  66   65   50   49   46   42  41 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().
-3 bytes by moving some stuff around.
-4 bytes by using and instead of the ternary ... if ... else ....
-1 byte by Jakque.

f=lambda x,n=1:x and[x[:n],*f(x[n:],2*n)]

Try it online!

-4 bytes by using and instead of the ternary ... if ... else ....
Source Link

Python 3.8 (pre-release),  66   65   50  49 49   46  42 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().
-3 bytes by moving some stuff around.
-4 bytes by using and instead of the ternary ... if ... else ....

f=lambda x,n=1:[x[:n]]+[*(x[n[*x]and[x[:]and fn]]+f(x[n:],2*n))]

Try it online!Try it online!

Python 3.8 (pre-release),  66   65   50  49 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().

f=lambda x,n=1:[x[:n]]+[*(x[n:]and f(x[n:],2*n))]

Try it online!

Python 3.8 (pre-release),  66   65   50   49   46  42 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().
-3 bytes by moving some stuff around.
-4 bytes by using and instead of the ternary ... if ... else ....

f=lambda x,n=1:[*x]and[x[:n]]+f(x[n:],2*n)

Try it online!

-1 byte by using list unpacking instead of list().
Source Link

Python 3.8 (pre-release),  66  65 65   50  49 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().

lambdaf=lambda x,n=1:[x[(b:=1<<i)-1n]]+[*(x[n:2*b-1]for i in]and range(len(bin(lenf(x))x[n:],2*n)-2)]

Try it online!Try it online!

Python 3.8 (pre-release),  66  65 bytes

-1 byte by doing away with int.bit_length().

lambda x:[x[(b:=1<<i)-1:2*b-1]for i in range(len(bin(len(x)))-2)]

Try it online!

Python 3.8 (pre-release),  66   65   50  49 bytes

-1 byte by doing away with int.bit_length().
-15 bytes: recursion for the win!
-1 byte by using list unpacking instead of list().

f=lambda x,n=1:[x[:n]]+[*(x[n:]and f(x[n:],2*n))]

Try it online!

Source Link
Loading