I just made a git repo for my #AdventOfCode solutions, so if any of you wanna see my spaghetti code you can find it here on #Codeberg - codeberg.org/rokosun/AOC
I'm using the #Nim programming language since I started learning it a while ago, still very much a beginner tho ๐
P.S. Also check out @amin's private leaderboard for #AOC - alpha.polymaths.social/@amin/sโฆ
This entry was edited (9 months ago)
like this
Rokosun reshared this.
Rokosun
in reply to Rokosun • • •Roma likes this.
sotolf
in reply to Rokosun • • •Rokosun
in reply to sotolf • • •sotolf
in reply to Rokosun • • •I've done all of mine so far in gleam :p so I'm not sure how helpful they would be since they look kind of different:
bin.benjaminhollon.com/tifirtrโฆ
But in a way the language has kind of a similar feel, weirdly enough.
bin.
bin.benjaminhollon.comRokosun
in reply to sotolf • • •@sotolf @esh
I'll take a look at this, I'm interested in seeing different people's solutions even tho I may not fully understand the language they use, most programming languages tent to have some familiarity with each other so you can make a pretty good guess.
Roma
in reply to Rokosun • •Rokosun
in reply to Roma • • •@esh I've actually just finished doing day 4 now, see my code ๐ - codeberg.org/rokosun/AOC/src/bโฆ
@sotolf helped me learn custom types in Nim and so far it has been very useful in solving these puzzles and keeping my code more neat and organized in general.
AOC
Codeberg.orgRoma likes this.
sotolf
in reply to Rokosun • • •Rokosun
in reply to sotolf • • •@sotolf @amin
Yeah I'm not familiar with using custom types or objects because my experience with programming so far had been writing shell scripts on Linux - which doesn't support either of those, lol ๐ So yeah, I'll probably need some practice before I can get into the Nim way of thinking. Thanks for your suggestions BTW ๐
sotolf
in reply to Rokosun • • •Rokosun
in reply to sotolf • • •@sotolf @amin
Some other folks have also shared their Nim code for this year's AoC so that's gonna come handy - forum.nim-lang.org/t/10717
This might sound like a stupid question, but I'm a bit confused between objects and custom types in Nim - do I actually need to use an object here or would a custom type with named tuples be enough?
sotolf
in reply to Rokosun • • •@amin
Here you go, this is how I would have solved day 2 in nim:
I like to keep things as readable for myself as possible for later, and so that it's a lot easier to debug when you inevetably will have to do it :)
bin.benjaminhollon.com/orrivalโฆ
bin.
bin.benjaminhollon.comRokosun
in reply to sotolf • • •Oh thanks man, I'll take a look at the code ๐
Rokosun
in reply to Rokosun • • •@sotolf @amin
Wow your code looks much better and well structured than mine. I still find it a bit hard to wrap my head around these custom types and things but I understand why it can be beneficial - it feels like the initial part of your code that defines all the custom types and the procedures used to parse them provides a sort of scaffolding that makes the rest of the code more easy to manage, I also like how modular everything is compared to my "omnifunction" ๐
sotolf
in reply to Rokosun • • •@amin yeah, that's exactly how I'm thinking how can I represent the data, and then how can I get closer to what I want, or functions I need to do what I need. My way is just one way to do it, but it's the one I find the easiest to work with :)
Types are a bit daunting in the beginning but when you do they really help you think, and let's the compiler help you not do a quite big group of errors :)
Rokosun
in reply to sotolf • • •@sotolf @amin
I think I also learned some new Nim features from your code, for example I was surprised to see how you defined the CubeSet type on line 13 - is Nim using the Color enum for indexing its arrays?! I had no idea this was possible!