Problem p03006 (python)

Fixed submission:
import collections


def calc(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    return xa - xb, ya - yb


n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]

if n == 1:
    print(1)
    exit()

a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        tmp = calc(balls[i], balls[j])
        a += [tmp, tuple(-i for i in tmp)]
counts = collections.Counter(a)

print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections


def calc(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    return xa - xb, ya - yb


n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]

a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        tmp = calc(balls[i], balls[j])
        a += [tmp, tuple(-i for i in tmp)]
counts = collections.Counter(a)

print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections


def calc(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    return xa - xb, ya - yb


n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]

a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(calc(balls[i], balls[j]))
counts = collections.Counter(a)

print(n-max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections

import math

n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]


def katamuki(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    x, y = (xa - xb), (ya - yb)
    dist = math.sqrt(y ** 2 + x ** 2)
    if x == 0:
        return 1000000000, dist
    if y == 0:
        return 0.0, dist
    if y / x == -1.0:
        return 1.0, dist
    return y / x, dist


a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(katamuki(balls[i], balls[j]))

counts = collections.Counter(a)
print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections

import math

n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]


def katamuki(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    x, y = (xa - xb), (ya - yb)
    dist = math.sqrt(y ** 2 + x ** 2)
    if x == 0:
        return math.inf, dist
    if y == 0:
        return 0.0, dist
    if y / x == -1.0:
        return 1.0, dist
    return y / x, dist


a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(katamuki(balls[i], balls[j]))

counts = collections.Counter(a)
print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections

import math

n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]


def katamuki(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    x, y = (xa - xb), (ya - yb)
    dist = math.sqrt(y ** 2 + x ** 2)
    if x == 0:
        return math.inf, dist
    if y == 0:
        return 0.0, dist
    if y / x == -1.0:
        return 1.0, dist
    return y / x, dist


a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(katamuki(balls[i], balls[j]))

counts = collections.Counter(a)
print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections

import math

n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]


def katamuki(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    x, y = (xa - xb), (ya - yb)
    dist = math.sqrt(y ** 2 + x ** 2)
    if x == 0:
        return math.inf, dist
    if y == 0:
        return 0.0, dist
    if y / x == -1.0:
        return 1.0, dist
    return y / x, dist


a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(katamuki(balls[i], balls[j]))

counts = collections.Counter(a)
print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import collections

import math

n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]


def katamuki(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    x, y = (xa - xb), (ya - yb)
    dir = math.sqrt(y ** 2 + x ** 2)
    if x == 0:
        return 1.0, dir
    if y == 0:
        return 0.0, dir
    if y / x == -1.0:
        return 1.0, dir
    return y / x, dir


a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(katamuki(balls[i], balls[j]))

counts = collections.Counter(a)
print(n - max(counts.values()))

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
balls = [tuple(map(int, input().split())) for _ in range(n)]


def katamuki(balla, ballb):
    xa, ya = balla
    xb, yb = ballb
    x, y = (xa - xb), (ya - yb)
    dir = math.sqrt(y ** 2 + x ** 2)
    if x == 0:
        return 1.0, dir
    if y == 0:
        return 0.0, dir
    if y / x == -1.0:
        return 1.0, dir
    return y / x, dir


a = []
for i in range(0, n - 1):
    for j in range(i + 1, n):
        a.append(katamuki(balls[i], balls[j]))

a.sort()
tmp = a[0]
cnt = 0
ans = []
a.append(10000000)
for i in range(len(a)):
    if a[i] == tmp:
        cnt += 1
    else:
        ans.append(cnt)
        tmp = a[i]
        cnt = 1

print(n - max(ans))