Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge thanks #1

Open
typescriptAoC opened this issue Dec 5, 2023 · 1 comment
Open

Huge thanks #1

typescriptAoC opened this issue Dec 5, 2023 · 1 comment

Comments

@typescriptAoC
Copy link

Just want to say a huge thanks for this repo. Would say am relatively experienced dev (js/ts). Decent at frontend/backend/reacty/nexty/nodey stuff but am a complete noob when it comes to any heavy lifting with algorithms. This is my first time doing AoC, really enjoying it. I can solve most of them with basic loops/brute force, though already have run into issues on day 5 pt 2 using this approach (thought 'oh this is easy, just generate a massive list of seeds using the ranges and then run the same loop'. Wouldn't even generate the seeds before the laptop threatened to explode :)).

Is so helpful to see how someone else approaches the problem from a more algorithmic angle - especially when the code is so well documented and clean.

Will be following along. Thanks again!

@delventhalz
Copy link
Owner

That’s genuinely lovely to hear, thank you.

And Day 5, part 2 was a bear! I don’t have a strong CS background, so often I’m the one brute forcing or feverishly googling algorithms. I somehow managed to come up with something on this one though.

delventhalz added a commit that referenced this issue Dec 12, 2023
This is my "cleaned up" solution. The initial solve was such a mess that
it didn't seem worth committing. This was an interesting problem. There
was no single "Aha!" moment, instead I started with a brute force
solution(which is still in Part 1), and then progressively refined it.
The three key refinements (in the order I applied them) were:

1. Only build valid permutations, aborting as soon as a possible
   permutation is invalid
2. Memoize
3. Don't actually build the valid permutations, just count them

At first, I saw no way to write #1... and honestly I still don't. But I
was able to get there step by step by working from simple test cases
and doing a lot of debugging. #2 was simple enough. Then, I finally
got #3 after staring at Node's memory usage for an hour or so, and
thinking over and over, "Man, this seems memory bound, not CPU bound."
Turns out, arrays of trillions of strings are pretty big.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants