Flip the substrings of size K starting from i
j = i NEW_LINE while ( j < i + K ) : NEW_LINE INDENT if ( S [ j ] == '1' ) : NEW_LINE INDENT S [ j ] = '0' NEW_LINE DEDENT else : NEW_LINE INDENT S [ j ] = '1' NEW_LINE DEDENT j += 1 NEW_LINE DEDENT