s2 seemed fairly straightforward... How did you get the bottom possibilities, Did you start at the top and work down through the combinations IE:
1011
0110
0000
1100
vvv
Code:
Possibilities r4: 1011
Possibilities r3: 0110 1101
Possibilities r2: 0000 0110 1101
Possibilities r1: 1100 1100 1010 0001
would make 4 -1 =3 for duplicates.
which would be a *fairly* straight forward recursive function.