i have an array of boolean variables. The array has a sort of structure, it's formed of many sequences of zeros and ones, sequences of different length. such as:
"commas omitted between values"
i need to separate it in this way
Someone knows a good way or just a way to do this ?
Algorithm could be language free, but in case you know how to do it in python you are welcome.
After some struggling i found a way to divide the array, but only if it begins with ONES. I realy can't figure out how to make it work with array beginning with 1 or 0.
import numpy as np x = np.asarray([1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0]) c = 1 for i in range(len(x)): if x[i] == 1: if c == 0: print "\n\tDIVIDE\n" c = 1 print "one" else: if c == 1: c = 0 print "zero"