Skip to content

Commit

Permalink
use global algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
NimVek committed Nov 23, 2023
1 parent a0e0617 commit 88c9259
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions y2020/d16/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dataclasses import dataclass
from math import prod

from aoc.lib.algorithms import possibilities_to_dict
from aoc.lib.sets import IntervalSet
from aoc.lib.solution import SolutionBase

Expand Down Expand Up @@ -57,20 +58,7 @@ def part_02(data):
idx for idx, value in enumerate(ticket) if value in values
}

translate = {}
while investigate:
translate.update(
{
code: opcodes.pop()
for code, opcodes in investigate.items()
if len(opcodes) == 1
}
)
investigate = {
code: opcodes - set(translate.values())
for code, opcodes in investigate.items()
if len(opcodes) > 1
}
translate = possibilities_to_dict(investigate)

return prod(
data.own[idx]
Expand Down

0 comments on commit 88c9259

Please sign in to comment.