2

I'm looking for an algorithm that can calculate N paths from K set where N=10 and K=32. This is not a combinatory algo, I don't need every number in every position.

So basically I need to be able to find the distinct paths of up to 10 elements in a collection of 32.

Edit: If I have a set of numbers

{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}

I would like to get every unique path of 10. So an example would be

Path 1 {1,2,3,4,5,6,7,8,9,10}
Path 2 {1,2,3,4,5,6,7,8,9,11}
Path 3 {1,2,3,4,5,6,7,8,9,12} 

Down the line I would like something like this:

Path N { 3,5,6,8,9,12,14,17,18,19 }

Since I need every possible path consisting of 10 elements from the larger set.

Payson Welch
  • 337
  • 4
  • 11

1 Answers1

1

This has been answered here :

Algorithm to return all combinations of k elements from n

Note that you will get 64512240 paths. You may want to think a bit about it before filling your RAM with them.

Community
  • 1
  • 1
vib
  • 2,254
  • 2
  • 18
  • 36