This is one of my favourite kinds of excercises, where you have to set up a simulation and let it run, I had a lot of fun with it, so I may have overengineered it a tad bit, but I'm kind of proud of this one :)
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day13.nim
So another optimising puzzle here, part 1 was troublesome at first because I used the wrong datastructure, got that changed over to an IntSet, and then I got that running pretty smoothly.
For the second part though 50 000 000 000 iterations is a lot, and I didn't find any looping, I'm also terrible at these, so after a little while I had to look at some hints, and then it was pretty obvious.
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day12.nim
This was rather fiddly to get to work, first thing I tried was way too slow, then at least I found a way to optimise it a bit, it's still slow, but now runs in ~1 min in debug mode or 0.52 sec in fully optimised mode (-d:danger) never really thought of trying that since I mostly just run these in debug mode and it's quick enough.
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day11.nim
This was a really easy one, but it was fun, I like these that create some ascii art, the only thing I had to do here was to just binary search my way into figuring out the size of the characters, and then it just showed up correctly :)
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day10.nim
For fun this time I implemented a doubly linked ring manually, since I didn't really need that many operations to do on it, it was quite a fun excercise, the second part is a bit slow, but I'm sure I could make it faster, I just don't feel like it right now.
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day09.nim
#nim is a weird (and hard) language... It feels like multiple languages mixed all together… but damn, I still managed to add a feature I want for a project without actually learning it
#nim #nimlang #foss #programming
I really had a lot of fun with this one, was a bit difficult to wrap my head around in the beginning, but when I got it it was a fun goal to build towards.
It was a lot of fun to build some custom iterators for this one, it was way easier than I thought it would be, and just feel really natural to use, I love how nim's syntax both feels so cohesive and still so flexible :)
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day06.nim
Having done some experimentations with a gapbuffer actually helped quite a bit with this one, I also think it's the only time I've ever used xor in an if statement before :p
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day05.nim
Got to try out some date stuff in nim, like the rest of the language it felt intuitive. Also more for fun I tried out using range-types, which are pretty nice, that way I could make sure that the month would be in the range 1..12 and the day in the range 1..31 very nice to make sure your numbers aren't something you didn't expect :) it's like an int enum :p
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day04.nim
So today I learned that nim has Levenstein distance algorithm in its standard library, that's nifty, also breaking to labels was useful in this one, in the first part countTable made it pretty trivial.
https://codeberg.org/sotolf/adventOfCode2018/src/branch/main/day02.nim
This is a bit slow, there is probably a good way of making it more performant, but the code looks and feels really nice :) so that is good, function overloading and UFCS makes this pretty nice :)
https://codeberg.org/sotolf/adventofcode2020/src/branch/main/day24.nim
I have to say I had to find some help on this one, for the first one I used a singly linked ring, and since it was small it went fast, when we then expanded it in orders of magnitude everywhere the searching for a number got way too slow, I read that many used an array where each "link" was stored, and using this I could do lookups in normal array time rather than having to scan through in the worst case a million pointers.
https://codeberg.org/sotolf/adventofcode2020/src/branch/main/day23.nim
Man of man this ended up as a fucking mess of a solution, took me ages to get right, now my code has a lot of repetition, and parts that could probably be redone otherwise, not even sure it would work for other inputs than mine, but it works :D
That took me 3 days or something, and now it finally works :D
https://codeberg.org/sotolf/adventofcode2020/src/branch/main/day20.nim
Generating FLIRT signatures for Nim and other non-C programming languages - Adversaries are increasingly writing malware in programming languages such as Go, Rust, o... https://blog.talosintelligence.com/generating-flirt-signatures-for-nim-and-other-non-c-programming-languages/ #malwareanalysis #ida #nim
Talos: Generating FLIRT signatures for Nim and other non-C programming languages https://blog.talosintelligence.com/generating-flirt-signatures-for-nim-and-other-non-c-programming-languages/ #MalwareAnalysis #IDA #Nim
At first I thought a 3D game of life was complex, but I did it, then I had to solve a 4D game of life, and I was getting nervous, luckily it worked out :)
https://codeberg.org/sotolf/adventofcode2020/src/branch/main/day17.nim
I really like named tuples, there are few places where an object actually makes more sense than a named tuple, and you can construct or deconstruct it really easily, or use named fields to retrieve the information in it.
For #nim this is even more the case since it's tagged unions are quite annoying in that you aren't allowed to have to variants use the same field, but if you use the name of its kind and the variable as a tuple with the information you can.
Once I finally wrapped my head around how 90º rotations work in a coordinate system this one wasn't that bad.
https://codeberg.org/sotolf/adventofcode2020/src/branch/main/day12.nim