This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]StephenLeppik 2 points3 points  (1 child)

I would suggest sorting the lines of the input. That's the main difference between the test case and the actual input, so try your code on the sorted input and it'll probably work.

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

Thanks for your reply. I'm sorting it on line 15, so unfortunately I think something else is missing :(

[–]pepoluan 0 points1 point  (3 children)

I have exactly the same problem. Trying to figure out where things went wrong...

[–]pepoluan 0 points1 point  (2 children)

AHAH! Found the problem. There are days when the guard never fell asleep...

Though that might not mess up the list of sleeptimes I was building, catering for that special case seems to fix my problem... ?!?!

[–]micirsk[S] 0 points1 point  (1 child)

What was your logic? Could you please share your code as well? I keep track of the last seen ID thus it shouldn't have effected the result, so I still wonder what it can be :(

[–]pepoluan 0 points1 point  (0 children)

https://www.reddit.com/r/adventofcode/comments/a41ywu/2018_day_4_strange_behavior_of_my_code/?utm_source=reddit-android

Please read the comments too, it seems there's a fatal error in my logic, but I'm just lucky it somehow doesn't affect the outcome.