Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_binary_incr.py
- cache = {}
- def b_binary_incr(b, incr=1):
- if b in cache:
- return cache[b]
- value = int(b, 2)
- value = (value + incr) % (2 ** len(b))
- result = f"{value:0{len(b)}b}"
- cache[b] = result
- return result
- xy = end = '0' * 16
- while 1:
- print(xy)
- xy = b_binary_incr(xy)
- if xy == end:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement