Problem: calculate how many unique "words" can be made using the letters of your
a) name (Kateryna - 8 letters, letter 'a' used twice)
b) lastname (Atamanchuk - 10 letters, letter 'a' used 3 times)
Typically, this is when we use a formula:
C^n(k1, k2, k3, ..., km) = n! / (k! * k2! * ... * km!)
and solutions would be respectively:
a) 8! / 2! = 7! * 4
b) 10! / 3! = 8! * 3
but this time we are looking for words of lengths in range [1, n] where n is the length of the 'source-word' (e.i. name or lastname), as if you had cards with the letters K A T E R Y N A and you could make words like YN, TER, RAKY, N, etc. This is rather simple when no letters are given more than once, but when there are repetitions (like 2 and 3 'a' in my name) I just can't handle this.
The actual task behind this is to find an algorithm that would let you design a formula for, say, "Find how many words of length 4 can be made from letters of VANILLAINK", that way by generating such formula for each length of the words to be made of using a certain number of repeated letters (say, 2 'a', 3 'b', 1'k', 1'l', etc). I gave it a lot of thought, and my teacher says I should've figured this out in 20 minutes, I think I am losing my mind :)