Skip to content
Prev 360483 / 398503 Next

Same sum, different sets of integers

This is not the most efficient, but gets the idea across.  This is the
largest sum I can compute on my laptop with 16GB of memory.  If I try to
set N to 9, I run out of memory due to the size of the expand.grid.
+             t(apply(add2N, 1, sort))  # sort
+             , 1
+             , toString
+             )
1, 7
2, 6
3, 5
4, 4
1, 1, 6
1, 2, 5
1, 3, 4
2, 2, 4
2, 3, 3
1, 1, 1, 5
1, 1, 2, 4
1, 1, 3, 3
1, 2, 2, 3
2, 2, 2, 2
1, 1, 1, 1, 4
1, 1, 1, 2, 3
1, 1, 2, 2, 2
1, 1, 1, 1, 1, 3
1, 1, 1, 1, 2, 2
1, 1, 1, 1, 1, 1, 2
1, 1, 1, 1, 1, 1, 1, 1



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Wed, Apr 27, 2016 at 11:46 AM, Atte Tenkanen <attenka at utu.fi> wrote: