+dijkstra :: S.Set Coord -> Distances -> Doors -> Distances
+dijkstra boundary distances doors
+ | S.null boundary = distances
+ | otherwise = dijkstra boundary' distances' doors
+ where (hereSet, others) = S.splitAt 1 boundary
+ here = S.findMin hereSet
+ nbrs = neighbours here doors
+ distance = distances!here
+ distance' = distance + 1
+ unseenNbrs = S.filter (\n -> M.notMember n distances) nbrs
+ boundary' = S.union others unseenNbrs
+ distances' = S.foldl (\d n -> M.insert n distance' d) distances unseenNbrs
+
+possibleNeighbours :: Coord -> S.Set Coord
+possibleNeighbours here = S.fromList $ map (+ here) [V2 0 1, V2 0 (-1), V2 1 0, V2 (-1) 0]
+
+neighbours :: Coord -> Doors -> S.Set Coord
+neighbours here doors = S.filter doorExists nbrs
+ where nbrs = possibleNeighbours here
+ doorExists there = S.member (makeDoor here there) doors
+
+
+
+-- S.intersection doors $ possibleDoors
+-- where possibleDoors = S.map (makeDoor here there) $ possibleNeighbours here
+