Day 16 (removed unused lines)

This commit is contained in:
Sebastian Seedorf
2020-12-16 17:48:26 +01:00
parent e22cdf5ee5
commit adb0edd038
2 changed files with 4 additions and 14 deletions

View File

@@ -5,9 +5,6 @@ import numpy as np
lines = (x.strip() for x in open("input.txt")) lines = (x.strip() for x in open("input.txt"))
REGEX_RANGES = re.compile(r"^([a-z ]+): (\d+)-(\d+) or (\d+)-(\d+)$") 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 = [] groups = []
tickets = [] tickets = []
@@ -15,12 +12,9 @@ for line in lines:
match = REGEX_RANGES.match(line) match = REGEX_RANGES.match(line)
if match: if match:
m_groups = match.groups() m_groups = match.groups()
names = np.append(names, [m_groups[0]])
groups.append(list(map(int, m_groups[1:]))) groups.append(list(map(int, m_groups[1:])))
match = REGEX_TICKET.match(line) if "," in line:
if match: tickets.append(tuple(map(int, line.split(','))))
ticket = tuple(map(int, line.split(',')))
tickets.append(ticket)
groups = np.array(groups) groups = np.array(groups)
tickets = np.array(tickets, dtype=np.int32) tickets = np.array(tickets, dtype=np.int32)

View File

@@ -5,8 +5,6 @@ import numpy as np
lines = (x.strip() for x in open("input.txt")) lines = (x.strip() for x in open("input.txt"))
REGEX_RANGES = re.compile(r"^([a-z ]+): (\d+)-(\d+) or (\d+)-(\d+)$") 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) names = np.array([], dtype=str)
groups = [] groups = []
tickets = [] tickets = []
@@ -17,10 +15,8 @@ for line in lines:
m_groups = match.groups() m_groups = match.groups()
names = np.append(names, [m_groups[0]]) names = np.append(names, [m_groups[0]])
groups.append(list(map(int, m_groups[1:]))) groups.append(list(map(int, m_groups[1:])))
match = REGEX_TICKET.match(line) if "," in line:
if match: tickets.append(tuple(map(int, line.split(','))))
ticket = tuple(map(int, line.split(',')))
tickets.append(ticket)
groups = np.array(groups) groups = np.array(groups)
tickets = np.array(tickets, dtype=np.int32) tickets = np.array(tickets, dtype=np.int32)