summaryrefslogtreecommitdiff
path: root/2018/aoc2018-d23-1.py
diff options
context:
space:
mode:
authorblenovo <bk@gmail.com>2025-08-14 17:27:36 +0200
committerblenovo <bk@gmail.com>2025-08-14 17:27:36 +0200
commitedf82358166db84f74419f9a83d328390cc6b356 (patch)
tree5dfb17b0f74a1035451b72162cac9184dc0d22e0 /2018/aoc2018-d23-1.py
parent0a441ce2306ae9edefb009fbc0596f4d511cdc7f (diff)
second to last star of 2018
Diffstat (limited to '2018/aoc2018-d23-1.py')
-rw-r--r--2018/aoc2018-d23-1.py47
1 files changed, 0 insertions, 47 deletions
diff --git a/2018/aoc2018-d23-1.py b/2018/aoc2018-d23-1.py
deleted file mode 100644
index a387337..0000000
--- a/2018/aoc2018-d23-1.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#advent of code 2018
-#day 23
-#part 1 and part 2
-
-
-f = open("input.txt",'r');
-Testing = False;
-#Testing = True;
-if Testing:
- f.close();
- f = open("testinput.txt",'r');
-
-def manhattan(pos1, pos2):
- mx = abs(pos1[0] - pos2[0]);
- my = abs(pos1[1] - pos2[1]);
- mz = abs(pos1[2] - pos2[2]);
- return mx + my + mz;
-
-class nanobot:
- def __init__(self, pos, r):
- self.pos = pos;
- self.radius = r;
- def __str__(self):
- return f'pos={self.pos}, r={self.radius}';
-
-bots = [];
-for l in f:
- l = l.replace("<","(");
- l = l.replace(">",")");
- l = l.replace("r=","");
- l = l.replace("pos=","");
- p, r = eval(l);
- bots.append(nanobot(p,r));
-
-f.close();
-
-strongest_radius = 0;
-strongest_pos = None;
-for bot in bots:
- if bot.radius > strongest_radius:
- strongest_radius = bot.radius;
- strongest_pos = bot.pos;
-
-part1 = 0;
-for bot in bots:
- if (manhattan(strongest_pos, bot.pos) <= strongest_radius): part1 += 1;
-print("part1 = ", part1);