aoc-2021/03_day/tobin.py

9 lines
154 B
Python
Raw Normal View History

2021-12-05 15:52:20 +00:00
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)