Пример #1
0
    def test_part1_examples(self):
        got = part1("../../20/input_23.txt")
        want = 23
        self.assertEqual(got, want)

        got = part1("../../20/input_58.txt")
        want = 58
        self.assertEqual(got, want)
Пример #2
0
def part2(data):
    m = day20.part1(data, True)
    m2 = SeaMonsterMatrix(12, 8)
    m2.LoadFromTiles([remove_tile_border(t.data) for t in ordered_tiles(m)])
    nb_monsters = m2.DetectMonsters()
    HASHTAGS_IN_MONSTER = 15
    print('%d #\'s - %d monsters * %d = %d' %
          (m2.CountDash(), nb_monsters, HASHTAGS_IN_MONSTER, m2.CountDash() -
           (nb_monsters * 15)))
    OPERATIONS = [
        'rotate90', 'rotate90', 'rotate90', 'rotate90', 'flip_h', 'rotate90',
        'rotate90', 'rotate90', 'rotate90', 'flip_h', 'flip_v', 'rotate90',
        'rotate90', 'rotate90', 'rotate90', 'flip_v', 'flip_h', 'flip_v',
        'rotate90', 'rotate90', 'rotate90', 'rotate90'
    ]
    for op in OPERATIONS:
        getattr(m2, op)()
        nb_monsters = m2.DetectMonsters()
        print(
            '%d #\'s - %d monsters * %d = %d' %
            (m2.CountDash(), nb_monsters, HASHTAGS_IN_MONSTER, m2.CountDash() -
             (nb_monsters * 15)))
Пример #3
0
 def test_part1_on_example(self):
     input = read_inputfile("example20.txt")
     self.assertEqual(part1(input), 20899048083289)
Пример #4
0
def test_day20_part1_maze2():
    assert day20.part1(maze2) == 58
Пример #5
0
def test_day20_part1_maze1():
    assert day20.part1(maze1) == 23
Пример #6
0
def test_part1(puzzle_input, answer):
    assert part1(puzzle_input) == answer
Пример #7
0
 def test_part1(self):
     got = part1("../../20/input.txt")
     want = 490
     self.assertEqual(got, want)
Пример #8
0
 def test_part1_example2(self):
     result = day20.part1(self.example2)
     self.assertEqual(58, result)
Пример #9
0
 def test_part1_input(self):
     result = day20.part1(aoc.read_input('day20.input'))
     self.assertEqual(462, result)
Пример #10
0
def test_day20_part1():
    assert day20.part1(day20_example) == 20899048083289
Пример #11
0
 def test_part1_example1(self):
     result = day20.part1(self.example1)
     self.assertEqual(23, result)
Пример #12
0
 def test_part1(self):
     maze = get_input(20, test=1, strip=False)
     portal_names, portal_locations, _ = find_portals(maze)
     walkable = get_walkable(maze)
     self.assertEqual(part1(portal_names, portal_locations, walkable), 23)
Пример #13
0
def test_20_1_examples():
    examples = []
    for (inp, out) in examples:
        assert out == day20.part1(inp)
Пример #14
0
def test_part1_sample(sample_data):
    assert part1(sample_data) == 20899048083289
Пример #15
0
def test_part1_input(input_data):
    assert part1(input_data) == 29293767579581
Пример #16
0
 def test_part1(self):
     self.assertEqual(68781323018729, part1())