Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    if a < b:
        a,b = b,a
    if a % b == 0:
        return b
    else:
        return gcd(b,(a % b))
 
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
cities.sort()
D=cities[0]
for i in range(N):
  D=gcd(D,cities[i])
print(D)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a,b = b,a
    if a % b == 0:
        return b
    else:
        return gcd(b,(a % b))

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)].sort()
D=cities[0]
for i in range(N):
  D=gcd(D,cities[i])
print(D)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=list(set([abs(inputcities[i]-X) for i in range(N)]))
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      i=N
    if count==N:
      print(j)
      flag=1
      break
    if i==N:
      for k in range(2,j)
        if j%k==0:
          j=k
          break
  if flag==1:
    break

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=set([abs(inputcities[i]-X) for i in range(N)])
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
  if flag==1:
    break

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
count=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
  if flag==1:
    break

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
count=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
  if flag==1:
    break

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
count=0
minimum=min(cities)
for j in range(minimum+1)[::-1]
  for i in range(N):
    if cities[i]%j==0:
      count+=1
    else:
      count=0
      break
    if count==N:
      print(j)
      flag=1
      break
if flag==1:
  break

Buggy submission (verdict: Runtime Error):
import math
import functools import reduce

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = reduce(math.gcd, cities)
print(D)

Buggy submission (verdict: Runtime Error):
import functools import reduce
import math

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = functools.reduce(math.gcd, cities)
print(D)

Buggy submission (verdict: Runtime Error):
import functools
import math

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[inputcities[i]-X for i in range(N)]
D = functools.reduce(math.gcd, cities)
print(D)