Better HN
topnewbestaskshowjobs
Log inSign up

sandyfajita

2 karma · joined Mar 25, 2013 (13y ago) · 1 submissions

Submissions

comment 13y ago · link · parent

One can also use a disjoint-set data structure. Make a list of walls as tuples containing the "room number" (cell index) of both adjacent cells. Add all cells as disjoint sets in a disjoint-set data structure. Shuffle all the doors (tuples) randomly. Then go through the shuffled list and for each door: IF both sides are not part of the same set already: remove the wall. ELSE save the wall, it is part of the final maze.