Maximal Partitions
August 17th, 2007When considering the extra-credit of the 23 and 2000 riddle, I thought of an additional interesting problem.
Let N be a positive integer. A partition of N into m parts (an m-partition of N) is a multiset of m positive integers, such that their sum equals N. A multiset is a set which may contain repeated elements.
So if N is 5, then the multiset {1, 1, 1, 2} is a 4-partition of N.
Now, for a multiset A of numbers, define the mul of A, denoted mul(A), as the product of all the numbers. So mul({1, 1, 1, 2}) = 2.
Now, let N be a positive integer. An m-partition P of N is called a maximal partition of N, if for all positive integers k, and all k-partitions of N, Pk, mul(P) >= mul(Pk).
E.g. the 2-partition {2, 3} is a maximal partition of 5 (its the only one). Note that as the number of partitions is finite there always is at least one maximal partition.
Finally, define maxmul(N) to be the mul of a maximal partition of N.
Now, we finally got to the point: given a positive integer N, what is maxmul(N)?
If you want to think about this one yourself, stop reading now, because the rest of this post discusses the solution. Anyway, try to have at least an initial intuition on the answer before reading on.
I must admit that my initial intuition about this problem was that if N is even, then a maximal partition of N will be a N/2-partition of the form {2, 2, …, 2}. This is wrong.
As it turns out, for all N > 1, the maximal partition of N depends on the value of N modulo 3.
If N = 0 (3) then the maximal partition is of the form {3, 3, …, 3}.
If N = 1 (3) then the maximal partition is of the form {3, 3, …, 3, 2, 2}.
If N = 2 (3) then the maximal partition is of the form {3, 3, …, 3, 2}.
I leave the reader the details of the proof. It is not too complicated using induction. I will now try to explain the reason behind this fact.
Notice a weird fact about the number 3. It is, in some way, the densest integer. Why is that so?
As you might have guessed, this is because 3 is the integer closest to e (=~2.718).
Lets consider the continuous equivalent of this problem. Say that N is a real-number. For each integer m, define an m-partition of Nas a multiset of m positive real numbers, whose sum is N. Note that now the number of partitions is infinite (for each m>1, even the number of m-partitionsis infinite) and so we are no longer guaranteed of the existence of a maximal partition (although it is easy to show that it indeed exists).
Using some basic analytic tools (such as Lagrange multipliers) it is easy to show that given m, the partition whose mul is maximal is the partition {N/m, …, N/m}.
So now we are left with finding an integer m such that the expression (N/m)^mis maximal. Again, lets consider the continuous equivalent of this. For each 1<x<∞, define f(x) = (N/x)^x. Using elementary calculus, it is clear that this function has a single maximum for x = N/e. A graph of the function f(x) is shown here (the blue line indicates e):
Using x = N/e gives a partition with a constant chunk size of e.
This explains (at least intuitively) the reason for 3 being the densest integer.
Extra credit
- How many partitions does a positive integer N have?
- How big is the set {mul(P) | P is a partition of N}?
Note that the definitions used in this post were invented by me and are not universally known (i.e. do not be alarmed if someone does not understand the meaning of the term maximal partition!).
August 25th, 2007 at 4:02 pm
This reminds me of another riddle I once invented.
First part:
Let there be a 52-cards pack, currently sorted.
I will shuffle the cards as follows:
split it to two equal parts.
Merge the two parts by putting one card from each part at the time.
(Note that we keep each part in the same order, and that the topmost card, stays the topmost card after the shuffling)
Repeating this procedure several times, causes an intresting phenomena:
After 8 times, the pack is sorted again.
This happens because of a certain property of the used permutaion.
The permutation created by this procedure is:
P = [0, 26, 1, 27, 2, 28, 3, 29, 4, 30, 5, 31, 6, 32, 7, 33, 8, 34, 9, 35, 10, 36, 11, 37, 12, 38, 13, 39, 14, 40, 15, 41, 16, 42, 17, 43, 18, 44, 19, 45, 20, 46, 21, 47, 22, 48, 23, 49, 24, 50, 25, 51]
But P is formed from several circles:
[[0], [1, 26, 13, 32, 16, 8, 4, 2], [2, 1, 26, 13, 32, 16, 8, 4], [3, 27, 39, 45, 48, 24, 12, 6], [5, 28, 14, 7, 29, 40, 20, 10], [6, 3, 27, 39, 45, 48, 24, 12], [9, 30, 15, 33, 42, 21, 36, 18], [10, 5, 28, 14, 7, 29, 40, 20], [11, 31, 41, 46, 23, 37, 44, 22], [17, 34], [18, 9, 30, 15, 33, 42, 21, 36], [19, 35, 43, 47, 49, 50, 25, 38], [22, 11, 31, 41, 46, 23, 37, 44], [34, 17], [38, 19, 35, 43, 47, 49, 50, 25], [51]]
The i-th card lifecycle, is to move through the all locations in its circle, again and again.
In that case, the pack will be sorted again, if all the circles are fully completed.
For that reason, the number of times needed to resort the pack, is LCM(circle_lengths), which in that case is 8.
The riddle I invented, is as follows:
Given the number of cards N, find the worst permutaion (IE. Find a permutation with the longest order).
Hint – so you can be sure your answer is correct:
for N=52, the worst permutation have an order of 180180.
So in fact, this riddle can be translated to:
Find a partition of N, with maximal LCM(P) (instead of the original demand of maximal MUL(P))
BTW – I don’t have a formula for calculation it, but I do have an algorithm for finding it in polynomal time.
August 25th, 2007 at 6:02 pm
Nadav,
A very interesting riddle indeed. A more standard way to phrase it (using group theory notations) is to ask: what is the maximal order of an element of Sn.
Although this is a very interesting question, as far as I know no complete answer exists. There are some (rather poor) bounds available with Cauchy’s theorem, stating that for each prime p dividing n there is a member of Sn of order p, but since Sn is not commutative, we cannot conclude much about the existance of elements of composite order.
Indeed, a simple O(n^2) algorithm for calculating this exists. It is similar to the one I originally used to solve the Maximal Partitions riddle.