P
pauljwilliams
Hi there,
I'm looking for an algorithm that will generate combinations in the
following way:
Given a lower bound, and an upper bound, generate a set of size n
containing all combinates of numbers between the bounds.
e.g if lower_bound = 5, upper bound = 7, size = 3, the algorithm would
generate:
555
556
557
565
566
567
575
576
577
655
etc.....
(in an ideal world i'd eliminate dupes as well, so 557 wont be produced
as well as 575).
I thought initially of generating a 'master set' such as '555666777',
and running next_permutation on it to get all the subsets, just taking
the first 3 each time, but in the biggest case( 9 numbers, 1 to 9) this
would take ages.
Is there a simple way?
I'm looking for an algorithm that will generate combinations in the
following way:
Given a lower bound, and an upper bound, generate a set of size n
containing all combinates of numbers between the bounds.
e.g if lower_bound = 5, upper bound = 7, size = 3, the algorithm would
generate:
555
556
557
565
566
567
575
576
577
655
etc.....
(in an ideal world i'd eliminate dupes as well, so 557 wont be produced
as well as 575).
I thought initially of generating a 'master set' such as '555666777',
and running next_permutation on it to get all the subsets, just taking
the first 3 each time, but in the biggest case( 9 numbers, 1 to 9) this
would take ages.
Is there a simple way?