Problem: N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.  The i-th tile from the left is painted black if the i-th character of S is `0`, and painted white if that character is `1`.  You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.  At least how many tiles need to be repainted to satisfy the condition?

Submission attempts (in order):
S = input()
sum01 = 0
sum10 = 0

if S[0:1] == '0':
  for i in range(len(S)-1):
    if (i % 2) == 0:
      if S[i+1:i+2] == 1:
        sum01 += 1
    if (i % 2) == 1:
      if S[i+1:i+2] == 0:
        sum01 += 1

else:
  for i in range(len(S)-1):
    if (i % 2) == 0:
      if S[i+1:i+2] == 0:
        sum10 += 1
    if (i % 2) == 1:
      if S[i+1:i+2] == 1:
        sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)

S = input()
sum01 = 0
sum10 = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == 1:
      sum01 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 0:
      sum01 += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i+:i+1] == 0:
      sum10 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 1:
      sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)


S = input()
sum01 = 0
sum10 = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == 1:
      sum10 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 0:
      sum10 += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == 0:
      sum01 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 1:
      sum01 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)


S = input()
sum01 = 0
sum10 = 0

if S[0:1] == '0':
  for i in range(len(S)-1):
    if (i % 2) == 0:
      if S[i+1:i+2] == '1':
        sum01 += 1
    if (i % 2) == 1:
      if S[i+1:i+2] == '0':
        sum01 += 1

else:
  for i in range(len(S)-1):
    if (i % 2) == 0:
      if S[i+1:i+2] == '0':
        sum10 += 1
    if (i % 2) == 1:
      if S[i+1:i+2] == '1':
        sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)


S = input()
sum01 = 0
sum10 = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == 1:
      sum10 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 0:
      sum10 += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == 0:
      sum01 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 1:
      sum01 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)


S = input()
sum01 = 0
sum10 = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == '1':
      sum01 += 1
  if (i % 2) == 1:
    if S[i:i+1] == '0':
      sum01 += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i+:i+1] == '0':
      sum10 += 1
  if (i % 2) == 1:
    if S[i:i+1] == '1':
      sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)


S = input()
sumi = 0
sumii = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == "1":
      sumi += 1
  if (i % 2) == 1:
    if S[i:i+1] == "0":
      sumi += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == "0":
      sumii += 1
  if (i % 2) == 1:
    if S[i:i+1] == "1":
      sumii += 1
        
if sumi > sumii:
  print(sumii)
else:
  print(sumi)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted