r/PowerShell • u/rmbolger • Dec 15 '20
Advent of Code 2020 - Day 15 - Rambunctious Recitation
https://adventofcode.com/2020/day/14
Definitely a pretty straightforward day where you should be able to use the same code for both parts 1 and 2.
5
Upvotes
5
u/rmbolger Dec 15 '20 edited Dec 15 '20
Here's what I've got after cleaning things up a bit. There are likely more efficient methods, but part 2 runs in about 1 min on my machine which is good enough for now. If you're not on PS 7+, be wary of the ternary operator towards the end of the function.
4
u/dantose Dec 15 '20 edited Dec 15 '20
Part 1:
part 2: Too inefficient to work in a reasonable amount of time.
Better, but it's still going to take a while:
4
u/RichardDzienNMI Dec 15 '20
Had things to do the last few days. So no advent for me. Back for a bit today at least. As always, bet there is a better way!
Part 1:
3
u/ka-splam Dec 16 '20 edited Dec 16 '20
I wrote some code with a big hashtable of times-last-seen, and it got my answer for part 1. Started running on part 2, working but slow. By the time I tried rewriting it, it was 5 million in and I let it run. It slowed down and down. Took 20 minutes for part 2.