예제 #1
0
def test_grid_vis():
    test_output = '''##.#.#..
                     .#.#.#.#
                     ....#.#.
                     #.#.##.#
                     .##.#...
                     ##..#..#
                     .#...#..
                     ##.#.##.'''
    key = 'flqrgnkx'
    bits = day14.build_grid(256, key)
    test_output = test_output.replace('#', '1')
    test_output = test_output.replace('.', '0')
    test_output = test_output.split('\n')
    test_output = [s.strip() for s in test_output]
    print([b[0:8] for b in bits[0:7]])
    print(test_output)
    assert all([b.startswith(s) for b, s in zip(bits, test_output)])
예제 #2
0
def test_count_used(key_str: str, expected_count: int):
    assert expected_count == count_used(build_grid(key_str))
예제 #3
0
def test_part2():
    key = 'jzgqcdpd'
    bits = day14.build_grid(128, key)
    assert day14.count_regions(bits) == 1212
예제 #4
0
def test_count_regions():
    key = 'flqrgnkx'
    bits = day14.build_grid(128, key)
    assert day14.count_regions(bits) == 1242
예제 #5
0
def test_part1():
    key = 'jzgqcdpd'
    bits = day14.build_grid(128, key)
    assert day14.count_used_bits(bits) == 8074
예제 #6
0
def test_used_bits():
    key = 'flqrgnkx'
    bits = day14.build_grid(128, key)
    assert day14.count_used_bits(bits) == 8108