let intpairset_neighbours cave set =
IntPairSet.diff
(IntPairSet.fold
(fun (x,y) tosearch ->
List.fold_right
(fun (x,y) tosearch' ->
if not (inrangexy cave x y)
then tosearch'
else IntPairSet.add (x,y) tosearch')
(neighbour_coords (x,y)) tosearch)
set set) set