string concatenation with all possibilities
-
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram
-
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram
sethupathiram wrote:
please share your ideas its very urgent for me
So what have you got so far? What code have you written? Which part is causing you a problem?
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram
Have a look at some of these and see what fits your needs best google: c# producing permutations of an array[^]
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram
This might help: Non-recursive Permutations and Combinations[^]
-
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram
Something like this should work:
static IEnumerable<T[]> BuildCombinations<T>(T[] input)
{
int length = input.Length;
int max = checked(1 << length);// Skip the first item, which would be completely empty.
// (If you want this item, start at zero.)for (int combination = 1; combination < max; combination++)
{
var current = new T[length];for (int index = 0, bit = 1; index < length; index++, bit <<= 1) { if ((combination & bit) != 0) { current\[index\] = input\[index\]; } } yield return current;
}
}...
string pattern = " INC | TRUST | COMPANY | 401K ";
string[] ArrPattern = pattern.Split('|');
List<string[]> allCombinations = BuildCombinations(ArrPattern);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Hi All, string pattren = " INC | TRUST | COMPANY | 401K "; string[] ArrPattern = pattren.Split('|'); above the string array i need to concatenate all the posibilities like below output, ex: INC PLAN COMPANY 401K INC PLAN COMPANY empty INC PLAN empty 401k INC PLAN empty empty INC empty COMPANY 401k INC empty empty 401k INC empty empty empty empty PLAN COMPANY 401k ... ... ... like these 16 combination.... please share your ideas its very urgent for me... Regards, Ram