Day 4: Perilous Pier
Megathread guidelines
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
FAQ
- What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
- Where do I participate?: https://adventofcode.com/
- Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465


Elixir
Hmm, my solution (although not really clean) works for the test input but not for the real input (answer is too low). Also looked around for some more codes to test but it works for those too. Anyone got additional tips what to try?
My approach is to first disassemble each code and then with increasing instruction length check for each legible character if there are any interference with this length, both looking ahead and behind. After that I take the minimum length where that didn’t result in collisions.
code
I had that too, luckily for me I didn’t need to drbug but only paste the correct number.
What do you mean by “disassemble” the input?
By disassemble I mean that I’m not working with the input string itself but transforming it into one list of all the positions of the illegible characters and one map with all the legible ones and their position.
I think I’ll have another look and compare the results I get with with what they should be for specific codes. I tried just putting in a number about 50 higher than my result and it was still too low so I’m not just off by one.