Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
For every fixed
k
,c[j]
is exactly the number of partitions ofj
using only numbers from1
tok
after inner cycle. This is possible to prove by induction.a) When
k=1
,c[j]=1
for allj
from0
ton
because the only way to make a partition of any integer with only1
's is simply1+1+...+1
.b) Now suppose it's true for
k-1
and for allj < j'
fork
. To get partitions ofj
with termk
, we need to appendk
to all partitions ofj-k
. Sincec[j-k]
has correct value by induction hypothesis, we get correct value forc[j]
by addingc[j-k]
.Then calculations up to
k=n
givec[n]
as answer.UPD: while writing this, I noticed the comments in the code are about generating function of number of integer partitions. Then I recommend to check https://en.wikipedia.org/wiki/Partition_(number_theory) (part about generating function) and https://en.wikipedia.org/wiki/Generating_function. The algorithm is easy to interpret in terms of operations with generating functions.
Can someone explain the idea of this solution or maybe share link to necessary information please