# SWI-Prolog, 62 bytes k(X,Y):-f(X,Y);f(Y,X);X==Y. s(X,Y):-not(k(X,Y)),k(X,Z),k(Y,Z). Prolog isn't too often useful, but when it is it's just beautiful. The first line simply says that `k(X, Y)` is true if either `f(X, Y)`, `f(Y, X)` or `X == Y` is true. This implements the symmetry of knowing eachother. Asking if there should be a suggestion is incredibly simple. We just ask if there is a `Z` such that `k(X, Y)` is false and `k(X, Z)` and `k(Y, Z)` is true. Exactly as described in the challenge. If you save this as a file (e.g. `friends.pl`) and open SWI-Prolog with this file (`prolog -l friends.pl`) you get dropped into a REPL. You can assert friendships like this: assert(f('a', 'b')). assert(f('a', 'c')). assert(f('b', 'd')). You can check if people know eachother or suggestion should be made: k('a', 'b'). s('a', 'd').