Silly little Rube Goldberg machine. Nothing intelligent to see here.
- clang
- GNU make
- python3 development headers (3.10, 3.11, or 3.12), e.g. python3-dev on Ubuntu and Debian or python312-devel on openSUSE.
- Build solutions
make py_aoc
- Put inputs under
./txt/input/2022/??
and solve (for example day 1) using:make run_d01
./run_in_docker.bash
py_aoc
embeds the Python interpreter and runs its entrypoint:
> ./out/py_aoc
Python 3.11.0 (main, Dec 15 2022, 19:30:38) [Clang 11.0.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hi")
hi
In addition to being a normal Python interpreter, py_aoc
defines a Python builtin-module named aoc_solve
containing a single function named y2022
.
The function takes a single integer argument between 1 to 25 for the Advent of Code 2022 challenge to solve.
For example, solving day 2:
> ./out/py_aoc -c "from aoc_solve import y2022; print(y2022(2))"
0.4 ms
15632 14416
Steps in more detail:
- Read the entire UTF-8 input file into a single Python
str
. - Pass input
str
as argument to the solver function. - Compute numerical solutions to part 1 and 2, then format the numbers into a single space-separated
str
. - Cleanup refcounts, return the solution, and print to stdout.