Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
785 B
2
Indexable
Never
import math

num = (input("Enter the number: "))

print(num)

r = 0
m = len(num)

while (2**r < m + r + 1):
    r =r+ 1

print(r)

def ispower(n):
    return math.ceil(math.log2(n)) == math.floor(math.log2(n))

a = []
k = m-1

for i in range(1, m+r+1):
    
    if(ispower(i)):
        a.append(9)
    else:
        a.append(num[k]) 
        k -=1
    
print("array: ")
print(a)

r1 = a[::2]
print("r1: ")
print(r1)

a2 = [ a[i:i+2] for i in range(1, len(a), 2)]
r2 = []


for i in range(0, len(a2),2):
    
    r2.extend(a2[i])

print(r2) 

a4 = [a[i:i+3] for i in range(3, len(a), 4)]

r4 = []

for i in range(0, len(a4)):
    
    r4.extend(a4[i])

print(r4)

a8 = [a[i:i+8] for i in range(8, len(a), 8)]

r8 = []

for i in range(0, len(a8)):
    
    r8.extend(a8[i])

print(r8)