How to Finding Solutions
-
Hello Experts, If i have a string "abc". then how can i get the shown output a b c ab bc ac abc In this output i do't need of ba or cab or cba. Thanks
If you can think then I Can.
Is this, what you are looking for?
string value="abc";
string result=string.Empty;for(int i=0;i<=value.Length-1;i++)
{
result+=value[i].ToString()+"\n";
}for(int i=0;i<=value.Length-1;i++)
{
if(i
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post. -
Hello Experts, If i have a string "abc". then how can i get the shown output a b c ab bc ac abc In this output i do't need of ba or cab or cba. Thanks
If you can think then I Can.
-
Hello Experts, If i have a string "abc". then how can i get the shown output a b c ab bc ac abc In this output i do't need of ba or cab or cba. Thanks
If you can think then I Can.
A double iteration over the input string with position and substring length :
string str = "anystring"; for (int x = 1; x <= str.Length; x++) // x = substring length { for (int y = 0; y <= str.Length - x; y++) // y = start position { Console.WriteLine(str.Substring(y, x)); } }
Cheers
-
A double iteration over the input string with position and substring length :
string str = "anystring"; for (int x = 1; x <= str.Length; x++) // x = substring length { for (int y = 0; y <= str.Length - x; y++) // y = start position { Console.WriteLine(str.Substring(y, x)); } }
Cheers
-
Is this, what you are looking for?
string value="abc";
string result=string.Empty;for(int i=0;i<=value.Length-1;i++)
{
result+=value[i].ToString()+"\n";
}for(int i=0;i<=value.Length-1;i++)
{
if(i
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post. -
The Length of value is not fixed for 3 it can be increase and the result will be change according to input. then how can i do that.
If you can think then I Can.
Length of string is dynamic too on my example. Did you try my code to see result? Which is result for you if the string is
"abcd"
I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post. www.cacttus.com
-
Hello Estys, Thanks for your solution.But it is missing values. Input : ABC Output : A B C AB BC CA // Missing Value SO pls provide the solution for that.
If you can think then I Can.
-
Hello Experts, If i have a string "abc". then how can i get the shown output a b c ab bc ac abc In this output i do't need of ba or cab or cba. Thanks
If you can think then I Can.
I found some good links : 1. http://n1b-algo.blogspot.com/2009/01/string-permutations.html[^] 2. http://geeksforgeeks.org/?p=767[^] 3. http://stackoverflow.com/questions/361/generate-list-of-all-possible-permutations-of-a-string[^] Hope this helps. All the best.
-
I found some good links : 1. http://n1b-algo.blogspot.com/2009/01/string-permutations.html[^] 2. http://geeksforgeeks.org/?p=767[^] 3. http://stackoverflow.com/questions/361/generate-list-of-all-possible-permutations-of-a-string[^] Hope this helps. All the best.
-
I didn't see the "CA" value, ouch! Can you give an example of the expected output if the input is "ABCD"? Or perhaps describe the situation in words? I suspect you're going to need some recursive algorithm. Cheers
-
I didn't see the "CA" value, ouch! Can you give an example of the expected output if the input is "ABCD"? Or perhaps describe the situation in words? I suspect you're going to need some recursive algorithm. Cheers
-
Length of string is dynamic too on my example. Did you try my code to see result? Which is result for you if the string is
"abcd"
I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post. www.cacttus.com
-
CA wasn't in the initial spec, but AC was. The OP needs to better define what the problem actually is (and why he wants to solve it beyond 'my homework says so').
You're right of course from a professional viewpoint. Some people, non-native english speakers, have trouble finding the right phrasing of the question though, which leads to this kind of confusion. I took a look at his profile, very interesting. Personally, I usually like solving these kindergarten puzzles, even if it sounds like homework :) . Cheers
-
Estys wrote:
input is "ABCD"?
Same question I asked :)
I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post. www.cacttus.com
-
Is this, what you are looking for?
string value="abc";
string result=string.Empty;for(int i=0;i<=value.Length-1;i++)
{
result+=value[i].ToString()+"\n";
}for(int i=0;i<=value.Length-1;i++)
{
if(i
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post. -
Hello Experts, If i have a string "abc". then how can i get the shown output a b c ab bc ac abc In this output i do't need of ba or cab or cba. Thanks
If you can think then I Can.
-
Hello Experts, If i have a string "abc". then how can i get the shown output a b c ab bc ac abc In this output i do't need of ba or cab or cba. Thanks
If you can think then I Can.
What you're looking for is the power set of "abc" (http://en.wikipedia.org/wiki/Power_set[^] ) If you go through all the 3-bit numbers (000, 001, 010, 011...) (i.e. the power set) and use the letters corresponding to 1's, that will give you all the permutations.
-
You're right of course from a professional viewpoint. Some people, non-native english speakers, have trouble finding the right phrasing of the question though, which leads to this kind of confusion. I took a look at his profile, very interesting. Personally, I usually like solving these kindergarten puzzles, even if it sounds like homework :) . Cheers
-
I think he is asking combination.....
I quit being afraid when my first venture failed and the sky didn't fall down.