Hello.
So, I am still working on Day 1 Part 2 and I can't get myself figuring out the solution alone. After solving part 1, I tried a different approach for part 2 and in the start It seemed it may work. But still after many attempted fixes It still tells me got the wrong number and I can't tell where could be the problem.
I'm very new to programming and my coding is pretty crippled. I hope asking for help will allow me to identify the problems in the code.
#AOC: Help for Day 1 Part 2
1 messages · Page 1 of 1 (latest)
I uploaded your attachments as Gist.
<@&987246399047479336> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
heory it should work, but I'm not getting the correct answer. Can you provide me with some guidance or hints on how to solve it?
Sure! I'd be happy to help you with Day 1 Part 2.
In Part 2, you need to find three numbers from the input file that sum up to a specific target value. The target value is the sum of two numbers you found in Part 1.
To solve this problem, you can use a nested loop approach. Here's a step-by-step guide:
-
Start by reading the input file and storing all the numbers in a list or array.
-
Iterate over each number in the list using the first loop.
-
Inside the first loop, use a second loop to iterate over all remaining numbers after the current number in the first loop.
-
Inside the second loop, use a third loop to iterate over all remaining numbers after the current number in the second loop.
-
In each iteration of the third loop, check if the sum of all three numbers (current number from first loop + current number from second loop + current number from third loop) equals your target value.
-
If you find a match, print out those three numbers and their product (multiply them together).
-
Continue iterating until you find all possible combinations or until there are no more valid combinations left.
This nested loop approach will check every possible combination of three numbers from your input list and find the ones that sum up to your target value.
Remember to handle cases where there might not be any valid combinations or where multiple combinations exist. You can choose how you want to handle these cases based on your specific requirements for this problem.
I hope this helps! Let me know if you have any further questions or need additional clarification.
have a look at the text u are given, there are a few things 'hidden' in it numberwise
it wont be fair to list em here, but u can scroll back in #advent-of-code-spoilers
Thanks! Then I guess I'll check the channel more deeply.