Advent of Code 2022 (Kotlin) ๐ŸŽ„



This year I had the ambition to actually use Java for Advent of Code (AOC). And needless to say, I got pretty far before falling down because of time issues and trying to solve it in a good way. What I actually should have done is use the quick and dirty way where possible so that I didnโ€™t lose a lot of time.

But I wanted to learn new things about Java and forcing myself to make a better solution worked out for the easier puzzles thus far. For this year because Java 17 was out I decided it was maybe good to try it out and find newer features.

I wrote down most things I learned in the file of the project, but here is a quick summary:

You can make an easy List without the use of a collector now:


// Java 17
List<String> cookiesToBuy = groceries.filter(g ->"Cookies")).toList();

// Java 11
List<String> cookiesToBuy = groceries.filter(g ->"Cookies")).collect(Collectors.toList());

I also learned that you can make 3D arrays in Java. I knew this from my Gamedevelopment experience but I didnโ€™t know the option existed in Java as well because I never had the need to use it. So I was making my own data structure before with classes which uses a lot more memory. This way when loading a lot of objects I donโ€™t need to have more than 128GB to run the puzzle ๐Ÿ™„


int size = 10;
String[][][] = new String[size][size][size];

Advent of Code Repository