Problem p03262 (python)

Fixed submission:
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    while q != 0:
        p, q = q, p % q
    return p

y = xs[0]
for i in range(N):
    if xs[i] % y != 0:
        y = gcd(y, xs[i])

print(y)

Buggy submission (verdict: Runtime Error):
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    if p < q:
        return gcd(q, p)
    if q == 0:
        return p
    else:
        return gcd(q, p % q)

def gcdList(numbers):
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList(xs))

Buggy submission (verdict: Runtime Error):
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    if p < q:
        return gcd(q, p)
    if p % q == 0:
        return q
    return gcd(q, p % q)

def gcdList(numbers):
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList(xs))

Buggy submission (verdict: Runtime Error):
N, X = [int(_) for _ in input().split()]
xs = [int(_) - X for _ in input().split()]

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if p < q:
        return gcd(q, p)
    if p % q == 0:
        return q
    return gcd(q, p % q)

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList(xs))

Buggy submission (verdict: Runtime Error):
import math

gcd = math.gcd

N, X = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList([_ - X for _ in x]))

Buggy submission (verdict: Runtime Error):
from fractions import Fraction

gcd = fractions.gcd

N, X = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

print(gcdList([_ - X for _ in x]))

Buggy submission (verdict: Runtime Error):
N, X = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]

def gcdList(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcdList([gcd(numbers[0], numbers[1])] + numbers[2:])

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if q > p:
        return gcd(q, p)
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)

print(gcdList([_ - X for _ in x]))

Buggy submission (verdict: Runtime Error):
N, X = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]

def gcd_list(numbers):
    if len(numbers) == 1:
        return abs(numbers[0])
    if len(numbers) == 2:
        return gcd(numbers[0], numbers[1])
    else:
        return gcd_list([gcd(numbers[0], numbers[1])] + numbers[2:])

def gcd(p, q):
    if p < 0:
        return gcd(-p, q)
    if q < 0:
        return gcd(p, -q)
    if q > p:
        return gcd(q, p)
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)

xmod = [_ - X for _ in x]
print(gcd_list(xmod))