I have been struggling to find an efficient solution to my problem. I am working with tours, which basically are permutations of the numbers 1 to n (n is given).
Now I want to code an anonymous function* that would work as follows:
tour = [1 8 9 7 4 5 2 10 6 3];Next = nextNode(tour,2);Next2 = nextNode(tour,3);Prev = prevNode(tour,10);Prev2 = prevNode(tour,1);% result should be:
% Next = 10
% Next2 = 1
% Prev = 2
% Prev2 = 3
Any suggestions and solutions are welcome, thank you!
Best Answer