FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Forum index » Science and Technology » Math » Combinatorics
Small algorithm needed...
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
saad
science forum beginner


Joined: 01 Feb 2006
Posts: 11

PostPosted: Sun Jul 02, 2006 10:43 pm    Post subject: Small algorithm needed... Reply with 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++
thanks
Back to top
Matthias Klaey
science forum beginner


Joined: 22 Oct 2005
Posts: 3

PostPosted: Mon Jul 03, 2006 12:03 am    Post subject: Re: Small algorithm needed... Reply with quote

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

PostPosted: Mon Jul 03, 2006 1:48 pm    Post subject: Re: Small algorithm needed... Reply with quote

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

PostPosted: Mon Jul 03, 2006 11:26 pm    Post subject: Re: Small algorithm needed... Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Mon Jun 26, 2017 10:39 pm | All times are GMT
Forum index » Science and Technology » Math » Combinatorics
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts how to deduce a number validation algorithm? Tim_Mac Math 1 Fri Jul 21, 2006 10:43 am
No new posts Intersection between a small and great circle christriddle@googlemail.c Math 11 Mon Jul 17, 2006 2:43 pm
No new posts Small Inflatable Air Bags John Eric Voltin Mechanics 4 Fri Jul 14, 2006 3:23 pm
No new posts Name of algorithm for pairwise comparison ? Paul Nutteing Math 10 Fri Jul 14, 2006 6:55 am
No new posts Need an algorithm Dave111 Math 4 Fri Jul 14, 2006 2:19 am

Copyright © 2004-2005 DeniX Solutions SRL
Other DeniX Solutions sites: Electronics forum |  Medicine forum |  Unix/Linux blog |  Unix/Linux documentation |  Unix/Linux forums  |  send newsletters
 


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0218s ][ Queries: 16 (0.0049s) ][ GZIP on - Debug on ]