comefrom: <doocs>1864.Minimum Number of Swaps to Make the Binary String Alternating_1.py
code: def minSwaps( s: str) -> int:
      s0n0 = s0n1 = s1n0 = s1n1 = 0
      for i in range(len(s)):
          if (i & 1) == 0:
              if s[i] != '0':
                  s0n0 += 1
              else:
                  s1n1 += 1
          else:
              if s[i] != '0':
                  s1n0 += 1
              else:
                  s0n1 += 1
      if s0n0 != s0n1 and s1n0 != s1n1:
          return -1
      if s0n0 != s0n1:
          return s1n0
      if s1n0 != s1n1:
          return s0n0
      return min(s0n0, s1n0)
masked: def sample_funcname ( var_0 : str ) -> int :
      var_7 = var_3 = var_4 = var_5 = 0
      for var_10 in range ( len ( var_0 ) ) :
          if ( var_10 & 1 ) == 0 :
              if var_0 [ var_10 ] != '0' :
                  var_7 += 1
              else :
                  var_5 += 1
          else :
              if var_0 [ var_10 ] != '0' :
                  var_4 += 1
              else :
                  var_3 += 1
      if var_7 != var_3 and var_4 != var_5 :
          return - 1
      if var_7 != var_3 :
          return var_4
      if var_4 != var_5 :
          return var_7
      return min ( var_7 , var_4 )
  