51 lines
1.3 KiB
Python
Executable File
51 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
|
|
def read_input():
|
|
result = []
|
|
with open('input.txt', 'r') as f:
|
|
for line in f:
|
|
result.append([ int(x) for x in line.split(', ')])
|
|
return result
|
|
|
|
MARGIN=1
|
|
coord = read_input()
|
|
coord_min = [ min([x[0] for x in coord]), min([x[1] for x in coord]) ]
|
|
coord_max = [ max([x[0] for x in coord]), max([x[1] for x in coord]) ]
|
|
|
|
finite = [True] * len(coord)
|
|
area_size = [0] * len(coord)
|
|
|
|
|
|
for x in range(coord_min[0]-MARGIN, coord_max[0]+MARGIN+1):
|
|
for y in range(coord_min[1]-MARGIN, coord_max[1]+MARGIN+1):
|
|
border_x = False
|
|
border_y = False
|
|
if x in (coord_min[0]-MARGIN, coord_max[0]+MARGIN):
|
|
border_x = True
|
|
if y in (coord_min[1]-MARGIN, coord_max[1]+MARGIN):
|
|
border_y = True
|
|
|
|
best = (None, None) #loc, distance
|
|
for loc_i, loc in enumerate(coord):
|
|
d = abs(x - loc[0]) + abs(y - loc[1])
|
|
if best[1] is None:
|
|
best = (loc_i, d)
|
|
continue
|
|
if best[1] > d:
|
|
best = (loc_i, d)
|
|
continue
|
|
if best[1] == d:
|
|
best = (None, d)
|
|
continue
|
|
|
|
if best[0] is None:
|
|
continue
|
|
|
|
if border_x or border_y:
|
|
finite[best[0]] = False
|
|
area_size[best[0]] += 1
|
|
|
|
|
|
print(max([v for k,v in enumerate(area_size) if finite[k]]))
|