I acknowledge that you asked for the general steps to the solution and not for a ready made solution.
I assume you know what a
recursive algorithm[
^] is. The following is a layout for a dumb
brute-force[
^] recursive algorithm to solve this problem.
Set-up:
Read
N
from user-input.
Create a collection
M
for {1..N} and initialize it with these values.
Create two empty collections
L
and
R
for the two subsets.
Call the recursive method with
M
,
L
and
R
.
Recursion:
One method that takes as arguments:
Collection
M
containing the not-yet distributed values.
Collections
L
and
R
containing the already distributed values.
If
M
is empty:
- Sum the values in
L
and
R
.
- Compare the sums. If equal, add
L
and
R
to the valid results (e.g. print it to the console).
- Return.
Else (
M
is not empty):
- Take the next value
x
out of
M
.
- Insert
x
into
L
and call the recursive method with these new collections.
- Remove
x
from
L
, insert it into
R
and call the recursive method with these new collections.
- Remove
x
from
R
and put it back into
M
.
- Return.
You could make it a bit smarter by cutting some paths of the brute-force-search. E.g. for an initial
M
= {1,2,3,4}, at the point of the recursion where
L
= {1,2},
R
= { } and
M
= {3,4} you wouldn't have to continue the recursion because ...? (The why and how left as an exercise for you.)