Commit graph

2 commits

Author SHA1 Message Date
92df810943 Solve 2022 day 12 pt 1-2
BFS, baby.

2 things got me.

 * S position was not (0,0) in the puzzle input. Such embarrasment to
   loose time over something so stupid.
 * I asumed the elevation was fixed to to increase AND DECREASE by 1.

From the problem description:

> To avoid needing to get out your climbing gear, the elevation of the
> destination square can be at most one higher than the elevation of
> your current square; that is, if your current elevation is m, you
> could step to elevation n, but not to elevation o. _(This also means
> that the elevation of the destination square can be much lower than
> the elevation of your current square.)_

This means elevation only can _increase_ by one,
but _decrease_ with more.

So my wrong code:

0 <= abs(n - e) <= 1

got fixed with:

n - e <= 1

For pt 2, I reused the loop to find S to collect all "a" positions,
and looped them as starting points. Execution time is not the best,
but it works.
2025-11-30 19:17:15 +01:00
7b5c9c393b Inititate AOC 2022 in python 2025-11-30 19:17:15 +01:00