Advent of Code 2023 - in Go
This year I am participating Advent of Code to learn about the Go Programming language. This will be fun.
There are two convenience python scripts available, to make life easier: one to download input and prepare a Go template, and another just to download the input
-
prepare.py- called viaprepare.py dayit will- (try to) download the input of the specified
day - create a target directory
- copy the input as well as the main Go template (
main-tmpl.go) into that directory and - start up VS Code.
E.g.,
prepare.py 03will create a directord03and put the respective input fileinput.txtandmain.gointo it. If the output directory already exists, the script will exit, to avoid overwriting any code. - (try to) download the input of the specified
-
load_input.py- called viaload_input.py dayit will- (try to) download the input of that day,
- create a target directory (if it does not exist already) and
- copy the input into it.
E.g.,
load_input.py 03will create a directoryd03and put respective input fileinput.txtinto that directory. If the output directory does exist, it is no error, any existing input file will be overwritten!
Of course, downloading the input from the python scripts only works if the input is already available on the website (i.e. it must be at least than midnight EST/UTC-5). Also, to be able to access the input, you need to put your AoC session variable into the .env file - it will be read and used by the python scripts:
sessiontoken=abcdefgh12345678...
You can grab this token using your browsers development tools after logging in into Advent of Code website, see this reddit thread.
The prepare.py script starts up VS Code in the main directory, but you are supposed to open the main.go file in the directory of the respective day.
The tools directory contains a few functions that might help with everyday tasks (e.g., reading input, converting strings etc).
MIT License, Copyright (c) 2023 Jonas Rathert - see file LICENSE.txt