Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fa97/Problem-of-Introduction

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Problem-of-Introduction

Degree of Separation

The Introduction Problem

In genteel 18th/19th century British manners, it was extremely impolite to speak to someone without previously having been formally introduced. In order for two persons Algernon and Bunbury to be formally introduced, it required a third party Cecily -- who had already been introduced to both Algernon and Bunbury -- to introduce them to each other.

Given a set of people, two people X and Y out of that set who wish to speak to each other, and a list of pairs of people who are acquainted (i.e. have already been formally introduced), find the smallest set of people required to perform the (series of) introductions necessary to allow X and Y to speak to each other.

Write a program embodying your solution to the problem, which runs as follows:

<INPUT.TXT>

The first argument is a plain text file of acquaintance relationships in the format:

NAME:NAME NAME:NAME ...

The other two arguments are two names X and Y. The program should print the smallest number of other people required to perform the introductions in order for X and Y to be acquainted. (If X and Y are already acquainted, print 0.)

Sample input file: robert:cora kevin:billy cora:steve kevin:steve

About

Degree of Separation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.