TS is talking about combinations (https://en.wikipedia.org/wiki/Combination).And here is some theory how to solve his problem: https://en.wikipedia.org/wiki/Combinatorial_number_system.