Unable to load image

Day 12

Post code, nerds.

14
Jump in the discussion.

No email address required.

butt: moderately washed

matlab (:gigachad2:)

idk what a* is or whatever so I just dijkstra'd the first part, slapped a for loop for the second part, and optimized it by making only one dijkstra from the end to the start, which finds the start and the optimal starting point.

The code is still a bit messy and I have absolutely no idea why it only works when I take out the last element of my priority queue instead of the first, regardless of the sorting order (that was true for the forward dijkstra too so it's not that)

![](/images/16708750886478238.webp)

Jump in the discussion.

No email address required.

Why do you people do Dijkstra on unweighted graphs?

Fun fact: the i, j, k naming convention for loop variables was invented by Dijkstra, after his own surname.

Jump in the discussion.

No email address required.

Because that's the only one I've ever learnt :gigachad3:

Jump in the discussion.

No email address required.

It's just that

def wave(start, neighbors):
     front = deque(start)
     visited = {}
     while front:
            node = front.popleft()
            for n in neighbors(node):
                   if n not in visited:
                         visited[n] = node
                         front.add(n)
      return visited

is so dead simple I just wrote it.

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.