The social network code-golf
On my social network, two users are "friends" if their name share a common letter.
For exemple, bob
and bill
are friends, as they share the letter b
.
Given a list of user names:
- display a falsy value if there exist in the list two distinct users
x
andy
that cannot be related through a friendship chain; - else, display a truthy value.
Examples
abc cde efg ghi
should return true, as abc
is friend with cde
, which is friend with efg
, which is friend with ghi
: all users are related.
abc cde fgh hij
should return false, as for example abc
and fgh
cannot be related through a friendship chain.
abc
should return true, as we cannot find in that list two unrelated users.
Input
- You can read the name list in any convenient format for your language.
- You can assume all the names are lowercase and use only the characters a-z
a-z
. - You don't need to handle the empty list, any result (true, false, program crash) is acceptable for it.