Author 
Message 
saad science forum beginner
Joined: 01 Feb 2006
Posts: 11

Posted: Sun Jul 02, 2006 10:43 pm Post subject:
Small algorithm needed...



I am working on a small private project in c++, and need following
algorithm on the fly.
I need to be able to generate a list of all possible
combinations for a set of numbers. k = amount of spaces
t = highest number
l = lowest number
I need a function that will give all possible combonations of k spaces
with numbers from l to t ex. l = 0 , t = 1, with k = fixed interger,e.g
5 here.
00000, 00010, snip , 11111
so numbers will be able to repeat them selves.
Like I said before I need ALL POSSIBLE COMBANATIONS and no repeateing
combanations in the list.
It would be good if code is in C++
thanks 

Back to top 


Matthias Klaey science forum beginner
Joined: 22 Oct 2005
Posts: 3

Posted: Mon Jul 03, 2006 12:03 am Post subject:
Re: Small algorithm needed...



saad.qaisar@gmail.com wrote:
Quote:  I am working on a small private project in c++, and need following
algorithm on the fly.
I need to be able to generate a list of all possible
combinations for a set of numbers. k = amount of spaces
t = highest number
l = lowest number
I need a function that will give all possible combonations of k spaces
with numbers from l to t ex. l = 0 , t = 1, with k = fixed interger,e.g
5 here.
00000, 00010, snip , 11111
so numbers will be able to repeat them selves.
Like I said before I need ALL POSSIBLE COMBANATIONS and no repeateing
combanations in the list.
[...] 
I'm sorry this is *very* unclear. Could you please expand? What values
of l and are possible? What kind of ouput do you expect if l = 345197
and t = 558191234?
Greetings
Matthias Kläy

www.kcc.ch 

Back to top 


saad science forum beginner
Joined: 01 Feb 2006
Posts: 11

Posted: Mon Jul 03, 2006 1:48 pm Post subject:
Re: Small algorithm needed...



its like this:
In my approach to fill in the spaces, if i decide to have two ones say
1 and 1^ where 1=1^, and three zeros, then i need to generate all
permutations of these without considering the case of 101^00 and
1^0100 as two seperate cases. One shortcut is to check their decimal
val, if same as some already existing, just consider them once. Though
i was looking for a bit smarter way...
Matthias Klaey wrote:
Quote:  saad.qaisar@gmail.com wrote:
I am working on a small private project in c++, and need following
algorithm on the fly.
I need to be able to generate a list of all possible
combinations for a set of numbers. k = amount of spaces
t = highest number
l = lowest number
I need a function that will give all possible combonations of k spaces
with numbers from l to t ex. l = 0 , t = 1, with k = fixed interger,e.g
5 here.
00000, 00010, snip , 11111
so numbers will be able to repeat them selves.
Like I said before I need ALL POSSIBLE COMBANATIONS and no repeateing
combanations in the list.
[...]
I'm sorry this is *very* unclear. Could you please expand? What values
of l and are possible? What kind of ouput do you expect if l = 345197
and t = 558191234?
Greetings
Matthias Kläy

www.kcc.ch 


Back to top 


Proginoskes science forum Guru
Joined: 29 Apr 2005
Posts: 2593

Posted: Mon Jul 03, 2006 11:26 pm Post subject:
Re: Small algorithm needed...



saad.qaisar@gmail.com wrote:
Quote:  I am working on a small private project in c++, and need following
algorithm on the fly.
I need to be able to generate a list of all possible
combinations for a set of numbers. k = amount of spaces
t = highest number
l = lowest number
I need a function that will give all possible combonations of k spaces
with numbers from l to t ex. l = 0 , t = 1, with k = fixed interger,e.g
5 here.
00000, 00010, snip , 11111
so numbers will be able to repeat them selves.
Like I said before I need ALL POSSIBLE COMBANATIONS and no repeateing
combanations in the list.
It would be good if code is in C++

Google is your friend. Googling for "generate combinations c++" yields
many links, one good one appearing to be:
http://www.scs.fsu.edu/~burkardt/cpp_src/subset/subset.html
 Christopher Heckman 

Back to top 


Google


Back to top 



The time now is Mon Jun 25, 2018 4:24 am  All times are GMT

