I'm mentally stuck at the following problem: I need an efficient algorithm to create possible hops along a chain.
The "real life" screnario is the following: You have a route with n stations. There can be different patterns of stops on this route, e.g. on a route where n=4, there are stops at station 1, 3 and 4.
I think this is nothing for the classical routing algorithms like Dijkstra's or A*, but I am very positive this is easy to solve ... but what is the most efficient way?
What would be an efficient algorithm to create these sets? The generated rows would look like the following:
var sets = [
stationCount2: [
[0, 1]
],
stationCount3: [
[0, 2],
[0, 1, 2]
],
stationCount4: [
[0, 3],
[0, 1, 3],
[0, 2, 3],
[0, 1, 2, 3]
],
stationCount5: [
[0, 4],
[0, 1, 4],
[0, 2, 4],
[0, 3, 4],
[0, 1, 2, 4],
[0, 1, 3, 4],
[0, 2, 3, 4],
[0, 1, 2, 3, 4]
]
];
Or is there a "known" algorithm for that?