Advent Of Code 2022 - Day 12: Hill Climbing Algorithm

This is a thread to discuss Day 12

It is VERY important NOT to write any public spoilers :slight_smile:
ALWAYS keep spoiler stuff hidden inside one of these


This text will be hidden

which you can obtain by clicking on the gear icon


1st attempt didn't finish even running overnight - too many paths :frowning:

trying again with a bit of code that hopefully will cut down on redundant paths

Spoiler alert

Dijkstra's algorithm should do the trick within seconds.
In this case I found no viable route from S to E.

I think if you found no viable route then maybe your algorithm isn't quite right :slight_smile:

I didn’t believe there could be none either, so I used the Pen library for making a picture of my program’s findings:

The characters correspond to the altitude of a location. Black means they can be accessed from S; red means they can not be accessed. S is one of the ‘a’s at the left rim of the picture, E is a ‘z’ in the middle of the large red ‘flower’. I don’t see any two adjacent characters bridging the black and red areas, do you?

No - I don't :frowning:

Not heard about something like this before!

At the end of this it says that you can go down as much as you want so once you get to the black "r" you can drop down to the red "p" and get to the end from there

I'd forgotton that rule :slight_smile:

Apparently I had misread that. Thanks for the hint!

Finally managed to come up with a workable algorithim that completed in a few hours :slight_smile:

I'll now go off and read about Dijkstra's algorithm to see if I've re-invented a wheel :slight_smile:

Part 1

Lots of debugging in the project so that doesn't help with its speed :slight_smile:
Snap! Build Your Own Blocks

Spoiler alert

Here’s my solution to part 2:

Snap! Build Your Own Blocks