summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2019/20.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/2019/20.hs b/2019/20.hs
index 8deb4e8..1f51c46 100644
--- a/2019/20.hs
+++ b/2019/20.hs
@@ -23,7 +23,9 @@ shortestPath nextf heuristic startnode target = go 0 (Set.singleton (heuristic s
visited' = Map.insert node dist visited
in if node == target
then dist
- else go (ctr + 1) pqueue' visited'
+ else if maybe True (dist <) (Map.lookup node visited)
+ then go (ctr + 1) pqueue' visited'
+ else go (ctr + 1) newpqueue visited
main :: IO ()
main = do