From adb0edd0380d5694dd9e7dff8296cb71cfe1bfe9 Mon Sep 17 00:00:00 2001 From: Sebastian Seedorf Date: Wed, 16 Dec 2020 17:48:26 +0100 Subject: [PATCH] Day 16 (removed unused lines) --- day16/part1-v2.py | 10 ++-------- day16/part2-v2.py | 8 ++------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/day16/part1-v2.py b/day16/part1-v2.py index ba02c80..8c82c55 100644 --- a/day16/part1-v2.py +++ b/day16/part1-v2.py @@ -5,9 +5,6 @@ import numpy as np lines = (x.strip() for x in open("input.txt")) REGEX_RANGES = re.compile(r"^([a-z ]+): (\d+)-(\d+) or (\d+)-(\d+)$") -REGEX_TICKET = re.compile(r"^(\d+,)*\d+$") -read_step = 0 -names = np.array([], dtype=str) groups = [] tickets = [] @@ -15,12 +12,9 @@ for line in lines: match = REGEX_RANGES.match(line) if match: m_groups = match.groups() - names = np.append(names, [m_groups[0]]) groups.append(list(map(int, m_groups[1:]))) - match = REGEX_TICKET.match(line) - if match: - ticket = tuple(map(int, line.split(','))) - tickets.append(ticket) + if "," in line: + tickets.append(tuple(map(int, line.split(',')))) groups = np.array(groups) tickets = np.array(tickets, dtype=np.int32) diff --git a/day16/part2-v2.py b/day16/part2-v2.py index d774d6c..1f1d6b0 100644 --- a/day16/part2-v2.py +++ b/day16/part2-v2.py @@ -5,8 +5,6 @@ import numpy as np lines = (x.strip() for x in open("input.txt")) REGEX_RANGES = re.compile(r"^([a-z ]+): (\d+)-(\d+) or (\d+)-(\d+)$") -REGEX_TICKET = re.compile(r"^(\d+,)*\d+$") -read_step = 0 names = np.array([], dtype=str) groups = [] tickets = [] @@ -17,10 +15,8 @@ for line in lines: m_groups = match.groups() names = np.append(names, [m_groups[0]]) groups.append(list(map(int, m_groups[1:]))) - match = REGEX_TICKET.match(line) - if match: - ticket = tuple(map(int, line.split(','))) - tickets.append(ticket) + if "," in line: + tickets.append(tuple(map(int, line.split(',')))) groups = np.array(groups) tickets = np.array(tickets, dtype=np.int32)