nparts 0 = []
nparts n = [n] : [x:xs | x <- [1..n`div`2], xs <- nparts(n - x)]
which is a bad bad example of recursion coz it’s slow!
*Main> nparts 5
[[5],[1,4],[1,1,3],[1,1,1,2],[1,1,1,1,1],[1,2,2],[1,2,1,1],[2,3],[2,1,2],[2,1,1,1]]
I can then filter this with length of p and get the required options of c
I can then call the function “ my_min” with this list (simple map application)
Problem is if i do
*Main> filter (\x->length x == 2) $ nparts 100
[[1,99]
and it hangs…for a lot of time….so time constraint?
Any other approaches to this problem to make the partitions speedier. I know it’s an optimization problem…but all non linear optizers will use floats…and fail to converge…this is an integer optimizing problem.
Any ideas??