I have strings like 1,2|3,4 and 1|2,3|4 and need to get the following permutations out of them (as an array/list).
Given 1,2|3,4 need to get 2 strings: 1,2,4 1,3,4
Given 1|2,3|4 need to get 4 strings: 1,3 1,4 2,3 2,4
It is basically splitting on the commas and then if those elements have a pipe create permutations for every pipe delimited sub-element (of the remaining elements). The solution needs to handle the general case of an unknown number of elements with pipes.
Interested in any solution that uses standard C# libraries.
Getting stuck on this one so searching for some thoughts from the community. I can't seem to get past the element with pipes...its almost like a "look ahead" is needed or something as I need to complete the string with the remaining comma separated elements (of which some may have pipes, which makes me think recursion but still can't wrap my head around it yet).
Ultimately order does not matter. The comma and pipe delimited elements are numbers (stored a strings) and the final string order does not matter so 1,2,4 = 1,4,2
And no, this is not homework. School ended over a decade ago.
or, so in the first example, 1 and (2 or 3) and 4. And in the second case (1 or 2) and (3 or 4)