2018 day 23 part 1
This commit is contained in:
parent
6c3aec3d6e
commit
25bd810886
32
2018/d23.py
Normal file
32
2018/d23.py
Normal file
@ -0,0 +1,32 @@
|
||||
from lib import get_data, str_to_ints
|
||||
|
||||
def dist(a, b):
|
||||
return sum(abs(x - y) for x, y in zip(a[:3], b[:3]))
|
||||
|
||||
data = get_data(__file__)
|
||||
data = """pos=<10,12,12>, r=2
|
||||
pos=<12,14,12>, r=2
|
||||
pos=<16,12,12>, r=4
|
||||
pos=<14,14,14>, r=6
|
||||
pos=<50,50,50>, r=200
|
||||
pos=<10,10,10>, r=5
|
||||
"""
|
||||
|
||||
max_bot = None
|
||||
bots = []
|
||||
for line in data.splitlines():
|
||||
xs = str_to_ints(line)
|
||||
if max_bot is None:
|
||||
max_bot = xs
|
||||
elif xs[3] > max_bot[3]:
|
||||
max_bot = xs
|
||||
bots.append(xs)
|
||||
|
||||
assert max_bot is not None
|
||||
|
||||
t = 0
|
||||
r = max_bot[3]
|
||||
for bot in bots:
|
||||
if dist(bot, max_bot) <= r:
|
||||
t += 1
|
||||
print(t)
|
Loading…
Reference in New Issue
Block a user