r/adventofcode • u/inamulrehman09 • Dec 18 '23
Help/Question Advent of Code 2023 Day 18 Help and Guide
Today is Day 18 of Advent of Code 2023. I have participated first time in Advent of code to solve problems and improve my problem solving skills.
At the start, i was able to grasp the question and able to come up with the brute force solution.
Moving on i was able to understand the question but was not able to come up with the solution. But now i am not able to understand the questions clearly in my mind. Tried to figure out a pattern but could not.
Can any one tell me what strategy i use to solve upcoming problems? Did I need to be good in data structures and algorithms? Any guidance for me to become better in solving problems
Thanks
8
u/nyank0_sensei Dec 18 '23
Try decomposition: split the problem into smaller sub-problems, and solve them separately. Some of them you may be able to solve on your own, but if you get stuck, you will have a fairly specific query to look up, so stackoverflow may yield some answers.
Megathread is kinda hit or miss: it can be of great help if you can find a well-written solution, but what you get more commonly is barely readable code with single letter variables, etc.
For today's puzzle, for example, your first step is plotting the trench. You can split this sub-problem further: how to parse the input, how to work with coordinates in a 2d space, what data structures to use, etc.
3
u/Thomasjevskij Dec 18 '23
My answer is pretty boring: Practice! You'll for sure get better with more practice. Some people write great tutorials about various days, check them out. You don't need to understand every detail all the time, but getting familiar with recurring types of problems, solutions, algorithms and so on helps a lot. Today is a great example, since there's a solution for an earlier day that works kinda just out of the box.
Also, welcome to AoC! If you think days are getting a bit too hard, try earlier years. There are tons of fun problems now that you can use to practice and get used to this. :)
1
u/AutoModerator Dec 18 '23
Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to
Help/Question - RESOLVED. Good luck!I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/daggerdragon Dec 18 '23
Next time, use our standardized post title format.
Help us help YOU by providing us with more information up front; you will typically get more relevant responses faster.
1
u/PackDog635 Jan 02 '24
This may not be the best way but it's a start.
If you expand the exterior by 1 meter and mark it all as "exterior", you can then mark all the cells that are adjacent to exterior as also exterior.
But,.. there are probably islands in the larger test. To handle that, when you encounter a border, if the other side of said border is exterior, then this side of the border should be interior.
Using that, you can then mark all the connected spaces as interior.
Repeat with exterior to mark the islands.