Re: Advent of Code 2018 megathread
Yesterday I have sent a mail to people on our leaderboard who solved 25 tasks. If you're one of them and you didn't receive anything: first check your spam folder ;) and if there's nothing there, please contact me. Also, even if you didn't solve all 25 tasks, but you think some solution of yours (or a whole repo) is very nice/elegant/fast/etc. give us a link to it and a short explanation why you think we should award it :)
Re: Advent of Code 2018 megathread
Here are my solutions: [https://github.com/epiphone/aoc/tree/master/2018](https://github.com/epiphone/aoc/tree/master/2018). Just started learning Nim so they're not much to look at. Enjoying the process though! Of the recent ones day 22 was particularly fun, with Dijkstra's algorithm, priority queues and whatnot. Exciting after the CRUD tedium of one's day job... Browsing other people's solutions was really helpful in picking up idiomatic Nim, so thanks for those!
Re: Advent of Code 2018 megathread
Yeah my bad on that. Trying to be too smart too quick doesn't usually end up paying off in the end :) Thankfully, I actually got to use A* on a later problem, and I was able to copy most of the code from my first day 15 attempt, so that was a little redeeming... I don't think you are alone in taking a break; I see others doing it and almost did so myself. I can feel my sanity slowly fading as we bounce between cellular automata problems one night and assembler reverse engineering problems the next.
Re: Advent of Code 2018 megathread
I had a breadth first solution that would have worked if I would have read the specification, hmpf reading order, then I looked at your A* and that threw me of track :) Eventually I ended up width a breadth first. Your repository was of good help @nickmyers217 both help in a good and in a bad way :D Now I won't be able to solve any more before christmas, I have to revisit the remaining problems when I get home from the christmas vacation. But I can say that I have found a lovely language that I can't wait to solve stuff in.
Re: Advent of Code 2018 megathread
Day 20 forced me to abandon nim, because for whatever reason my hash searches started taking seconds. I probably fucked up somewhere around type Room = object coord: Coord doors: Table[char, Door] Door = object name: char frm: Room to: Room proc hash(room: Room) : Hash = result = 10 * room.coord.y + room.coord.x proc hash(coord: Coord) : Hash = result = 10 * coord.y + coord.x
Re: Advent of Code 2018 megathread
Yeah day 15 was a struggle, but I am glad I didn't give up. I was finally able to hunt down the path finding but that was haunting me. My issue was that I was trying to be too clever and implement A* for the pathing which led to bug after bug. I took a big step back and decided to just brute force it with breadth first search instead, which ended being a way better choice. Tell some of your friends that if they come back to the problem with a fresh and well rested mind they can do it :)
Re: Advent of Code 2018 megathread
I know atleast three people who rage quit advent of code this year because of day 15. Day 16 was a lot of fun and I'm currently finding time to work on day 17 but I still have nightmares about goblins and elves :(
Re: Advent of Code 2018 megathread
Yeah, day 16 was like a vacation compared to 15. I am back to work debugging 15 now, and I found an issue with my path finding. I think the best approach to debugging it is visualizations, so I am building out a little interactive mode that steps through the game step by step visually. Hopefully I can hone in on the problem now.
Re: Advent of Code 2018 megathread
I encountered the same difficulties. The fact that the problem provides several test cases shows that the creators are aware of the difficulties. There are several traps to fall into. And, for part 2, there are also performance issues. For now, this problem has been the most challenging. Day 16 is easier.
Re: Advent of Code 2018 megathread
Sigh, I have a solution that gets all the test cases right for day 15 no problem, but it doesn't get the right answer for my actual input. Time for debugger hell. I guess its about time I check out how well GDB works with Nim anyway.
Re: Advent of Code 2018 megathread
Not an active participant myself (well, at least not in public), but these related blog posts were interesting: [https://chameth.com/2018/12/09/over-the-top-optimisations-in-nim/](https://chameth.com/2018/12/09/over-the-top-optimisations-in-nim/) ([repo](https://github.com/csmith/aoc-2018)) [https://blog.dataforce.org.uk/2018/08/advent-of-code-benchmarking/](https://blog.dataforce.org.uk/2018/08/advent-of-code-benchmarking/) ([scoreboard](https://dataforce.org.uk/aocbench2018/))
Re: Advent of Code 2018 megathread
A bit late to the party and really not proud of all of them, but here is my repo: [https://github.com/bonflintstone/AdventOfCode](https://github.com/bonflintstone/AdventOfCode) I guess my favorites were 8, 9 and 13. 13 was really nice to visualize and I actually created some more tracks later just to watch it play out
Re: Advent of Code 2018 megathread
I liked day 5, day 7 and day 8.
Re: Advent of Code 2018 megathread
> Do you guys have a favorite so far? My favourites so far are probably: 1. day 5 (polymers) 2. day 8 (nodes and metadata) 3. day 9 (marbles)
Re: Advent of Code 2018 megathread
I found day 7 to be the most challenging and rewarding to solve thus far. Day 9 was pretty cool as well.
Re: Advent of Code 2018 megathread
Day 9 https://adventofcode.com/2018/day/9 was so much fun to solve ! I also really enjoyed day 3 https://adventofcode.com/2018/day/3 and day 6 https://adventofcode.com/2018/day/6 Do you guys have a favorite so far?
Re: Advent of Code 2018 megathread
Thank you, that means a lot :)
Re: Advent of Code 2018 megathread
> I'm still learning Nim (...) Not a programmer by trade and it might show. I really like your solutions so far! And if you didn't explicitly tell, I wouldn't ever have guessed that you're just learning Nim nor that you're not a programmer.
Re: Advent of Code 2018 megathread
Here is my repository: [https://github.com/filipux/adventofcode2018](https://github.com/filipux/adventofcode2018)
Re: Advent of Code 2018 megathread
Thanks! That was exactly what I needed to run my tests more quickly. I was just compiling each file individually before, not too fun...
Re: Advent of Code 2018 megathread
I suggest you add the following to your nimble file: ### Helper functions proc test(name: string, defaultLang = "c") = if not dirExists "build": mkDir "build" --run switch("out", ("./build/" & name)) setCommand defaultLang, "tests/" & name & ".nim" ### tasks task test, "Run all tests": test "all_tests Run And then in your test directory add a all_tests.nim file that imports all your individual tests. Now you can just type nimble test to run all your test suite. Example repo with this setup: * simple version with one test only: [https://github.com/numforge/laser](https://github.com/numforge/laser) * complex version with dozens of tests: [https://github.com/mratsim/Arraymancer](https://github.com/mratsim/Arraymancer)
Re: Advent of Code 2018 megathread
This is my first encounter with nim. [https://github.com/tradfursten/advent_of_code_2018](https://github.com/tradfursten/advent_of_code_2018)
Re: Advent of Code 2018 megathread
Just started programming in Nim about a week ago (javascript guy here), and this is also my first year doing AOC. I am enjoying the language and the compiler a lot so far. Here is a link to my github repo: [https://github.com/NickMyers217/advent_of_code_2018_nim](https://github.com/NickMyers217/advent_of_code_2018_nim) I'm going out of my way to unit test everything and do TDD, and am really trying to battle test Nim to see how practical and maintainable it is. I think the language has great potential for indie game development!
Re: Advent of Code 2018 megathread
> repo: > [https://git.sr.ht/~king3vbo/advent-of-code/tree/master/2018](https://git.sr.ht/~king3vbo/advent-of-code/tree/master/2018) "Your" solutions look quite nice, although [very familiar](https://github.com/narimiran/AdventOfCode2018) ;) I know that MIT license is quite permissive, but at least a link to the originals and an attribution would be nice of you.
Re: Advent of Code 2018 megathread
Hi, I am new in this forum and as a Nim user. I'll post my solutions here: [https://github.com/JulienRobitaille/AoC2018](https://github.com/JulienRobitaille/AoC2018) I use this year advent of code as an opportunity to learn Nim :)
Re: Advent of Code 2018 megathread
I recently picked up Nim In Action and have been reading through it, so here's a perfect way to get some practice in. I'm in PST so my place on the private leaderboard is pretty abysmal so far. repo: [https://git.sr.ht/~king3vbo/advent-of-code/tree/master/2018](https://git.sr.ht/~king3vbo/advent-of-code/tree/master/2018)
Re: Advent of Code 2018 megathread
Did day 3. Things I've missed in nim: "difference" for OrderedSet, or a method to convert back to a HashSet so I can apply difference. Ended up just declaring the set as HashSet; OrderedSet was useful to visualize, but not necessary. Better tutorial for regular expressions. Ended up with strscans, which works great tho.
Re: Advent of Code 2018 megathread
Decided to use AoC as an opportunity to learn Nim. My solutions are in this repo: [https://github.com/anonanonymous/Advent_of_Code](https://github.com/anonanonymous/Advent_of_Code)
Re: Advent of Code 2018 megathread
By the way, if you are trying to "right size" a set or table to streamline resizing costs, you can use rightSize(number of members to support). This is easier than trying to guess the power of two at which such a population is supported for both initSet and initTable. rightSize uses the same formula (its inverse, really) as the internal formula used to decide when doubling capacity is needed.
Re: Advent of Code 2018 megathread
if i don't end up procrastinating like previous years, my solutions will be here [https://github.com/SolitudeSF/adventOfCode](https://github.com/SolitudeSF/adventOfCode)
Re: Advent of Code 2018 megathread
> I am brand new to Nim, and was inspired by the Advent of Nim post Glad to have you with us :) > In my testing, `initIntSet()` turned out to be a lot faster than initializing > with `initSet[int]()` You're not using high enough number ;) Try it with something like `2^17`. There should be a difference between the two (with `intSet` being faster), but just a couple of miliseconds between them (when you compile with `-d:release`). Now, the more interesting question is _why?_ , and the simple answer (allow me this, I'm waking up around 5:30 for AoC :)) is because the different ways these two sets are implemented (if you're interested, here are the source codes: [hash sets](https://github.com/nim-lang/Nim/blob/master/lib/pure/collections/sets.nim), [int sets](https://github.com/nim-lang/Nim/blob/master/lib/pure/collections/intsets.nim)). If somebody else would like to go into more details, be my guest.
Re: Advent of Code 2018 megathread
> Something in the end I was not able to understand how to do is how to print > the type of a variable. There is a pending PR waiting to be merged which will allow this by default. Until that is here, you need to `import typetraits`. > my input file contained integer that did not fit in 16 bits. I guess this was > due to the fact that I was using the const Sets (the ones in system, which you use without any import) are limited to `int16`. Hash sets (`import sets`) don't have this limit. For these kind of problems, it is even better to use int sets (`import intsets`).
Re: Advent of Code 2018 megathread
Joining in. I dabble in nim. Haven't touched it for a couple of months so I am rusty. Need to keep practicing so I joined this [https://github.com/floydnunez/Advent_of_code_2018](https://github.com/floydnunez/Advent_of_code_2018) Oh man, my second solution is bruteforce as all fuck. I just reread the file over and over. Someone tell me that the read is actually cached.
Re: Advent of Code 2018 megathread
> We had a long discussion on #nim IRC channel about this today, and there are > two possible solutions yes, thank you! I saw the discussion earlier this morning and I was able to fix that (I did initialize the HashSet with the defaults...). I pushed the changes and also activated the issues. :) As a first day it was definitely fun. As far as the learning process went, I struggled a little bit with the types (I realize now how much type inference and casting is done in Python) and also I still do not get the syntax right at the beginning (in particular when handling types, initializing variables and calling functions). As could have been expected, searching how to do stuff is less easy than in python (where, for every "dumb" question - and I had a lot - you find the answer on Stack Overflow). I was impressed by the help from Visual Code in spotting errors (and giving hints on what is wrong). Is this because of nimsuggest that I saw mentioned around? What exactly is that? Anyway, Visual Code was even able to tell me that I could not use the built in set implementation because my input file contained integer that did not fit in 16 bits. It would highlight an error over the parseInt below and give me instances of illegal conversions: const changes = map(readFile("./inputs/01.txt").splitLines, proc(x: string): int16 = int16 parseInt(x)) Run I guess this was due to the fact that I was using the const (I really like the idea of compile time constants). In fact when I change the declaration to a let, the error disappears (well, it still there, I just do not know about it). In order to do that it has to do the compilation on the fly, right? Are there mechanism to prevent computations that might take too much time? I still would like to fire up an interpreter (a couple of times I did use `nim secret`). I very much look forward too the REPL that is in the works. Something in the end I was not able to understand how to do is how to print the type of a variable. It is something that in python I do once in a while and I realize that it might not make much sense in Nim (where I can just hover over the variable in the IDE), but still, what is the correct way to make this work? const instructions = @["+1", "-1"] echo type(instructions) # this raises error Run
Re: Advent of Code 2018 megathread
Hi everyone! I am brand new to Nim, and was inspired by the Advent of Nim post I saw on Hackernews the other day to give it a shot. Like others here, I will be posting my solutions to Github: [https://github.com/hermanschaaf/advent-of-code-2018](https://github.com/hermanschaaf/advent-of-code-2018) @miran could you explain why initIntSet() is so much faster? In my testing, it turned out to be a lot faster than initializing with initSet[int](). What is the difference?
Re: Advent of Code 2018 megathread
My repo: [https://github.com/ericsolomon/aoc2018](https://github.com/ericsolomon/aoc2018) Still fairly new to nim and there will be solutions in other languages in this repo, but there is where all of the aoc code will be housed.
Re: Advent of Code 2018 megathread
> Inspired by @miran's repo _blushing_ :) > Nim (python-naive) implementation unexpectedly much slower! Why? I know the answer, but you disabled issues in your repo so I cannot comment there. We had a long discussion on #nim IRC channel about this today, and there are two possible solutions for this problem: * initialize your set to have a large initial size `initSet[int]()`, or * import `intsets` and then plain and simple `initIntSet()`
Re: Advent of Code 2018 megathread
Joined the leaderboard and here is my repo: [https://github.com/Thor77/AdventOfCode2018](https://github.com/Thor77/AdventOfCode2018)
Re: Advent of Code 2018 megathread
Hey everyone, new Nim hobbyist programmer here! It's my first time doing AOC this year, I though it would be a new opportunity to learn what seems to be one of the most promising new languages out there. So, I'll try to do most days in Nim, but can't promise I won't fall back to python if I get really stumped. Looking forward to reading your solutions! Here is my repo: [https://github.com/auxym/AOC2018](https://github.com/auxym/AOC2018)
Re: Advent of Code 2018 megathread
Hi all, ran into Nim in Hacker News a couple months ago, and this year's Advent of Code seems an excellent way to finally learn by doing. Inspired by @miran's repo I will be posting my solutions here: [https://github.com/pietroppeter/AdventOfCode2018](https://github.com/pietroppeter/AdventOfCode2018) I plan to solve them first with Python, then by Nim. Only when they are solved also in Nim I will put in my solution. I joined the private leaderboard. It is going to be fun!
Re: Advent of Code 2018 megathread
> Currently there are 18 of us who joined. Make that 38, as we speak ;) Less than 24 hours to go until the start so here are some basic tips/rules: 1\. **SPOILERS** : Try to keep this thread as spoiler-free as possible. If you can't wait to share your solution, [r/adventofcode](https://old.reddit.com/r/adventofcode/) will have megathreads for each day and you can post there as soon as the global leaderboard is populated (and that is veeery quickly). If you would like to post it here too, consider posting a link to your solution (Github, Pastebin, etc.) and not just copy-paste it here, so people will need to consciously click before seeing spoilers. 2\. **ASKING FOR HELP** : Feel free to ask for help either here or on Nim IRC/Gitter channel if you have some Nim-related problem, but have in mind that your snippets might contain spoilers for other who haven't solved the task yet — not everybody will be able to solve the tasks at 5 a.m. UTC. Consider waiting at least couple of hours before asking for help (in that time, try it some more to see if you can solve it by yourself). 3\. **HAVE FUN** : This is mandatory!
Re: Advent of Code 2018 megathread
Currently there are 18 of us who joined. If you didn't participate in the previous incarnations of AoC and you don't get what all the fuss is about, I'd recommend you to solve some tasks from 2017 (or earlier) to get in the mood and join us this Saturday. Usually first few days every year are easy tasks for warming up. If you want to challenge yourself, take a look at [2015 day 19](https://adventofcode.com/2015/day/19), [2015 day 22](https://adventofcode.com/2015/day/22), or [2016 day 11](https://adventofcode.com/2016/day/11), to name a few.
Re: Advent of Code 2018 megathread
My AoC repo: [https://github.com/moigagoo/aoc2018](https://github.com/moigagoo/aoc2018)
Re: Advent of Code 2018 megathread
My repo for AoC 2018 is here: [https://github.com/jabbalaci/AdventOfCode2018](https://github.com/jabbalaci/AdventOfCode2018) .
Advent of Code 2018 megathread
It is time for [Advent of Code 2018](https://adventofcode.com/)! Nim is organizing [private leaderboard](https://adventofcode.com/2018/leaderboard/private) where you can compete against other Nim users. To join the Nim leaderboard, all you have to do is use `40415-c732e66e` code in the previous link. More information about this event and the prizes you might win in [this blog post](https://nim-lang.org/blog/2018/11/26/advent-of-nim.html) * * * Use this thread to post links to your AoC repositories and share your solutions.