Ejemplo n.º 1
0
def part1(inp: list[str]) -> None:
    tiles = parse_tiles(inp)
    img = Image()
    img.fit(tiles)

    edge_ids = map(lambda tile: tile.id, img.get_edge_tiles())
    print(reduce(operator.mul, edge_ids))
Ejemplo n.º 2
0
def part2(inp: list[str]) -> None:
    tiles = parse_tiles(inp)
    img = Image()
    img.fit(tiles)

    combined = img.get_combined()
    for i, variation in enumerate(get_variations(combined)):
        monster_count = count_monsters(variation)
        if monster_count > 1:
            total_count = sum(sum(row) for row in variation)
            print(total_count - monster_count * 15)
            return