4 ms·
Advent of Code Python Solutions, Explained
- sampagu 8y agohttps://www.bollymeditube.com/2018/11/how-to-get-chubby-cheeks.html https://www.bollymeditube.com/2018/11/how-to-get-chubby-chee...
- fogleman 8y agoOP here. I really enjoyed reading through Peter Norvig's AoC solutions a while back: https://github.com/norvig/pytudes/blob/master/ipynb/Advent%202017.ipynb https://github.com/norvig/pytudes/blob/master/ipynb/Advent%2... I'm no Norvig, but I thought I'd try my hand at walking the reader through my own solutions this year. This is what I've come up with so far! I'm currently 9th on the global leaderboard: https://adventofcode.com/2018/leaderboard https://adventofcode.com/2018/leaderboard
- jurassicfoxy 8y ago9th on the leaderboard is insane, great work.
- CobrastanJorji 8y agoHey OP, great job! While I see your notes that you've cleaned up your solutions after the fact, what you've published is remarkably clean, concise, and beautiful code.
- fogleman 8y agoThank you!
- Dowwie 8y agoWell done. Great job taking the lead.
- mixedmath 8y agoThank you for this. I always like reading people's writeups for problems like these. Cheers.
- bentleycook 8y agoI've really enjoyed these solutions in Javascript: https://beta.observablehq.com/collection/@mpcowan/advent-of-code-2018 https://beta.observablehq.com/collection/@mpcowan/advent-of-.... Observable has made it fun to follow along and re-run the code.
- jurassicfoxy 8y agoI recommend reading the solutions on the Advent of Code subreddit: https://www.reddit.com/r/adventofcode/ https://www.reddit.com/r/adventofcode/ There are much more interesting, highly optimized solutions and better discussion, animations, etc.
- levi_n 8y agoThanks for the link, OP. Looking at just Days 1 and 2, the author has given examples that are certainly concise, but (arguably) at the expense of readability. Similarly, the Day 2 part 2 answer is concise at the expense of performance, as there is a lot of duplicated comparisons and comparisons that could be skipped.
- fogleman 8y agoIn an alternate reality, I made the solutions more performant and you criticized them for being too verbose.
- levi_n 8y agoFair point. I wasn't trying to necessarily criticize the solutions, but personally found differences between the given solutions and my own enlightening.
- fogleman 8y agoHaha, fair enough. There's certainly a balance to be made.
- keithnz 8y agoI think it's worth noting that the problems are such that many solution don't need performance, and then later there are problems that do need performance, and of course those that no matter how much performance you had you have to work another approach entirely. I was amused watching some people doing day 9 having solved it using a good datastructure and confused why p2 was so simple, vs watching people having no idea about their languages performance for the baked in collections they were using.
- Waterluvian 8y agoI love looking at other ways to solve these problems. But I hope it remains clear to all that there's no singular right way to solve them. I remember writing a few of them thinking, "the big O is terrible but this is so much more obvious to read." Or even, "I bet part 2 will want to do X so I'll make it more robust for refactoring." So many variables. Fun to practice which ones you constrain.
- a_humean 8y agoI've enjoyed solving them on my own and then looking at the other solutions in the AoC subreddit. Its really interesting to see how people solve them in lots of languages including the language I wrote in. Usually I learn something new, and even if its in a different language I can see optimisations that I could apply to my solution.
- AdeptusAquinas 8y agoIm still stuck on Day 15 in F# :| Trying to resist copying OPs python search algorithm.
- nestorD 8y agoAnd it might not even work. Some solutions work only on a fraction of inputs due to a vicious tie-breaking rule. This thread might help you if you already pass all the tests : https://www.reddit.com/comments/a6f100/-/ebw1uda/ https://www.reddit.com/comments/a6f100/-/ebw1uda/