コード例 #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))
コード例 #2
0
def main():
    to_input = "../input"
    path = local_path(__file__, to_input)

    config = get_lines(path)

    print(count_living_cells(config))
コード例 #3
0
def main():
    rel_route_input = "../input"
    path = local_path(__file__, rel_route_input)

    instructions = get_lines(path)

    print(sum_up_values(instructions))
コード例 #4
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)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
def main():
    to_input = "../input"
    path = local_path(__file__, to_input)

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