Exemplo n.º 1
0
    def test_solution(self):
        s = Solver(from_file='input/dec12.in')
        (one, two) = s.solve()
        one_alt = s.solve_part_one_alternative()

        self.assertEqual(one, 191164)
        self.assertEqual(one_alt, 191164)
        self.assertEqual(two, 87842)
Exemplo n.º 2
0
 def test_examples_for_part_two(self):
     self.assertEqual(Solver.sum_json(json.loads(
         '[1,2,3]'), exclude_red=True), 6)
     self.assertEqual(Solver.sum_json(json.loads(
         '[1,{"c":"red","b":2},3]'), exclude_red=True), 4)
     self.assertEqual(Solver.sum_json(json.loads(
         '{"d":"red","e":[1,2,3,4],"f":5}'), exclude_red=True), 0)
     self.assertEqual(Solver.sum_json(json.loads(
         '[1,"red",5]'), exclude_red=True), 6)
Exemplo n.º 3
0
 def test_example(self):
     test_input = """
         cpy 41 a
         inc a
         inc a
         dec a
         jnz a 2
         dec a
         """
     s = Solver(from_str=test_input)
     self.assertEqual(s.solve_part_one(), 42)
Exemplo n.º 4
0
 def test_examples_for_part_one(self):
     self.assertEqual(Solver.sum_json(json.loads('[1,2,3]')), 6)
     self.assertEqual(Solver.sum_json(json.loads('{"a":2,"b":4}')), 6)
     self.assertEqual(Solver.sum_json(json.loads('[[[3]]]')), 3)
     self.assertEqual(Solver.sum_json(json.loads(
         '{"a":{"b":4},"c":-1}')), 3)
     self.assertEqual(Solver.sum_json(json.loads('{"a":[-1,1]}')), 0)
     self.assertEqual(Solver.sum_json(json.loads('[-1,{"a":1}]')), 0)
     self.assertEqual(Solver.sum_json(json.loads('[]')), 0)
     self.assertEqual(Solver.sum_json(json.loads('{}')), 0)
Exemplo n.º 5
0
    def test_example_one(self):
        example_input = """
            initial state: #..#.#..##......###...###

            ...## => #
            ..#.. => #
            .#... => #
            .#.#. => #
            .#.## => #
            .##.. => #
            .#### => #
            #.#.# => #
            #.### => #
            ##.#. => #
            ##.## => #
            ###.. => #
            ###.# => #
            ####. => #
            """
        s = Solver(from_str=example_input)
        one = s.solve_part_one()
        self.assertEqual(one, 325)
Exemplo n.º 6
0
 def test_solution(self):
     (one, two) = Solver(from_file='input/december12.input').solve()
     self.assertEqual(one, 318117)
     self.assertEqual(two, 9227771)
Exemplo n.º 7
0
 def test_solution(self):
     (one, two) = Solver(from_file="input/december12.input").solve()
     self.assertEqual(one, 3738)
     self.assertEqual(two, 3900000002467)