First time here? Check out the FAQ!
answered 2015-12-22 21:36:04 +0100
A one line conversion
sage: w = [1,1,1,0,0,1,0,0] sage: for i in range(1,len(w)): w[i] = w[i-1] + 2*w[i]-1 sage: print w [1, 2, 3, 2, 1, 2, 1, 0]