Prolog can be... difficult to wrap your head around when you are starting out.
First, try writing a predicate that will, on backtracking, return the entire cartesian join of the list against itself, something like this:
test( List, result( A, B ) ) :-
member( A, List ),
member( B, List )
.
Running that with the test data: test( [ [], [0], [0,0], [0,1], [1,0] ], R ).
will successively return 25 results (the sample list has 5 items in it, so 5 × 5 gives us 25 results, right?):
R = result( [] , [] )
R = result( [] , [0] )
R = result( [] , [0, 0] )
R = result( [] , [0, 1] )
R = result( [] , [1, 0] )
R = result( [0] , [] )
R = result( [0] , [0] )
R = result( [0] , [0, 0] )
R = result( [0] , [0, 1] )
R = result( [0] , [1, 0] )
R = result( [0, 0], [] )
R = result( [0, 0], [0] )
R = result( [0, 0], [0, 0] )
R = result( [0, 0], [0, 1] )
R = result( [0, 0], [1, 0] )
R = result( [0, 1], [] )
R = result( [0, 1], [0] )
R = result( [0, 1], [0, 0] )
R = result( [0, 1], [0, 1] )
R = result( [0, 1], [1, 0] )
R = result( [1, 0], [] )
R = result( [1, 0], [0] )
R = result( [1, 0], [0, 0] )
R = result( [1, 0], [0, 1] )
R = result( [1, 0], [1, 0] )
Once you have that, it's easy to compute the difference in length between the 2 sublists:
test( List, result( A, B ) ) :-
member( A, List ),
member( B, List ),
length( A, L1 ),
length( B, L2 ),
Delta is L1 - L2
.
And even easier to filter on that:
test( List, result( A, B ) ) :-
member( A, List ),
member( B, List ),
length( A, L1 ),
length( B, L2 ),
Delta is L1 - L2,
Delta = 1
.