Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # increment_binary_string.py
- def increment_binary(s):
- return '{:04b}'.format(1 + int(s, 2))
- x = '0000'
- for _ in xrange(16):
- print x
- x = increment_binary(x)
- '0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement