示例#1
0
.#..######
..#.......
######....
####.#..#.
.#...#.##.
#.#####.##
..#.###...
..#.......
..#.###..."""

else:
    # Current file filepath
    thisfile = current_file(__file__)

    # AOC day number
    DAY_NO: int = day_number(thisfile.stem)

    raw_data = read_data(f"day-{DAY_NO}-input.txt")

# Replace newline characters
raw_data = raw_data.replace(r"\r\n", "\n")

# raw_data = read_data(f"day-20-input.txt")

tile_pattern = r"Tile\s(\d+):\s+?"
ptitle = re.compile(tile_pattern)


class Grids:
    __slots__ = "titles", "tiles", "enum_titles", "enum_tiles", "title_tile_dict"
示例#2
0
Date created: 2020-12-02
URL: https://adventofcode.com

Contributor(s):
    Mark M.
"""

from pathlib import Path
from utils import current_file, day_number, read_data

# Current file filepath
thisfile = current_file(__file__)
print(thisfile)

# AOC day number
DAY_NO = day_number(thisfile.stem)

# Import data and split each line in the data file.
data_file = f"day-{DAY_NO}-input.txt"
raw_data = read_data(data_file)
data = sorted(list(map(lambda x: int(x), raw_data.splitlines())))


def prod(iterable):
    """Product of values in array."""
    if len(iterable) == 0:
        return 1
    else:
        return iterable[0] * prod(iterable[1:])