This is my attempt at Dijkstra's algorithm: code.
The graph I'm working on here is one where the nodes are given by the position + current collected keys, where the position can be at any of the key positions (and the start position @). It's still searching too many of the nodes for it to finish in a reasonable time.