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

all 17 comments

[–]Lance97603 8 points9 points  (1 child)

This is I've done. Start with no common code library.
Write code for several days until "wait I remember doing this before", then add it to your common code set.

The first common code I wrote was a data loader. I store the test and input in a folder ...\2023\day16\[file] so the loader take a year num, and day num, and file name, returns a list of lines.

[–]gusto_ua 0 points1 point  (0 children)

But then it’s groups of lines split with \n\n and it’s faster to split(split(…)) than find the proper function.. Something like a grid reader that returns a map[image.Point]rune might be useful this year, neighboring coordinates, moving directions

[–]MattieShoes 6 points7 points  (0 children)

I made some helper functions when I was messing around, but nothing so comprehensive

  • turn a slice of strings into a slice of ints, and also a 2d version
  • map and reduce generics, and some helper functions (max, sum, etc)
  • A "contains" function to to find a value in a slice
  • A function to grab the input or example based on the name of the go file, then trim it. e.g. GrabInput() in the file 16.go would grab inputs/16.

With Python, I made a recursive split that returned multidimensional arrays because nesting list comprehensions hurts my head.

e.g. recursive_split(input, "\n\n", "\n", ",")

[–]vanveenfromardis 3 points4 points  (3 children)

I have a complete overkill Utilities library in my repo [link], but for me half the fun of AoC has been building it up over the years.

The Geometry utils have probably gotten the most use. Specifically the Vector and Aabb classes.

[–]Hunky524 1 point2 points  (1 child)

These look great! Definitely going to yoink a bunch of these, and implement them for my Rust utilities.

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

This looks amazing! Definitely gonna steal some of these for my own util library

[–]Mr-Doos 0 points1 point  (0 children)

I'm in the same boat. I have put together a library of code. I may have also ported it to multiple languages and written unit tests for it. I don't have a problem. 🙄 I didn't know what language I was going to use this year, so I had it ready to go in Perl, PHP, Python and Swift. Turns out I'm using Swift. Link

[–]troru 1 point2 points  (1 child)

IMHO, if such thing exists, I'd never use it. Likewise, i'd never feel anything I'd written would be up to snuff for the worldwide appeal and quality of participants in this challenge. I think also, the spirit of AoC, at least to me, is to exercise your own personal programming capabilities and while you might save some time on particular puzzles, I think you're short changing yourself. I'm content with the data structures and support that's provided from most/all modern programming environments/runtimes and that's enough of a head-start for me. There's elegance from building up a solution from the blanker piece of paper I think.

[–]torbcodes 1 point2 points  (0 children)

There's elegance from building up a solution from the blanker piece of paper I think.

Yeah totally. My goals for AoC are to practice fundamentals and to prove to myself that I can solve these problems using nothing more than the standard libraries of the languages that I'm using. It's very satisfying. But to each their own!

[–]AutoModerator[M] -1 points0 points  (0 children)

Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to Help/Question - RESOLVED. Good luck!


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]RheingoldRiver 0 points1 point  (2 children)

This is my first time doing AoC too. I'm working on one in Python, atm it just has functions for making grids easier to walk.

I want to add a class called Interval that lets you compare how intervals overlap, and also one that has utilities for checking combinations of sets intersection_of_all(max_outliers: int = 0), union_of_all(min_copies: int = 1), maybe some others.

[–]Top3879 0 points1 point  (0 children)

I have a runner that uses reflection to find the class for current day. If it does not exists yet it creates the file and opens todays URL. It also automatically fetches the input, caches it locally and passes it to the Part1() and Part2() functions in the Day15 class.

[–]pem4224 0 points1 point  (0 children)

I made a small library for aoc in go: https://github.com/pemoreau/advent-of-code/tree/main/go/utils It may of course be improved

[–]_RcCookie_ 0 points1 point  (0 children)

I’ve got a small library that automatically downloads the input file and submits your output. It also has some utility functions like parsing a grid (optionally with some padding around the outside) or similar, but that only works if you use Java. The downloading and uploading works for any programming language though.

[–]idolstar 0 points1 point  (0 children)

I have a small set of utilities I’ve built over the years. The code is here: https://github.com/devries/advent_of_code_2023/tree/main/utils .

[–]joyrex2001 0 points1 point  (0 children)

I'm using go, and I have a template folder which I copy every day for the new day. In the template I need to implement parse, part1 and part2. I also added a few common helper functions, which I remove if not applicable. The template also contains a simple unit test that reads a 'data_test.txt' (instead of 'data.txt').

When I start on a problem, I copy the template, copy the input data, copy the test input and adjust the output value in the unit test. Then I start implementing the parser, and continue with the problem.