If this is not the right forum for this question let me know.
I am looking for a physical algorithm that can be easily followed by anyone not knowing much mathematics to get integer partitions of a number.
I have come up with the following way - but there is an issue (described later).
Suppose I want to divide number 11 into all its integer partitions (order is not important).
For finding partitions of size 2 we do following.
Take 11 coins of identical widths. Take a paper. Write 1 and 2 on it
1 2
Below the first number, keep all 11 coins one upon another to make a tower of height 11. This is represented as -
1 2
11c 0c
Now, shift 1 coin from first column to second column.
1 2
10c 1c
Here, height of tower 1 = 10, height of tower2 = 1
Keep on doing this, only if Height of tower 1 >= Height of tower2
On each step of the algorithm, we get new integer partition.
- This "physical algorithm" is easy to understand by anyone knowing basic mathematics.
- Preferrably, each step in the physical algorithm must show a new partitioning way.
- There should be an end condition to the algorithm.
- When the algorithm reaches end condition, all possible partitioning ways must have been shown.
If we now want to find all partitions of size 3, the problem gets a bit tricky.
We have 3 towers, with following restrictions
Height of tower 1 >= Height of tower2 >= Height of tower3
But thing is, there are certain positions, from which we cannot go to next stage without destroying earlier stage - what do I mean by this? See below
Step1
1 2 3
9c 1c 1c
Step2
1 2 3
8c 2c 1c
Step3
1 2 3
7c 3c 1c
Alternative Step3
1 2 3
7c 2c 2c
At step 3 the algorithm creates two branches - people could either put new coin in tower2 or tower1. How should the algorithm statements be written so that by the time the algorithm is finished, all partitions of size 3 are known?
If you could come up with a new algorithm, that's welcome too!
I have come up with following algorithm for finding partitions of size 3. It may be generalized to size
N, but I'm not 100% sure.Initial Setup
A paper with 3 numbers, 1,2 and 3 written on it.
11 coins.
1 coin in tower1, 1 coin in tower2, 9 coins in tower3.
This is represented as
Algorithm This algorithm is a series of steps. Some of the steps are termed "starting positions". Once a starting position is reached, an operation
O1must be performed to reach next step - while satisfying a certain conditionC0. Then we repeat that operation multiple times. If that partular conditionC0cannot be satisfied, we go to the next starting position via operaitonO2.Condition C0= Height of tower1 <= Height of tower2 <= Height of tower3Operation O1= Shift one coin from last tower to second-last tower whilecondition C0is satisfied. IfC0cannot be satisfied do operationO2Operation O2= Shift one coin from last tower to first tower. Then shift coins from second-last tower to last-tower untilHeight of tower1 = Height of tower2Termination condition= If after performingoperation O2,condition C0cannot be satisfied, algorithm is terminated and that coin distribution is discarded.Algorithm demonstration
Initial Starting position
Condition C0Height of tower1 <= Height of tower2 <= Height of tower3Operation O1-> Shift one coin from last tower to second-last tower whilecondition C0is satisfied.Now, we can no longer perform
operation O1without disobeyingcondition C0. So we shift to next starting position viaoperation O2which modifies coin distribution according to some conditions.Operation O2- Shift one coin from last tower to first tower Shift coins from second-last tower to last-tower untilHeight of tower1 = Height of tower2If
condition C0cannot be satisfied at this stage - algorithm is terminated. Otherwise we go forward as belowAfter performing
operation O2we reach next starting position as belowNow, a series of
O1operations takes us through -Now
C0cannot be obeyed after performingoperation O1, so we applyoperation O2Then another
O1Now
C0cannot be obeyed after performingO1, so we applyO2C0cannot be obeyed by above distribution, so algorithm has terminated and last coin position4 4 3is discarded.Thus we get all 10 ways to partition 11 into 3 summands.