Exemplo n.º 1
0
def main():
    rel_route_input = "../input"
    path = local_path(__file__, rel_route_input)

    values = [int(x) for x in get_lines(path)[0].split(',')]

    print(get_nth_value(values, 30000000))
Exemplo n.º 2
0
def main():
    to_input = "../input"
    path = local_path(__file__, to_input)

    my_input = parse_input(path)

    print(multiply_departure(*my_input))
Exemplo n.º 3
0
def main():
    rel_route_input = "../input"
    path = local_path(__file__, rel_route_input)

    instructions = get_lines(path)

    print(sum_up_values(instructions))
Exemplo n.º 4
0
def main():
    to_input = "../input"
    path = local_path(__file__, to_input)

    config = get_lines(path)

    print(count_living_cells(config))
Exemplo n.º 5
0
def main():
    to_input = "../input"
    path = local_path(__file__, to_input)

    rules, _, nearby_tickets = parse_input(path)

    print(sum_up_not_valid_values(rules, nearby_tickets))
Exemplo n.º 6
0
    def test_first_example(self):
        to_input = "../smallinput"
        path = local_path(__file__, to_input)

        config = get_lines(path)

        should_be = 112
        self.assertEqual(count_living_cells(config), should_be)
Exemplo n.º 7
0
    def sums_up_correctly(self):
        rel_route_input = "../smallinput1"
        path = local_path(__file__, rel_route_input)

        instructions = get_lines(path)

        real_sum = 165
        self.assertEqual(sum_up_values(instructions), real_sum)
Exemplo n.º 8
0
    def test_first_example(self):
        to_input = "../smallinput"
        path = local_path(__file__, to_input)

        rules, _, nearby_tickets = parse_input(path)

        should_be = 71
        self.assertEqual(should_be,
                         sum_up_not_valid_values(rules, nearby_tickets))
Exemplo n.º 9
0
    def test_first_example(self):
        to_input = "../smallinput2"
        path = local_path(__file__, to_input)

        rules, _, nearby_tickets = parse_input(path)
        valid = valid_tickets(rules, nearby_tickets)

        should_be = ["row", "class", "seat"]
        self.assertEqual(fieldnames(rules, valid), should_be)
Exemplo n.º 10
0
    def test_sums_correctly(self):
        rel_route_input = '../smallinput2'
        path = local_path(__file__, rel_route_input)

        instructions = get_lines(path)

        mem = write_memory(instructions)

        s = sum(mem.values())
        actual_sum = 208

        self.assertEqual(s, actual_sum)
Exemplo n.º 11
0
def main():
    to_input = "../input"
    path = local_path(__file__, to_input)

    prec = {'+': 2, '*': 1}
    print(sum_exprs(get_lines(path), prec))