Given two integers Image may be NSFW.
Clik here to view. and Image may be NSFW.
Clik here to view., where Image may be NSFW.
Clik here to view. is non-negative, an ordered Image may be NSFW.
Clik here to view.-partition of Image may be NSFW.
Clik here to view. is a Image may be NSFW.
Clik here to view.-tuple Image may be NSFW.
Clik here to view. of positive integers such that
Image may be NSFW.
Clik here to view.
For example, the ordered 3-partitions of 5 are Image may be NSFW.
Clik here to view., Image may be NSFW.
Clik here to view., Image may be NSFW.
Clik here to view., Image may be NSFW.
Clik here to view., Image may be NSFW.
Clik here to view., and Image may be NSFW.
Clik here to view..
The problem I'm considering in this post is: how do you enumerate all the ordered Image may be NSFW.
Clik here to view.-partititions of Image may be NSFW.
Clik here to view.?
In the case where Image may be NSFW.
Clik here to view., the problem is simple. An ordered 0-partition is a 0-tuple. But there is only one 0-tuple: the empty tuple, Image may be NSFW.
Clik here to view.. And the sum of Image may be NSFW.
Clik here to view. is 0, which means the only integer Image may be NSFW.
Clik here to view. is an ordered 0-partition of is 0. So 0 has Image may be NSFW.
Clik here to view. as its only ordered 0-partition, while every other integer has no ordered 0-partitions.
In other cases, where Image may be NSFW.
Clik here to view., we can try to reduce the problem to instances of the problem where Image may be NSFW.
Clik here to view. is smaller, so that we can use recursion to arrive at a solution. Observe that an ordered Image may be NSFW.
Clik here to view.-partition of Image may be NSFW.
Clik here to view. will have the form Image may be NSFW.
Clik here to view., where Image may be NSFW.
Clik here to view., …, Image may be NSFW.
Clik here to view. are positive integers that sum to Image may be NSFW.
Clik here to view.. Given that Image may be NSFW.
Clik here to view., we can talk about Image may be NSFW.
Clik here to view. individually. By subtracting Image may be NSFW.
Clik here to view. from both sides of the equation Image may be NSFW.
Clik here to view., we obtain the equivalent equation Image may be NSFW.
Clik here to view.. This proves the following theorem:
Theorem. The ordered Image may be NSFW.
Clik here to view.-partitions of Image may be NSFW.
Clik here to view. are the Image may be NSFW.
Clik here to view.-tuples Image may be NSFW.
Clik here to view. of positive integers such that Image may be NSFW.
Clik here to view. is an ordered Image may be NSFW.
Clik here to view.-partition of Image may be NSFW.
Clik here to view..
This gives us a nice mathematical recursive characterization of the ordered Image may be NSFW.
Clik here to view.-partitions. If we write the set of all ordered Image may be NSFW.
Clik here to view.-partitions of Image may be NSFW.
Clik here to view. as Image may be NSFW.
Clik here to view., and we denote concatenation of tuples by Image may be NSFW.
Clik here to view., we can write the following equations:
Image may be NSFW.
Clik here to view.
However, these equations do not translate directly into a terminating algorithm, because of the union over all of the infinitely many positive integers Image may be NSFW.
Clik here to view. taken in the third equation.
But we don't necessarily need to examine all positive integers Image may be NSFW.
Clik here to view., because for some of them, Image may be NSFW.
Clik here to view. may be empty, so that nothing is contributed to the overall union by this particular value of Image may be NSFW.
Clik here to view.. This suggests that we should consider the following sub-problem:
For which integers Image may be NSFW.
Clik here to view.and Image may be NSFW.
Clik here to view., where Image may be NSFW.
Clik here to view.is non-negative, are there no ordered Image may be NSFW.
Clik here to view.-partitions of Image may be NSFW.
Clik here to view.?
This is easy to solve:
Theorem. For every integer Image may be NSFW.
Clik here to view. and every nonnegative integer Image may be NSFW.
Clik here to view., the following statements are equivalent:
- Image may be NSFW.
Clik here to view.has an ordered Image may be NSFW.
Clik here to view.-partition.
- Image may be NSFW.
Clik here to view.or Image may be NSFW.
Clik here to view..
Proof.
- If Image may be NSFW.
Clik here to view.is negative, then it has no ordered Image may be NSFW.
Clik here to view.-partitions, because ordered Image may be NSFW.
Clik here to view.-partitions of Image may be NSFW.
Clik here to view.are tuples of positive integers that sum to Image may be NSFW.
Clik here to view., but the sum of a tuple of positive integers is always non-negative.
- If Image may be NSFW.
Clik here to view., then Image may be NSFW.
Clik here to view.has no ordered Image may be NSFW.
Clik here to view.-partitions, because ordered Image may be NSFW.
Clik here to view.-partitions of Image may be NSFW.
Clik here to view.are tuples of Image may be NSFW.
Clik here to view.positive integers that sum to Image may be NSFW.
Clik here to view., and the sum of Image may be NSFW.
Clik here to view.posiive integers cannot be less than Image may be NSFW.
Clik here to view..
- 0 has an ordered 0-partition, namely Image may be NSFW.
Clik here to view.. But no nonzero integer Image may be NSFW.
Clik here to view.has any ordered 0-partitions.
- If Image may be NSFW.
Clik here to view., then the ordered Image may be NSFW.
Clik here to view.-tuple consisting of Image may be NSFW.
Clik here to view.1s, followed by Image may be NSFW.
Clik here to view.(which is positive since Image may be NSFW.
Clik here to view.), is an ordered Image may be NSFW.
Clik here to view.-partition of Image may be NSFW.
Clik here to view..
Image may be NSFW.
Clik here to view.
So, in the third equation above, the union only needs to be taken over values of Image may be NSFW.
Clik here to view. such that Image may be NSFW.
Clik here to view. (i.e. Image may be NSFW.
Clik here to view. and Image may be NSFW.
Clik here to view.) or Image may be NSFW.
Clik here to view. (i.e. Image may be NSFW.
Clik here to view. and Image may be NSFW.
Clik here to view.). Hence we can rewrite the equations as follows:
Image may be NSFW.
Clik here to view.
This can now be translated straightforwardly to code in a programming language. For example, here's a Python implementation:
from typing import Iterator
def int_parts(n: int, k: int) -> Iterator[tuple[int, ...]]:
if k == 0:
if n == 0:
yield ()
return
if k == 1:
if n >= 1:
yield (n,)
return
for m in range(1, n - k + 2):
for p in int_parts(n - m, k - 1):
yield (m,) + p
This is a pretty trivial subject, and I feel like my presentation of it here is somewhat incomplete (for example, I haven't said anything about how efficient the algorithm described here is). However, I think my standards for considering a post "complete" are a bit too high at the moment, as evidenced by the fact that I haven't made any posts on this blog for a couple of years, despite having written a number of unfinished drafts.
I think it would be good if whenever I learn something new, I would write down what I've learnt that very same day and make a blog post out of it, regardless of how trivial or in need of further exploration it might seem. So I'm going to attempt to do that from now on.