コード例 #1
0
ファイル: test_examples.py プロジェクト: oeick/advent-of-code
 def test_part_1(self):
     result = main.solve_part_1({
         '1': ['trees: 7', 'perfumes: 2', 'akitas: 5'],
         '2': ['children: 3', 'goldfish: 4', 'vizslas: 0'],
         '3': ['children: 3', 'goldfish: 5', 'vizslas: 0']
     })
     self.assertEqual(3, result)
コード例 #2
0
ファイル: test_examples.py プロジェクト: oeick/advent-of-code
 def test_solve_part_1(self):
     self.assertEqual(
         4,
         main.solve_part_1(
             [Replacement('H', 'HO'),
              Replacement('H', 'OH'),
              Replacement('O', 'HH')],
             'HOH'))
コード例 #3
0
 def test_part_1_example(self):
     example = r"""
     ""
     "abc"
     "aaa\"aaa"
     "\x27"
     """
     lines = [line.strip() for line in example.splitlines() if line.strip()]
     self.assertEqual(12, main.solve_part_1(lines))
コード例 #4
0
ファイル: test_examples.py プロジェクト: oeick/advent-of-code
 def test_solve_part_1(self):
     self.assertEqual(
         4,
         main.solve_part_1(main.parse_grid([
             '.#.#.#',
             '...##.',
             '#....#',
             '..#...',
             '#.#..#',
             '####..']),
             steps=4)
     )
コード例 #5
0
 def test_example(self):
     example = """
         Alice would gain 54 happiness units by sitting next to Bob.
         Alice would lose 79 happiness units by sitting next to Carol.
         Alice would lose 2 happiness units by sitting next to David.
         Bob would gain 83 happiness units by sitting next to Alice.
         Bob would lose 7 happiness units by sitting next to Carol.
         Bob would lose 63 happiness units by sitting next to David.
         Carol would lose 62 happiness units by sitting next to Alice.
         Carol would gain 60 happiness units by sitting next to Bob.
         Carol would gain 55 happiness units by sitting next to David.
         David would gain 46 happiness units by sitting next to Alice.
         David would lose 7 happiness units by sitting next to Bob.
         David would gain 41 happiness units by sitting next to Carol.
         """
     lines = [line.strip() for line in example.splitlines() if line.strip()]
     result = main.solve_part_1(lines)
     self.assertEqual(330, result)
コード例 #6
0
 def test_solve_part_1(self):
     self.assertEqual(2, main.solve_part_1([(2, 4, 3), (1, 9, 1),
                                            (7, 6, 5)]))
コード例 #7
0
ファイル: test_examples.py プロジェクト: oeick/advent-of-code
 def test_example_part1(self, example, floor):
     self.assertEqual(floor, main.solve_part_1(example))