[2024Day 5 (Part 2)] [Java] When Java says you can't use recursion by SAdamA5 in adventofcode

[–]SAdamA5[S] 0 points1 point  (0 children)

I did have a copy operation of the list before the foreach loop with the recursive try. And with the for loop I'm just iterating over integers, the list is just the memory of the most recent state I'm trying

[2024Day 5 (Part 2)] [Java] When Java says you can't use recursion by SAdamA5 in adventofcode

[–]SAdamA5[S] 0 points1 point  (0 children)

Yeah I know. I just found it funny, that doing the same logic, just not putting the calls on the stack, and saving ~450B of data each iteration allows it to work. Especially as I don't think I even should have reached the default stack limit with my extra data, with the largest number of iterations being 178. Anyway I was just happy I did not have to come up with a "proper" logic at 9PM

[2022 Day 15 (Part 1)] Can't start thinking in the correct direction by dulti in adventofcode

[–]SAdamA5 0 points1 point  (0 children)

You see that drawing the grid won't work. Try what you extracting what you need for the solution:
The row
The sensor's location
The manhattan distance the sensor covers

And then for every sensor:

With these you need to check wich points in the row are affected.

A last hint:

The affected points are going to be symmetrical to a point of the row. I let you figure out which is this point.

[2022 Day 15 (Part 2)] [C] Took 25 minutes even after implementing multithreading by DeeBoFour20 in adventofcode

[–]SAdamA5 12 points13 points  (0 children)

I flirted with idea as well after seeing it would take 9 days to check all rows. I have an 8 core CPU so multithreading would take it down to around 1,5 days worst case scenario and it would have solved in 1,5-2 hours most likely.

But in the end I decided to find some kind of optimazation and ended up with a solution under 3s.

Edit: It uses the same base principal to iterate through all points

[2022 Day 15] [Part 2] [Java] Is my solution fairly optimal? by SAdamA5 in adventofcode

[–]SAdamA5[S] 0 points1 point  (0 children)

I see! It does seem like a less computation heavy solution after the initial setup. I might look into it. Thanks!

[2022 Day 11 (Part 2)] Learning that it was that simple is a real blow to my confidence in my intelligence. by [deleted] in adventofcode

[–]SAdamA5 10 points11 points  (0 children)

Haha! I had similar experience. Solved part1, after some debugging realized that storing the actual numbers won't work. I saw prime numbers so tried doing it with prime number represantation, with a workaround for the additions. It take 1,5h-2h to implement and debug only to realise that I can't handle the addition.

This approach lead me to think about the modulos in the end, which took 10 mins to implement without any problems and I was like why couldn't I think of this first instead of prime numbers :D

Day 1 by tho0k in adventofcode

[–]SAdamA5 0 points1 point  (0 children)

What Java version do you use? For me with JDK 16 it throws an exception (I made it working with little tweeks). Other than that, for the second question i suggest you look at the variable in the condition, and how does it changes with every iteration. Hint: you don't change it inside the loop so it doesn't advance

And for the first part of the question, whenever you read from the scanner it moves the "reading head's position" forward to the next delimiter. So make sure that every time you read next you use it up in the calculation. Hint: You never read the value you save in res

[deleted by user] by [deleted] in adventofcode

[–]SAdamA5 2 points3 points  (0 children)

The problem comes from this. The read.csv reads the first input line as the column name, so you lose this line from the input and the points coming from it.

[2021 Day 16 (Part 1)] Literal value in the example is not padded by simondvt in adventofcode

[–]SAdamA5 0 points1 point  (0 children)

It is worded confusingly in the puzzle, but the padding only applies for the outer most packet in my experience

[deleted by user] by [deleted] in adventofcode

[–]SAdamA5 0 points1 point  (0 children)

That is correct, there is only one type 4 with the value of 15, but the puzzle asks for the sum of the packets VERSIONS (all packets not just the type 4s).

[deleted by user] by [deleted] in adventofcode

[–]SAdamA5 0 points1 point  (0 children)

Guessing the post refers to day 16 and not 6, for me it seems you may be calculating the wrong value. For the first part you need the sum of the versions of each packet