Skip to main content
r/adventofcode icon

r/adventofcode

members
online

[2024, day 1, part 1, C] [2024, day 1, part 1, C]
Help/Question - RESOLVED

Hi,

My understanding of the problem was that I am supposed to read every input line (which contains two lists) sort them in ascending order, then compute the distance between each point and add it to a total sum.

I printed out my variables and verified that my program is doing this correctly, but I still get the wrong answer.

This leads me to think that I have misunderstood the question. I watched some solution videos, but I am still confused.

Would anyone be kind enough to look at my code and help me find what I'm doing wrong. Thanks.

Advent_of_code/day1.c at main · nrv30/Advent_of_code


Missed our AMA with Alain Massicotte, Director of Design and Innovation? No sweat! It was a wild ride of awesome questions and even better answers.
Missed our AMA with Alain Massicotte, Director of Design and Innovation? No sweat! It was a wild ride of awesome questions and even better answers.


[2024 Day 5 (Part 2)] What? [2024 Day 5 (Part 2)] What?
Spoilers

I've been bamboozled. The question asks to find a correct page ordering for each input, but the problem statement itself does not guarantee that such an ordering exists. So, I can only assume that each input is chosen in a way that there's a unique correct ordering based on the set of rules. Do y'all not consider this to be broken? I mean, I was expecting a programming puzzle, I got a linguistic dilemma whether saying “find the correct ordering” implies that such correct ordering exists and is unique.

Editing to add another example of the hidden assumptions that are confusing to me. The goal is to find a middle page, but it's not stated that the number of pages is always odd. My first thought is, how can you talk about a middle page without first making sure that the notion of a middle page is well defined? What if the number of pages is even, which is a possibility that's not excluded anywhere in the problem statement?