Haskell, Genetic Algorithm, Graph Theory, Programming.
(exits, i) <- zip (topSide (tiles !! (n - 1))) [0 ..], dir `elem` exits ] connections = [ (1, S, 2, N), (1, SW, 2, NW), (1, SE, 5, NW), (2, NE, 5, SW), (2, SE, 6, NW), (2, S, 3, N), (2, SW, 3, NW), (3, NE, 6, SW), (3, SE, 7, NW), (3, S, 4, N), (3, SW, 4, NW), (4, NE, 7, SW), (4, SE, 8, NW), (5, NE,