This was a question from Infinix Hiring challenge, which ended few days ago.
You have N
distinct white balls, and want to paint balls in a red color, instead of painting all of them simultaneously, you decide to take turns. You paint the balls by following these steps:
- Choose
Q
balls from the bag - Paint the
Q
with red color - Put them back into the bag
Note: Among the chosen Q
, red balls remain red but white ones are converted to red
You take exactly K
turns. In other words, you follow the steps K
times. Given N
, Q
, K
, tell how no.of ways each number of balls are colored after K
turns. Your task is to determine the number of red balls in the bag after K
turns.
Two ways are considered different if the set of selected balls differ in at least one of the K
turns.
Sample Explanation: Lets say N = 3, Q = 2, K = 2, then there are 3 balls in the bag, you take 2 turns, and in each you chose 2 balls.
Lets number them 1 to 3, The possible ways are,
(1,2),(1,2) - Total colored are 2 - (1,2)
(1,2),(1,3) - Total colored are 3 - (1,2,3)
(1,2),(2,3) - Total colored are 3 - (1,2,3)
(1,3),(1,2) - Total colored are 3 - (1,2,3)
(1,3),(1,3) - Total colored are 2 - (1,3)
(1,3),(2,3) - Total colored are 3 - (1,2,3)
(2,3),(1,2) - Total colored are 3 - (1,2,3)
(2,3),(1,3) - Total colored are 3 - (1,2,3)
(2,3),(2,3) - Total colored are 2 - (2,3)
So there are 0 ways in which exactly 1 ball is painted red, 3 ways in which exactly 2 balls are painted, 6 ways in which exactly 3 balls are painted red.
What I tried: I started with small numbers, took 5 numbers (1,2,3,4,5) and Q = 2, K = 2.
(1,2)(1,2) = 2 from the first pair, 0 from the second = 2
(1,2)(1,[3|4|5]) = 2 from the first, +1 from the second = 3,
and this happens 3 times for each of the numbers mentioned in square braces,
and the same happens for the below one
(1,2)(2,[3|4|5]) = 2 + 1, happens 3 times
(1,2)(3C2 from [3|4|5]) = 2 + 2, happens 3C2 times
And this is true for all distinct 5C2 pairs. ( please correct me if I'm wrong )
Now 5 numbers, Q = 3, K = 2
(1,2,3)(1,2,3) = 2 + 0
Change in one number,
(1,2,3)(1,2,[4|5]) = 2 + 1 happens twice
Change in two numbers,
(1,2,3)(1,2C2) = 2 + 2 happens once
But when there are more than two turns i.e., when K is 3, I facing difficulties in finding method to make a formula, as I'm weak in Combinatorics.