9 lines
154 B
Python
9 lines
154 B
Python
|
|
||
|
inp = '01011'
|
||
|
out = 0
|
||
|
for i in range(0, len(inp)):
|
||
|
print(i, len(inp)-i-1)
|
||
|
if inp[i] == '1':
|
||
|
out = out | (1 << (len(inp)-i-1))
|
||
|
print(out)
|