Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.46 KB | None | 0 0
  1. distribute([], [], []).
  2. distribute([H|T], [H|L2], L3) :-
  3.     distribute(T, L2, L3).
  4. distribute([H|T], L2, [H|L3]) :-
  5.     distribute(T, L2, L3).
  6.  
  7. both(X, Y, L) :-
  8.     member(X, L),
  9.     member(Y, L).
  10.  
  11. bipartite([], _, _).
  12. bipartite([H|T], S1, S2) :-
  13.     bipartite(T, S1, S2),
  14.     [X,Y] = H,
  15.     \+both(X, Y, S1),
  16.     \+both(X, Y, S2).
  17.  
  18. bipartite(M, L1, L2, L3) :-
  19.     findall(N, between(1, M, N), NS),
  20.     distribute(NS, L2, L3),
  21.     bipartite(L1, L2, L3).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement