Well, when it rains, it pours. When I find myself on code ranch, it's usually because I have 5 or 25 questions, not just 1! Here I go again for the 2nd time in 2 days!
I'm looking for a tidy way to assemble every possible combination for arguments I'm feeding to a test.
I have, for example, and array of integers from 4, 7 (inclusive): [ 4, 5, 6, 7 ]
I'd like to basically build the power set. I find lots of useful stuff on the web for building a power set from an array in java. However, I want to include [ 4, 5 ] AND [ 5, 4 ]. A typical power set omits these, as they're considered duplicate. My tests does different things with the 1st or the second item in that subset, so I want to preserve "duplicates".
My current code is:
This code is not mine, it's adapted from Matt McPeak here: https://stackoverflow.com/questions/5162254/all-possible-combinations-of-an-array
This code is great, but it doesn't allow duplicates ( it includes [5, 6] but not [6, 5]). Any feedback is welcomed. Does this problem go by a different name?