def process_input(self, filename): raw_rules, raw_my_ticket, raw_nearby_tickets = \ read_line_groups(filename) # parse the rules self.rules = [] self.rule_names = [] for line in raw_rules: parts = line.split(':') rs = parts[1].split('or') cr = [] for r in rs: rg = [int(x) for x in r.strip().split('-')] cr.append(rg) self.rules.append(cr) self.rule_names.append(parts[0]) # parse my ticket self.my_ticket = [int(n) for n in raw_my_ticket[1].split(',')] # parse nearby tickets self.nearby_tickets = [] for line in raw_nearby_tickets[1:]: self.nearby_tickets.append([int(n) for n in line.split(',')]) return
def __init__(self, filename): line_groups = read_line_groups(filename) self.numbers = list(map(int, line_groups[0][0].split(","))) cards = [] for card_input in line_groups[1:]: card = [] for line in card_input: card.append(list(map(int, line.split()))) cards.append(card) self.cards = np.array(cards) self.n_cards, self.n_rows, self.n_cols = self.cards.shape
def __init__(self, filename): self.custom_sets = read_line_groups(filename)
def __init__(self, filename): self.line_groups = read_line_groups(filename) self.process()
def __init__(self, filename): input_lines = read_line_groups(filename) self.start_deck1 = deque(map(int, input_lines[0][1:])) self.start_deck2 = deque(map(int, input_lines[1][1:]))