A suitable algorithm to change strings to zero strings

24 Views Asked by At

I found a programming exercise I couldn't solve. Namely, I have been given a long binary string and a fixed set of operations. Here, an operation means that it takes a substring and transforms its bits $b_i$ to $1-b_i$. Also, indexed are modulo $n$ so if I apply the transform to the end of the string, also the first bits changes. For example, if a substring is 1010111001 then it becomes 0101000110.

What would be an algorithm to compute what is the minimum number of operations I need to transform a given binary string to 000...00, if the length of the substring is fixed? I heard once that one might apply Gauss–Jordan but I was unable to find the idea how to apply it.