3 minutes to read - Apr 12, 2023

Print all states of output

state = dict(enumerate([0,1,1,0,0])) tail_i = 0 next_i =len(state) for i in range(32) print(f"i={i}, state = {state}, tail_i = {tail_i}, nxt_i = {next_i}") total=0 for (j,x) in state.items(): bit_i = j-tail_i e= 2**bit_i total+=x*e print(f"j = {j}, x={x} bit_i={bit_i}, e={e}, xe={x*e}, total = {total}") print("OUTPUT",total) t0i, t1i=tail_i + 0, tail_i +3 print(f"t0i={t0i}, t1i={t1i}") t0,t1=state[t0i], state[t1i] b=t0^1 print(t0,t1,b) state[next_i] = b del state[tail_i] next_i += 1 tail_i += 1 Show the entire output of the program.

Here is the output of the program:

Copy code

`i=0, state = {0: 0, 1: 1, 2: 1, 3: 0, 4: 0}, tail_i = 0, nxt_i = 5 j = 0, x=0 bit_i=0, e=1, xe=0, total = 0 j = 1, x=1 bit_i=1, e=2, xe=2, total = 2 j = 2, x=1 bit_i=2, e=4, xe=4, total = 6 j = 3, x=0 bit_i=3, e=8, xe=0, total = 6 j = 4, x=0 bit_i=4, e=16, xe=0, total = 6 OUTPUT 6 t0i=0, t1i=3 0 0 1 i=1, state = {1: 1, 2: 1, 3: 0, 4: 0, 5: 1}, tail_i = 1, nxt_i = 6 j = 1, x=1 bit_i=0, e=1, xe=1, total = 1 j = 2, x=1 bit_i=1, e=2, xe=2, total = 3 j = 3, x=0 bit_i=2, e=4, xe=0, total = 3 j = 4, x=0 bit_i=3, e=8, xe=0, total = 3 j = 5, x=1 bit_i=4, e=16, xe=16, total = 19 OUTPUT 19 t0i=1, t1i=4 1 0 1 i=2, state = {2: 1, 3: 0, 4: 0, 5: 1, 6: 1}, tail_i = 2, nxt_i = 7 j = 2, x=1 bit_i=0, e=1, xe=1, total = 1 j = 3, x=0 bit_i=1, e=2, xe=0, total = 1 j = 4, x=0 bit_i=2, e=4, xe=0, total = 1 j = 5, x=1 bit_i=3, e=8, xe=8, total = 9 j = 6, x=1 bit_i=4, e=16, xe=16, total = 25 OUTPUT 25 t0i=2, t1i=5 1 1 0 i=3, state = {3: 0, 4: 0, 5: 1, 6: 1, 7: 0}, tail_i = 3, nxt_i = 8 j = 3, x=0 bit_i=0, e=1, xe=0, total = 0 j = 4, x=0 bit_i=1, e=2, xe=0, total = 0 j = 5, x=1 bit_i=2, e=4, xe=4, total = 4 j = 6, x=1 bit_i=3, e=8, xe=8, total = 12 j = 7, x=0 bit_i=4, e=16, xe=0, total = 12 OUTPUT 12 t0i=3,`

loading...