#PHP, 138 133 129 bytes
PHP beats Mathematica - a rare occurence.
for(;$s=fgets(STDIN);$s>G?print$$a[$b]?$s<L:$s>L&&@array_intersect_key($$a,$$b):$$a[$b]=$$b[$a]=1)[,$a,$b]=explode(" ",trim($s));
prints 1
for truthy, empty string for falsy. Run with -nr
or test it online.
needs PHP 7.1 for the list assignment; user names are case sensitive and should exclude a
, b
, s
.
breakdown
for(;$s=fgets(STDIN); # loop through input
$s>G # 2. evaluate command
?print$$a[$b]
# command KNOW: true if $$a[$b]
?$s<L
# command SUGGEST: true if !$$a[$b] and array_intersect_key returns truthy
:$s>L&&@array_intersect_key($$a,$$b)
# command FRIEND: set keys in $$a and $$b
:$$a[$b]=$$b[$a]=1
)
[,$a,$b]=explode(" ",trim($s)); # 1. parse user names to $a and $b
- user names are case sensitive and should exclude
a
,b
ands
. $s
has to be trimmed because it includes the newline character.array_intersect_key
has to be muted or it would yield warnings for empty$$a
or$$b
.+18+15 bytes for all user names: Replace$$a
with$f[$a]
and$$b
with$f[$b]
.