By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,631 Members | 892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,631 IT Pros & Developers. It's quick & easy.

combinations of a string ?

P: n/a
i have been trying to build a program to find various combinations of a string.
the problem is that if there are multiple similar characters in the string
then the program displays multiple similar combinations. how could i overcome
this ...comparing each o/p doesn't seem feasible.
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
M a n i s h wrote:
i have been trying to build a program to find various combinations of a string.
the problem is that if there are multiple similar characters in the string
then the program displays multiple similar combinations. how could i overcome
this ...comparing each o/p doesn't seem feasible.


This is more of a programming issue than a C language issue.
Next time, C language issues are answered in this newsgroup,
general programming issues in news:comp.programming.

Although your requirements are a bit vague, try creating a
set of all the characters in the string (the set should
allowing only unique characters). Next, generate
combinations of all the letters in the set.

As for duplicate letters, you may want to make the elements
in your set like <letter, quantity>. The quantity will
let you know how many times you can repeat a letter.

As far as repeating goes, you may want to stick in some
advanced rules which filter out unused combinations of
letters, such as "ttt" or "eee". But this depends on
you language.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.