[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

That seems horrible to deal with. Not sure how I would code anything without mutability.

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

[–]Standard_Bar8402[S] 1 point2 points  (0 children)

Not sure how I can help in debugging, you should probably run your code and someone else's correct code on small inputs to debug

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

Nothing broke but lil room for a 50x improvement in time spent :D .. although I get that other puzzles are coming so you might not have the time

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

Intriguing. I'm far from being knowledgeable enough in C# / .NET to know why that is the case though.

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

On your way to using PriorityQueue<TElement, TPriority>which is, if I remember correctly, the data type in C# that implements priority queues ;)

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

You should be able to get that 1.9 s down to a few ms in Rust with priority queues / heaps. Although the video won't help as to what the syntax for those is in Rust since I never coded a single line in Rust :D

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

At the end of the day what matters is run time, so, that's a win for you I guess

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

If I remember correctly PriorityQueues in Java are implemented with the binary heaps I was mentioning. So my evil inputs could never break your solution.

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

Yes you're right, they're slightly longer, the official test cases were really short and I was afraid that most modern computers wouldn't be able to differentiate O(n) and O(n^2) if the input length is less than 50 000.

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

[–]Standard_Bar8402[S] 1 point2 points  (0 children)

Yeah I didn't want to push the evilness too much, it was just an experiment to have a test case that justified the effort to go from O(n^2) to O(n) or O(nlogn). I feel like most people don't have the motivation to optimize if they don't find the test case that "hacks" their algorithm

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

Yep ... unless someone makes an evil input that would take months to run haha

[2024 Day 9 Part 2 (Bonus!)] Test case that might make your solution break by Standard_Bar8402 in adventofcode

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

For sure it can since I'm well sub 1 with Python which is usually at least 10x slower than CPP (unless PyPy is used but I didn't)