it is solved, thank you
Your post isn’t very clear. You mention peano representation, but in that representation you would represent the set of natural numbers as:
0 = , 1 = [], 2 = [ , [] ], 3 = [ , [], [, []] ]
however you want to instead represent the number X as a list of X elements having the members 1…X. However you sublists L1,L2 do not have that restriction and hence are not numbers in your representation.
Anyway…, lets assume that pluslist(X,L1,L2,S) hold if the sum(L1) is the same as the sum(L2) and length(L1) + length(L2) is X?
so these examples would hold.
pluslist(3,[1,2],,3). pluslist(4,[1,4],[2,3],5). pluslist(12,[1,12,2,11,3,10],[4,9,5,8,6,7],39).
Looking at even/odd indexes of [1…N] isnt going to give you two sublists which add up to the same value, however you may be able to spot a pattern from the larger example above.
You should also be able to figure out that the sum of L1+L2 is X(X+1)/2. And if you want your lists to add up to the same value, then the sum of L1 is X(X+1)/4. This should give you more insight on which values of X can hold true.
This is cross posted on StackOverflow.
There are many ways to achieve it. Look at the predicates
For example, if you partition the ordered list 1…4K into A1,A2,A3 and A4 of equal size, then the list consisting of A1,A4 is equal in size to the list A2,A3, and that the sums must be the same. Of course this algorithm only works where X is a multiple of 4
The code you’ve provided is nothing like the examples I posted, so you are doing a different problem. Since this looks like homework, I’d recommend re-reading your course notes.