You are viewing a single comment's thread. Return to all comments →
Python Code for finding neighbours from a node.
def Neighbours(ls): visited = set() illegal = set() count = 0 for i in range(len(ls)-1, -1,-1): if ls[i] == 1: count += 1 else: break for i in range(len(ls)-count): if ls[i] not in illegal: for j in range(1, 5): if ls[i] != j and j not in illegal: temp = ls.copy() temp[i] = j visited.add(tuple(temp)) illegal.add(ls[i]) return list(visited)
Seems like cookies are disabled on this browser, please enable them to open this website
Gena Playing Hanoi
You are viewing a single comment's thread. Return to all comments →
Python Code for finding neighbours from a node.