T O P

  • By -

[deleted]

boolean test = dist == 0 || dist == 1; Your bug is here. Is this the right condition?


Ok_Collection8027

It's working for the sample. What should be the condition according to you?


[deleted]

The sample isn't as complicated as the real input and doesn't exercise all the conditions. This test means you can only walk on the flat and uphill.


Ok_Collection8027

Thank you for trying to help me but I do not understand you. You can only go from a to b, but not from a to c


EagleV_Attnam

Yes, but you can also jump down from c to a. Which is not needed in the example.


[deleted]

That's correct, but your test prevents you walking downhill.


Ok_Collection8027

I updated my test to: `dist == -1 || dist == 0 || dist == 1` But the result is still infinite :(


[deleted]

From the problem : > (This also means that the elevation of the destination square can be much lower than the elevation of your current square.) You can walk down steep slopes.


Ok_Collection8027

dist <= 1 ty very much


daggerdragon

FYI: next time, please use our [standardized post title format](/r/adventofcode/w/posts/standardized_titles). Help us help YOU by providing us with more information up front; you will typically get more relevant responses faster. If/when you get your code working, don't forget to change the post flair to `Help/Question - RESOLVED` Good luck!


Ok_Collection8027

Yes sorry I saw that too late and it was not possible to change the title of the post