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

AOC Day10 #1

Open
drade-on opened this issue Dec 10, 2021 · 1 comment
Open

AOC Day10 #1

drade-on opened this issue Dec 10, 2021 · 1 comment

Comments

@drade-on
Copy link

I've been using your solutions as a reference since day05
So far, your solutions have been the most concise I've seen
I am honestly learning a lot from your work (like indexOf() returning -1 !)
Would you mind putting some comments on your thought process / tips how you construct a solution ?
Or at least comment on the logic of the solution itself

Nonetheless, thank you Sir and keep up the work !

@constb
Copy link
Owner

constb commented Dec 13, 2021

Oh. Thanks!

I'm not sure I can help you with the thought process though. About day 10 specifically I remember that when I read the task, I immediately came up with this stack idea. The rest was just implementing it quickly to see if this works. I usually put test case to the input.txt first to see if result matches problem example and if it does I switch to actual input.

After solving both parts, I usually go to http://reddit.com/r/adventofcode/ to see this day's solution megathread. Oftentimes, there are better and simpler solutions than the one I came up with, so I learn from them too.

Day 10 in particular, there's another way, where you can use regexes to eliminate matching pairs like () repeatedly until there's nothing to eliminate. If the resulting line still contains closing braces, it's corrupted, otherwise it's incomplete. I feel this would be easier to write and maybe even less error-prone, but I didn't come up with it on the spot (which I find odd 'cause I love regexes 🙂). I usually try to compete for time (even when I'm late to the start), so the first solution that comes to mind is the one I put in code.

Basically, it's just some experience with algorithms and general problem solving that helps. I've also been programming professionally for over 20 years and personally since I've been 12, and my favourite subject in high school was math, so it's kinda my thing, you know. 🙂

So good luck for you and keep learning. Advent of code is pretty amazing as a learning tool…

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