Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 407 #823

Closed
vaskoz opened this issue Dec 31, 2019 · 1 comment · Fixed by #824
Closed

Day 407 #823

vaskoz opened this issue Dec 31, 2019 · 1 comment · Fixed by #824
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Dec 31, 2019

Good morning! Here's your coding interview problem for today.

This problem was asked by Samsung.

A group of houses is connected to the main water plant by means of a set of pipes. A house can either be connected by a set of pipes extending directly to the plant, or indirectly by a pipe to a nearby house which is otherwise connected.

For example, here is a possible configuration, where A, B, and C are houses, and arrows represent pipes:

A <--> B <--> C <--> plant
Each pipe has an associated cost, which the utility company would like to minimize. Given an undirected graph of pipe connections, return the lowest cost configuration of pipes such that each house has access to water.

In the following setup, for example, we can remove all but the pipes from plant to A, plant to B, and B to C, for a total cost of 16.

pipes = {
    'plant': {'A': 1, 'B': 5, 'C': 20},
    'A': {'C': 15},
    'B': {'C': 10},
    'C': {}
}
@vaskoz vaskoz self-assigned this Dec 31, 2019
@vaskoz
Copy link
Owner Author

vaskoz commented Dec 31, 2019

Identical to Day 299: #611

@vaskoz vaskoz mentioned this issue Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant