Day 16 (removed unused lines)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user