Susan gave her nephew a number of pennies, as well as a mathematical challenge: to figure out how many ways there were of dividing the pennies into three piles. The pennies are indistinguishable, so the identity of the pennies doesn't matter, nor does the order of the piles. For example, if there had been nine pennies, the piles could have been arranged in any of seven ways: 1+1+7, 1+2+6, 1+3+5, 1+4+4, 2+2+5, 2+3+4, 3+3+3.

There were actually more pennies than this, and in fact, the number of ways was a four-digit number.

However, the nephew misunderstood the instructions. He thought that no two of the piles could be equal, and so came up with a smaller number. For example, if the number of pennies were nine, as above, only three of the arrangements into piles consisted of unique sizes: 1+2+6, 1+3+5, 2+3+4, and the nephew would have reported that, incorrectly.

As mentioned the actual number of ways was a four-digit number. The number reported by the nephew was also a four-digit number, and as a result of his misunderstanding, the only difference between his reported number and Susan's expected answer was that the middle two digits were reversed.

How many pennies did Susan give to her nephew?

IntegerPartitions

IntegerPartition [*n*, {*k*}]

gives partitions into **exactly** *k* integers.

For three piles k=3 so

[*n*, {*3*}] A=

partitions into **exactly** *3* piles. Is the number of

This number equals to number OF partitions of N+3 pennies into 3 piles with **distinct** number of pennies in each pile.

Proof : Arrange in ascending order each of all A possible

partitions and then for each partition add 1 penny to the second pile and two pennies to the 3^{rd} pile to assure they are distinct.

To clarify – in the problem posted

[*6*, {*3*}] = 3 >>> (114,123,222),

By adding 3 pennies we get the same number of

**distinct** partitions of 9 >>> (126,135,234)

SOLUTION :

GET(OR GENERATE) A LIST 0F [*n*, {*3*}]

WITHIN A 4 DIGIT RANGE COMPARE[*X*,{*3*}] with [*X+3*,{*3*}]

FIND THE INVERSED DIGITS AS REQUIRED

DONE

I am too lazy to do it , but I looked up the posted answer and it appears to be OK

*Edited on ***April 10, 2008, 6:39 pm**