logan_2023/day5
2023-12-06 01:24:01 -07:00
..
.gitattributes Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
.gitignore Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
answer1 Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
answer2 Added Day 5 Part 2 answer 2023-12-06 00:56:44 -07:00
d5p1.gd D5: Made Godot scripts runnable from the command line 2023-12-06 01:23:40 -07:00
d5p1.py Added Day 5 Python versions 2023-12-06 00:56:52 -07:00
d5p2.gd D5: Made Godot scripts runnable from the command line 2023-12-06 01:23:40 -07:00
d5p2.py Added Day 5 Python versions 2023-12-06 00:56:52 -07:00
icon.svg Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
icon.svg.import Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
input.txt Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
node_3d.tscn Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
project.godot Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00
README.md Added (back?) README 2023-12-06 01:24:01 -07:00
sample.txt Added Day 5 Part 1 (Godot) 2023-12-05 22:09:39 -07:00

AoC 2023 Day 5 (GDScript & Python)

Today's code was written for Godot, somewhat lazily.

I also made a port to Python because I'm lazy and didn't feel like waiting all day to test the script (see commentary for more info). The Python versions are a direct port of the GDScript versions, so there's some seemingly strange choices in them.

Requirements:

  • Godot: Godot 4 Editor or a compiled Godot 4 based project
  • Python: Python ≥ 3.6 compatible interpreter

Usage:

  • To use the Godot version, run godot --headless -s d5p1.gd -- $INPUT where $INPUT is the path to your input file relative to the project root. Your input file should have an extension, ideally .txt.
  • To use the Python version, run python3 d5p2.py $INPUT.

Commentary (Spoilers):

**Reveal** Godot fought me at many points. It seems to have some behavior inconsistencies, as well as some poorly made functions (namely range). Admittedly it's not meant to do this, but I feel like it shouldn't be this bad.

Part 2 is not great. Originally it was written such that in order to find the answer, 1,809,081,164 iterations of the main while loop were required. This was definitely not good. On my 3700X it would've taken ~8h22m to find the answer. Fortunately I thought of a better way while porting Part 2 to Python. Instead of 1,809,081,164 iterations, it instead now takes 34,039,469 iterations (53x improvement!). Sadly, it's also slower per iteration now. I still feel like there is a far faster way to determine the answer, but at least it can finish in less time than it takes to port it to another language.

The Python versions are as close to 1:1 with the GDScript versions as I can reasonably manage. Their biggest advantage is that they're way faster, even with stock Python.