Hacker News new | ask | show | jobs
by Storm-Bringer 1987 days ago
How do people usually tackle AdventOfCode? Most elegant/concise solution or best performant?

Asking because for example most solutions to Day 1 I've seen are O(n^2)

2 comments

I aim for "first thing that I can get to work and doesn't take more than 20 seconds". Usually they run in under 2 (Common Lisp is my language of choice). Then for the part 2 portions I may have to optimize.

I sometimes go back and clean up my solutions, though I aim for a combination of clarity and performance if I do that, clarity first.

Unless I'm really unhappy with my solution, I stick with the first thing I write that spits out the correct answer. Since a lot of the problems require you to do some potentially interesting optimization to get an answer in a reasonable amount of time, I don't bother optimizing the ones that don't.