Hacker News new | ask | show | jobs
by wishawa 1497 days ago
For the open question on bounded number of choices, the idea is still "count the number of smaller combinations".

Given a k-combination C, we first count the number of all possible combinations of less than k elements; this is binom(n, 0) + binom(n, 1) + ... + binom(n, k-1).

Then we simply add the number of smaller combinations that are of k elements; this is the N calculated by the formula in the blog.

The final answer is N' = binom(n, 0) + binom(n, 1) + ... + binom(n, k-1) + binom(C_k, k) + binom(C_{k-1}, k-1) + ... + binom(C_1, 1).