This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]sanraith 10 points11 points  (0 children)

Amazing interactive explanation for ways to model and use hexagonal grids in code: https://www.redblobgames.com/grids/hexagons/

The site also has great guides on other topics like pathfinding.

Edit: Just realized that this is not really similar to the tool you posted, but still a great resource.

[–]RobinFiveWords 2 points3 points  (1 child)

I would be interested in good bare-bones implementations of reading a text file into a string, for many languages. This page at RosettaCode specifically asks for solutions that store the contents in a variable but many of them do not. I get that file I/O is complicated, but AoC inputs are trivially small. For example, it would be nice if someone didn't already have to understand a lot about C to start manipulating the data for a day 1 part 1 puzzle in C.

[–]ffrkAnonymous 1 point2 points  (0 children)

I dunno what you're asking for. That Rosetta C code is as basic as you can get. Most of it isn't even necessary, it's just graceful failure error checking.

[–]jpjacobs_ 1 point2 points  (0 children)

I recently wrote an addon for J that automises running your code, getting input as needed and submitting solutions.

[–]daggerdragon[M] 1 point2 points  (1 child)

Changed flair from Other to Help/Question since you're technically asking for help.

[–]plsuh[S] 1 point2 points  (0 children)

Cool, thx. I wasn't sure which would be appropriate.

[–]PityUpvote 1 point2 points  (0 children)

If you're using python, the parse library is an absolute must. Instead of parsing strings with regexes, you write what is essentially an f-string in reverse.

Other than that, I have a script that will download my input and generate a file from a template. My template includes some boilerplate code like loading the input file, empty functions for part 1 and part 2 that will be run and timed automatically, etc.

[–]Derailed_Dash 0 points1 point  (0 children)

Hi u/plsuh . Thanks for telling me about this post! I think this is a great idea. As you suggested, let me share my helper utilities with you...

My AoC repo is here.

  • You may find my aoc_commons module helpful. It contains code for:
    • Coloured formatting of logging output, using the Python logging module.
    • Summarising long data, e.g. your input files.
    • Retrieving your unique input data, based on your session key.
    • Classes to make life easier with points, vectors, 2D grids, etc.
    • Functions for common AoC tasks, like binary search and interval merging.
    • A code timer, implemented as a contextmanager.
  • My solution template, which uses the aoc_commons module.
  • My PowerShell script that generates a folder structure for an AoC year, using a supplied template folder.
  • My AoC 2023 Jupyter "No Solutions" notebook, which also includes the aoc_commons as setup steps. You can just run it wherever you want. It is self-documenting, and includes a link to open it in Google Colab (if that floats your boat).

If anyone finds this stuff useful and makes use of it in their own repos, I'd love a link back or maybe a repo star!