Taddeus Kroes пре 7 година
родитељ
комит
0d916ae21c
4 измењених фајлова са 1481 додато и 0 уклоњено
  1. 118 0
      24_immunesys.py
  2. 35 0
      25_constellations.py
  3. 23 0
      input/24
  4. 1305 0
      input/25

+ 118 - 0
24_immunesys.py

@@ -0,0 +1,118 @@
+#!/usr/bin/env python3
+import sys
+import re
+from operator import attrgetter
+
+class Units:
+    def __init__(self, team, n, hp, dmg, dmgty, initiative, immune=[], weak=[]):
+        self.team = team
+        self.n = n
+        self.hp = hp
+        self.dmg = dmg
+        self.dmgty = dmgty
+        self.initiative = initiative
+        self.immune = immune
+        self.weak = weak
+
+    def copy(self):
+        return self.__class__(self.team, self.n, self.hp, self.dmg,
+                self.dmgty, self.initiative, [i for i in self.immune],
+                [w for w in self.weak])
+
+    @classmethod
+    def parse(cls, line, team):
+        pat = r'(\d+) units each with (\d+) hit points (?:\(([^)]*)\) )?' \
+              r'with an attack that does (\d+) (\w+) damage at initiative (\d+)'
+        n, hp, special, dmg, dmgty, init = re.match(pat, line).groups()
+        group = cls(team, int(n), int(hp), int(dmg), dmgty, int(init))
+        if special:
+            for spec in special.split('; '):
+                ty, rest = spec.split(' to ')
+                setattr(group, ty, rest.split(', '))
+        return group
+
+    def effective_power(self):
+        return self.n * self.dmg
+
+    def alive(self):
+        return self.n > 0
+
+    def pick_order(self):
+        return self.effective_power(), self.initiative
+
+    def damage_to(self, other):
+        if self.dmgty in other.immune:
+            return 0
+        if self.dmgty in other.weak:
+            return self.effective_power() * 2
+        return self.effective_power()
+
+    def attack(self, defender):
+        nkilled = min(defender.n, self.damage_to(defender) // defender.hp)
+        defender.n -= nkilled
+        return nkilled
+
+def parse(f):
+    team = re.match(r'(.+):', f.readline()).group(1)
+    for line in sys.stdin:
+        line = line.rstrip()
+        if line.endswith(':'):
+            team = line[:-1]
+        elif line:
+            yield Units.parse(line, team)
+
+def fight(groups):
+    # target selection phase
+    groups.sort(key=Units.pick_order, reverse=True)
+    chosen = [False] * len(groups)
+    picks = {}
+
+    for attacker in groups:
+        opts = []
+        for i, defender in enumerate(groups):
+            if defender.team != attacker.team and not chosen[i]:
+                damage = attacker.damage_to(defender)
+                if damage:
+                    opts.append((damage, defender.effective_power(), defender.initiative, i))
+        if opts:
+            target = max(opts)[-1]
+            if not chosen[target]:
+                chosen[target] = True
+                picks[attacker] = groups[target]
+
+    # attack phase
+    groups.sort(key=attrgetter('initiative'), reverse=True)
+
+    progress = False
+    for attacker in groups:
+        if attacker.alive() and attacker in picks:
+            progress |= attacker.attack(picks[attacker]) > 0
+
+    return progress, [g for g in groups if g.alive()]
+
+def simulate(initial, boost):
+    groups = [g.copy() for g in initial]
+    for g in groups:
+        if g.team == 'Immune System':
+            g.dmg += boost
+
+    while len(set(u.team for u in groups)) > 1:
+        progress, groups = fight(groups)
+        if not progress:
+            return 'Infection', 0
+
+    return groups[0].team, sum(g.n for g in groups)
+
+initial = list(parse(sys.stdin))
+
+# part 1
+winner, units = simulate(initial, 0)
+assert winner == 'Infection'
+print(units)
+
+# part 2
+boost = 0
+while winner != 'Immune System':
+    boost += 1
+    winner, units = simulate(initial, boost)
+print(units)

+ 35 - 0
25_constellations.py

@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+import sys
+from itertools import combinations, product
+
+def dist(a, b):
+    return sum(abs(y - x) for x, y in zip(a, b))
+
+
+# iteratively make the first constellations
+const = []
+for line in sys.stdin:
+    a = tuple(map(int, line.rstrip().split(',')))
+    for c in const:
+        if any(dist(a, b) <= 3 for b in c):
+            c.append(a)
+            break
+    else:
+        const.append([a])
+
+# merge constellations where possible
+prevlen = None
+
+while len(const) != prevlen:
+    prevlen = len(const)
+
+    for i, j in combinations(range(prevlen), 2):
+        c1 = const[i]
+        c2 = const[j]
+        if any(dist(a, b) <= 3 for a, b in product(c1, c2)):
+            const[i] = c1 + c2
+            const[j] = []
+
+    const = list(filter(None, const))
+
+print(len(const))

+ 23 - 0
input/24

@@ -0,0 +1,23 @@
+Immune System:
+2317 units each with 2435 hit points (weak to bludgeoning, cold; immune to fire) with an attack that does 10 cold damage at initiative 2
+967 units each with 5447 hit points (immune to cold; weak to slashing, radiation) with an attack that does 50 fire damage at initiative 3
+851 units each with 11516 hit points with an attack that does 106 cold damage at initiative 7
+4857 units each with 2273 hit points with an attack that does 4 radiation damage at initiative 17
+1929 units each with 2540 hit points (immune to fire) with an attack that does 12 radiation damage at initiative 4
+4673 units each with 3705 hit points with an attack that does 5 fire damage at initiative 16
+2312 units each with 6698 hit points (immune to radiation) with an attack that does 26 slashing damage at initiative 15
+3526 units each with 3316 hit points (weak to cold) with an attack that does 9 fire damage at initiative 20
+3207 units each with 2502 hit points (weak to cold, fire; immune to slashing) with an attack that does 6 radiation damage at initiative 11
+5213 units each with 9656 hit points (immune to radiation) with an attack that does 17 fire damage at initiative 6
+
+Infection:
+8026 units each with 11443 hit points (immune to bludgeoning, slashing, fire) with an attack that does 2 cold damage at initiative 14
+4465 units each with 36617 hit points (weak to radiation) with an attack that does 16 cold damage at initiative 1
+378 units each with 18782 hit points (weak to radiation; immune to fire) with an attack that does 98 slashing damage at initiative 10
+1092 units each with 17737 hit points (immune to bludgeoning, fire; weak to slashing) with an attack that does 25 slashing damage at initiative 18
+270 units each with 19361 hit points (weak to bludgeoning, slashing) with an attack that does 104 fire damage at initiative 9
+2875 units each with 30650 hit points (weak to fire) with an attack that does 16 slashing damage at initiative 5
+1024 units each with 43191 hit points (weak to bludgeoning, cold) with an attack that does 76 cold damage at initiative 12
+892 units each with 10010 hit points (immune to radiation; weak to slashing) with an attack that does 15 radiation damage at initiative 19
+2708 units each with 40667 hit points (immune to cold; weak to fire) with an attack that does 21 cold damage at initiative 13
+780 units each with 44223 hit points (immune to bludgeoning, radiation, slashing) with an attack that does 104 cold damage at initiative 8

+ 1305 - 0
input/25

@@ -0,0 +1,1305 @@
+3,-2,5,6
+-6,-8,8,7
+6,-6,-7,6
+-1,4,1,0
+4,-2,-6,-7
+-4,2,6,1
+3,2,-5,5
+0,3,-5,-1
+0,-3,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