diff --git a/day16.py b/day16.py index 373dc9c..cd3f5a2 100644 --- a/day16.py +++ b/day16.py @@ -1,6 +1,6 @@ from math import prod from tools.aoc import AOCDay -from typing import Any, List +from typing import Any class Packet: @@ -15,11 +15,11 @@ class Packet: def __parse(self): if self.p_type == 4: - while self.packet_str[self.p_len] == "1": + while True: self.value = self.value * 16 + int(self.packet_str[self.p_len + 1:self.p_len + 5], 2) self.p_len += 5 - self.value = self.value * 16 + int(self.packet_str[self.p_len + 1:self.p_len + 5], 2) - self.p_len += 5 + if self.packet_str[self.p_len - 5] == "0": + break else: op_type = self.packet_str[self.p_len] self.p_len += 1