Пример #1
0
    95
    102
    117
    150
    182
    127
    219
    299
    277
    309
    576
    """
).strip()


if __name__ == "__main__":
    advent.setup()
    advent.test(
        functools.partial(main, preamble_length=5),
        advent.TestCase(
            input=SAMPLE_INPUT,
            expected_part_1=127,
            expected_part_2=62,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Пример #2
0
    mem[8] = 0
    """).strip()

SAMPLE_INPUT_2 = textwrap.dedent(r"""
    mask = 000000000000000000000000000000X1001X
    mem[42] = 100
    mask = 00000000000000000000000000000000X0XX
    mem[26] = 1
    """).strip()

if __name__ == "__main__":
    advent.setup()
    advent.test(
        main,
        # advent.TestCase(
        #     input=SAMPLE_INPUT,
        #     expected_part_1=165,
        #     expected_part_2=None,
        # ),
        advent.TestCase(
            input=SAMPLE_INPUT_2,
            expected_part_1=None,
            expected_part_2=208,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Пример #3
0
        q = a // b
        a, b = b, a%b
        x0, x1 = x1 - q * x0, x0
    if x1 < 0: x1 += b0
    return x1


SAMPLE_INPUT = textwrap.dedent(
    r"""
    939
    7,13,x,x,59,x,31,19
    """
).strip()


if __name__ == "__main__":
    advent.setup()
    advent.test(
        main,
        advent.TestCase(
            input=SAMPLE_INPUT,
            expected_part_1=295,
            expected_part_2=None,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Пример #4
0
from pathlib import Path
from typing import Any
from typing import Tuple

import advent


def main(s: str) -> Tuple[Any, Any]:
    part1 = None
    part2 = None

    return part1, part2


if __name__ == "__main__":
    advent.test(
        main,
        advent.TestCase(
            input="",
            expected_part_1="",
            expected_part_2="",
        ),
    )

    input_file = Path(__file__).parent.absolute() / "input.txt"
    part1, part2 = main(input_file.read_text())
    if part1:
        print(f"Part 1: {part1}")
    if part2:
        print(f"Part 2: {part2}")
Пример #5
0
    r"""
    L.LL.LL.LL
    LLLLLLL.LL
    L.L.L..L..
    LLLL.LL.LL
    L.LL.LL.LL
    L.LLLLL.LL
    ..L.L.....
    LLLLLLLLLL
    L.LLLLLL.L
    L.LLLLL.LL
    """
).strip()


if __name__ == "__main__":
    advent.setup()
    advent.test(
        main,
        advent.TestCase(
            input=SAMPLE_INPUT,
            expected_part_1=37,
            expected_part_2=26,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Пример #6
0
    17
    7
    9
    4
    2
    34
    10
    3
    """).strip()

if __name__ == "__main__":
    advent.setup()
    advent.test(
        main,
        advent.TestCase(
            input=SAMPLE_INPUT_1,
            expected_part_1=35,
            expected_part_2=8,
        ),
        advent.TestCase(
            input=SAMPLE_INPUT_2,
            expected_part_1=220,
            expected_part_2=19208,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Пример #7
0
    return part1, part2


SAMPLE_INPUT = textwrap.dedent(r"""
    nop +0
    acc +1
    jmp +4
    acc +3
    jmp -3
    acc -99
    acc +1
    jmp -4
    acc +6
    """).strip()

if __name__ == "__main__":
    advent.setup()
    advent.test(
        main,
        advent.TestCase(
            input=SAMPLE_INPUT,
            expected_part_1=5,
            expected_part_2=8,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Пример #8
0
    part1 = None
    part2 = actual_ship.manhattan_distance

    return part1, part2


SAMPLE_INPUT = textwrap.dedent(r"""
    F10
    N3
    F7
    R90
    F11
    """).strip()

if __name__ == "__main__":
    advent.setup()
    advent.test(
        main,
        advent.TestCase(
            input=SAMPLE_INPUT,
            # expected_part_1=25,
            expected_part_1=None,
            expected_part_2=286,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )