|
|
|
|
|
by epiccoleman
907 days ago
|
|
Yeah, it's always rough when you write a solution for part 2, and it passes all the samples, but then has issues with the real input. One thing I've tried to do when I run into those kinds of problems is to write a little benchmark to illustrate the difference between approaches. It's always kinda fun to watch your initial brute force solution start chugging while your shiny new solution seems to handle whatever you toss at it - great lesson in choosing effective algorithms. I use Elixir to do the puzzles, so I've used Benchee for this, and it works very well. So easy to set up too. Here's an example benchmark, which also has the output. As the input size increases you start getting some pretty crazy ratios between the two algorithms (the "smart" version was 200,000 times faster than the "naive" one on the largest test input!) https://github.com/epiccoleman/advent_of_code_ex/blob/master... |
|