Lets say you've got N input elements, and you want a K-long combination.
All you need to do is to count in base N, scoped of course, to all numbers that have K digits.
So, lets say N = {n0, n1, ... nN}
You'd start from the number [n0 n0 ... n0], and count all the way up to [nN nN ... nN]
If you'd like help in understanding how to count in another base, you can get that here
Each number that you compute maps to one of the K-long combinations that you need.
I think an example will help
I'll use your values.
N = {a, b, c}
So we want to count in base 3.
Since we want 2-long combinations, we only care about 2-digit numbers.
The smallest 2-digit base 3 number is 00, so we start there. By counting in base 3, we get:
00
01
02
10
11
12
20
21
22
Ok, so now to convert these numbers into a combination.
Remember, our set is {a, b, c}
So whenever we see a 0, it implies 1. Wherever we see 1, it implies 2, and I'm sure you can guess what a 2 implies :)
00 aa
01 ab
02 ac
10 0 => a ba
11 1 => b bb
12 2 => c bc
20 ca
21 cb
22 cc
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…