-1
$\begingroup$

I need to calculate the combinations of elements with a substitution element.

For example for elements [A,B] if the substitution is X the results should be {[A,X],[X,B],[X,X]}. While this is easy enough to implement when the number of elements increase it becomes harder and error prone.

Is there an algorithm I can implement for this kind of combination calculations?

If this question is not a good fit for this site I do apologize, but this is the best site for an algorithmic question as far as I can tell.

EDIT :

I should have mentioned that all results should be of the same length as well.

$\endgroup$
  • 1
    $\begingroup$ This is the same as picking a subset and replacing the elements in the subset with X. $\endgroup$ – Herp Derpington Oct 1 '13 at 9:55
  • $\begingroup$ Make that an answer, I can work from there, thank you. $\endgroup$ – Thihara Oct 1 '13 at 10:27
  • 1
    $\begingroup$ This seems more suitable for Computer Science which has a broader scope, for the scope of Theoretical Computer Science please check tour and help center. $\endgroup$ – Kaveh Oct 1 '13 at 18:02
1
$\begingroup$

This is the same as picking a subset and replacing the elements in the subset with X

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.