1 | initial version |
For instance, using list comprehension:
sage: x = '0110101'
sage: R = range(len(x))
sage: def show_bit(s, exchange=False):
....: if not exchange:
....: return s
....: return str(1-int(s))
....:
sage: [ ''.join([show_bit(x[j], j <= k) for j in R]) for k in R ]
This gives the list of the path of the strings where one by one the bits are reverted:
['1110101', '1010101', '1000101', '1001101', '1001001', '1001011', '1001010']