I took part in a coding contest organized by a club in my college for freshers, In one of the problems it was asked to find out the minimum number of partitions of a number $n$, so that all the integers from $1$ to $n$ can be formed such that the partitions are minimum. For such a problem, I couldn't find anything in searching, and I don't know what to search exactly.
The solution is not satisfactory to me at all, in short, it uses the fact that Strong Induction Proof: Every natural number = sum of distinct powers of 2 and then eerily uses $(7)_{10} = (111)_2$ as an example, saying, from $1, 2, 4$ we can make all integers till $7$, which is true. But this just added more to my confusion.
At the beginning, I got confused with binary representation and since the question on which the answer is based, I couldn't refrain from asking Why not base 3? (I got the answer: because base 3 won't have distinct powers, so it won't be minimum) (1)
Since it is hard to check for even a small test cases, I wrote a program to get more insights, and indeed, minimum number of partitions are the digits in binary representation of $n$, and that the numbers seem arbitrary. Therefore, I think that there might be some link to base $2$, but the way it is being used and explained to me by my peers and seniors might be incorrect.
My approach:
We could use generating function for an arbitrary number of partitions say $k$, (2)
so the generation function would be: $$ (1 + x^{p_1})(1 + x^{p_2})\cdots(1 + x^{p_k}) = 1 + a_1x + a_2x^2+\ldots+a_kx^k$$ where each $p_i$ is the $i^{\text{th}}$ number and $p_1 + p_2 +\ldots+p_k = n$
If we somehow proof that each $a_i > 0$, and then find the minimum condition, we'll be done.
on solving the expression, Differentiation can be hectic, if try to find a pattern by expanding it comes out to be $$ 1 + \sum_{i = 1}^kx^{p_i} + \sum_{i,j = 1}^kx^{p_i + p_j} + \ldots + x^{p_1 + p_2 +\ldots+p_k}$$ ...which doesn't give any lead. And of course, numbers can repeat, which can be even more problematic.
Hence, I'm stuck at the very beginning itself.
My questions are:
- There is obviously some link to powers of $2$, but why? and why only $2$?
- would my approach (finding a pattern first, then trying to find the minimum condition) actually work?
Some partitions that satisfy the conditions:
$\begin{align} 8 &= 4 + 2 + 1 + 1 \\ &= 3 + 3 + 1 + 1\\ &= 3 + 2 + 2 + 1 \end{align}$
$ \begin{align} 9 &= 5 +2 +1+ 1\\ &=4 +3 +1 +1 \\ &=4+ 2+ 2+ 1\\ &=3 +3+ 2+ 1 \end{align}$
$\begin{align} 14 &= 7+4+2+1 \end{align}$
Note: I know minimum partitions are $\lfloor \log_2(n) \rfloor + 1$, I want to know HOW.
How did you get the intuition to use the first inequality of n, to begin with?
And, can we be sure if the number of sums $2^k$, cover everything from $1$ to $n$? – Sarthak Jan 15 '21 at 06:54I was trying to do the same with other numbers, $3^{k-1}\le n\le 3^k-1$, in this case, I'll be dividing by $3$, So, $m = \lceil n/3 \rceil$ and $n-m = 2\lfloor n/3 \rfloor + 1 $ or $n-m = 2\lfloor n/3 \rfloor$... So, would this work?
– Sarthak Jan 15 '21 at 20:29