6 kyu

Clique of three

28 of 49geoffp

Description:

Given a list of friend pairs, find a clique of three (a.k.a. triangle): a group of three people who are all friends with each other.

For example, given the input

Harry/Ron
Ron/Hermione
Harry/Hermione
Hermione/Lavender

you should return

Harry/Ron/Hermione

The order of the three names in the returned string does not matter.

If there is no clique-of-three, return an empty string.

The members of a clique-of-three must be three different people. In particular, a person who claims to be his own friend does not constitute a clique-of-three all by himself.

The input consists of zero or more lines, one line per friend pair. Each line is terminated by the newline character '\n' and contains exactly one '/' character to separate the two names. The names are non-empty strings. Names may contain spaces or punctuation (but not the '/' or newline characters).

The largest test cases contain up to 750 unique names.

Strings
Algorithms

More By Author:

Check out these other kata created by geoffp

Stats:

CreatedJul 15, 2019
PublishedSep 10, 2023
Warriors Trained296
Total Skips43
Total Code Submissions455
Total Times Completed49
C++ Completions28
Java Completions23
Total Stars13
% of votes with a positive feedback rating90% of 20
Total "Very Satisfied" Votes16
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes0
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • geoffp Avatar
  • eurydice5717 Avatar
  • dfhwze Avatar
Ad