[Haskell-cafe] Partition int 180. Out of memory

Kees Bleijenberg K.Bleijenberg at lijbrandt.nl
Thu Nov 19 09:06:54 UTC 2015

Hi Erik,

Complicated stuff. Your proposal worked. It took (on my compter )341 secs to compute the 612.743.290 partitions.


On Wednesday, November 18, 2015 at 3:25:12 AM UTC-6, Kees Bleijenberg wrote:
I want to partition the integer n=180 with terms >=5
I.e.  n=15 => [[5,5,5],[8,7],[9,6],[10,5],[15]]

For an alternate way to produce partitions, have a look at how the combinat package does it:


In particular, in this part:

    _partitions' (!h ,!w) d =  [ i:xs | i <- [1..min d h] , xs <- _partitions' (i,w-1) (d-i) ]

if you change `i <- [1..min d h]` to ` i <- [5..min d h]` it appears you will get the partitions which have size at least 5.

After you make the change, call the function like this: _partitions' (180,180) 180

More information about the Haskell-Cafe mailing list