Skip to content

filipux/adventofcode2018

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adventofcode2018

# comment
1 Found itertools with cycle() iterator Day 1
2 toCountTable(seq) saved some typing - nice! Day 2
3 Happy about how I could use an iterator for patches :) Day 3
4 Very hard. Learned about parseEnum and attributes on enums Day 4
5 Started with string based regex solution but went with DoublyLinkedList for speed (0.1 seconds for both parts) Day 5
6 Hard problem. Inititally solved part #1 using a super fast flood fill technique but had to change to a slower method to solve part #2 with same code (0.2 sec for both parts). Day 6
7 Graph problem that got a bit bloated. Why isn't there a Graph class in the Nim standard library? Tried out generics for the first time. Used strscans instead of regex to parse input. Day 7
8 Easier problem. readTree() turned out great, super happy about my code this time! Learned about seq.pop() Day 8
9 Easily solved using DoublyLinkedRing. ring.head.prev.prev.prev.prev.prev.prev.prev 😄 Day 9
10 Also quite easy. Hardest part was figuring out when to stop time and how to print the output Day 10
11 Easy. Immediately recognised the problem as one that could make use an integral map. Had to read up on wikipedia how to implement one but it was very straight forward. Day 11
12 Meh. Learned how to index arrays backwards using [^] Day 12
13 I didn't like this one at all. Horrible horrible code that I don't want to see ever again. Day 13
14 Easy once you realise you need to check for Part 2 after each added recipe. Day 14
15 This was WAY too hard. Probably made 10% of all people give up on advent of code this year ☹️ I spent too much time on this so I didn't find the time to optimize the solution. It is is very slow, 13 seconds on my computer, but optimizing it could be easy based on this quick profiling with nimprof:
a15.nim: addNeighbour 628/1703 = 36.88%
a15.nim: init 1096/1703 = 64.36%
a15.nim: newDistanceMap 1697/1703 = 99.65%
Day 15
16 Lots of fun and easy compared to #15. Used templates to get nice CPU emulator code. Day 16
17 Kept looking for a simple set of local rules to run the simulation and sort of found it in the end. Ugly code but I'm happy with the algorithm I ended up with. First working version took 10 minutes to finish but I was able to optimize it alot down to 0.1 seconds 😎 Day 17
18 Easy day but ugly code. Realised CountTable can't count to zero. Submitted a feature request. Day 18
19.1 Part 1: Simple rewrite of day 16. Still lots of fun! Day 19.1
19.2 Part 2: Holy moly. How can something so simple turn out to be so incredibly hard? My code from Part 1 would have taken ~3 years to run. Almost gave up but solved it doing a line by line analysis and multiple high level rewrites. In the end the problem turned out to be simple again 😄Code contains all my analysis and iterations. Day 19.2

About

Solutions in Nim for advent of code 2018

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages