Problem p03104 (python)

Fixed submission:
A, B = list(map(int, input().split()))

def calc_num(N):
  if N==0:
    return 0
  if N % 4 == 1:
    return 1
  if N % 4 == 2:
    return N ^ 1
  if N % 4 == 3:
    return 0
  return N ^ 0

A = calc_num(A-1)
B = calc_num(B)

print(A^B)

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N==0:
    return 0
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

print(A^B^subA^subB)

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N==0:
    return 0
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
A[-1] %= 2
B[-1] += subB
B[-1] %= 2

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [str((A[i]+B[i])%2) for i in range(len(A))]
#print(res)
print(int("".join(res), 2))

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
A[-1] %= 2
B[-1] += subB
B[-1] %= 2

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [((A[i]+B[i])%2)*2**(len(A)-i-1) for i in range(len(A))]
#print(res)
print(sum(res))

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
A[-1] %= 2
B[-1] += subB
B[-1] %= 2

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [((A[i]+B[i])%2)*2**i for i in range(len(A))]
#print(res)
print(sum(res))

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
A[-1] %= 2
B[-1] += subB
B[-1] %= 2

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [str((A[i]+B[i])%2) for i in range(len(A))]
#print(res)
print(long("".join(res), 2))

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
A[-1] %= 2
B[-1] += subB
B[-1] %= 2

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [str((A[i]+B[i])%2) for i in range(len(A))]
#print(res)
print(int("".join(res), 2))

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

def calc_num(N):
  if N % 4 == 1 or N % 4 == 3:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

numbers = [2**i for i in range(40)]

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
B[-1] += subB

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [str((A[i]+B[i])%2) for i in range(len(A))]
#print(res)
print(int("".join(res), 2))