My solutions for Advent of Code 2017 in Python.
Special thanks to Erisc Wastl and the rest of the AoC team for such an awesome set of challenges!
- Day 1: Inverse Captcha (code)
- Day 2: Corruption Checksum (code)
- Day 3: Spiral Memory (code)
- Day 4: High-Entropy Passphrases (code)
- Day 5: A Maze of Twisty Trampolines, All Alike (code)
- Day 6: Memory Reallocation (code)
- Day 7: Recursive Circus (code)
- Day 8: I Heard You Like Registers (code)
- Day 9: Stream Processing (code)
- Day 10: Knot Hash (code)
- Day 11: Hex Ed (code)
- Day 12: Digital Plumber (code)
- Day 13: Packet Scanners (code)
- Day 14: Disk Defragmentation (code)
- Day 15: Dueling Generators (code)
- Day 16: Permutation Promenade (code)
- Day 17: Spinlock (code)
- Day 18: Duet (code)
- Day 19: A Series of Tubes (code)
- Day 20: Particle Swarm (code)
- Day 21: Fractal Art (code)
- Day 22: Sporifica Virus (code)
- Day 23: Coprocessor Conflagration (code) (image)
- Day 24: Electromagnetic Moat (code)
- Day 25: The Halting Problem (code)
The main program of this project is adventofcode.py. You must use this program to run any day puzzle. Usage is pretty straightforward. Note that DAY can be any number from 1 to 25. You can find a sample of the ouput in output.txt.
usage: adventofcode.py [-h] [-d DAY]
Run Advent of Code 2017
optional arguments:
-h, --help show this help message and exit
-d DAY, --day DAY day to run (all by default)
I only used built-in modules, so it should be easy to run the program in your local machine. Just note that Python3 is required. However, to ensure that indeed the program works, I have dockerized the program.
git clone https://github.com/EikaNN/AdventOfCode2017.git
cd AdventOfCode2017/adventofcode
python adventofcode.py
git clone https://github.com/EikaNN/AdventOfCode2017.git
cd AdventOfCode2017/adventofcode
python adventofcode.py -d DAY
If you want to use Docker, there are two docker images available. The first one uses Python while the second one uses PyPy, which speeds up considerably the execution.
The following table shows how much it takes to run all days in both Python and Pypy, and the performance gain is substantial, especially considering that no source code modifications were needed!
Python | PyPy |
---|---|
9min44s | 1min20s |
git clone https://github.com/EikaNN/AdventOfCode2017.git
cd AdventOfCode2017/docker
./docker_python.sh -d DAY
git clone https://github.com/EikaNN/AdventOfCode2017.git
cd AdventOfCode2017/docker
./docker_python.sh
git clone https://github.com/EikaNN/AdventOfCode2017.git
cd AdventOfCode2017/docker
./docker_pypy.sh -d DAY
git clone https://github.com/EikaNN/AdventOfCode2017.git
cd AdventOfCode2017/docker
./docker_pypy.sh