Algorithm for Determining Variations of Differing Lengths
Posted
by joseph.ferris
on Stack Overflow
See other posts from Stack Overflow
or by joseph.ferris
Published on 2010-06-08T18:17:42Z
Indexed on
2010/06/08
18:22 UTC
Read the original article
Hit count: 248
I have four objects - for the sake of arguments, let say that they are the following letters: A B C D
I need to calculate the number of variations that can be made for these under the following two conditions:
- No repetition
- Objects are position agnostic
Taking the above, this means that with a four object sequence, I can have only one sequence that matches the criteria (since order is not considered for being unique):
- ABCD
There are four variations for a three object combination from the four object pool:
- ABC, ABD, ACD, and BCD
There are six variations for a two object combination from the four object pool:
- AB, AC, AD, BC, BD, and CD
And the most simple one, if taken on at a time:
- A, B, C, and D
I swear that this was something covered in school, many, many years ago - and probably forgotten since I didn't think I would use it. :-) I am anticipating that factorials will come into play, but just trying to force an equation is not working.
Any advice would be appreciated.
© Stack Overflow or respective owner