Question: Part 3 - Coding Exercise: Connected Sinks in a Pipe System In this exercise, you will write code to solve a problem. Your code must
Part Coding Exercise: Connected Sinks in a Pipe System
In this exercise, you will write code to solve a problem. Your code must be in either Python preferred or JavaScriptsolutions in other languages will not be accepted! You can write your code using
any IDE you want.
Problem
We have a pipe system represented by a D rectangular grid of cells. There are three different types of objects located in cells in the grid. with each cell having either objects or object:
Source: There is source in the system. It is represented by the asterisk character
Sinks: There are an arbitrary number of sinks in the system. They are each represented by a different uppercase letter A etc.
Note that each pipe has openings on or sides of its cell.
Two adjacent cells are connected if both have a pipe opening at their shared edge.
possibly still be connected via a path through other cells around them.
Treat the source and sinks as having pipe openings at all of their edges. For example, the two cells Tr are connected through their shared edge, but the two cells are not directly
connected through their shared edge.
A sink may be connected to the source through another sink. For example, in the simple pipe system x all three sinks are connected to the source.
Your objective is to write a function that determines which sinks are connected to the source in a given pipe system.
As an example, consider the following illustration of a pipe system: As an example, consider the following illustration of a pipe system:
In this system, the source is connected to sinks A and but it is not connected to sink B
A system is specified by an input text file that contains rows of data indicating the location of the objects in the grid. Each row has three pieces of information, separated by a space character:
The character representing the object asterisk uppercase letter, or pipe
The coordinate of the object in the grid. This has a minimum value of
The coordinate of the object in the grid. This has a minimum value of
Below are the contents of an input file that specifies the example pipe system illustrated above. The order of the rows within the file is arbitrary, so the rows could be given in any order. The
coordinates will always correspond to the same corner of the grid as in this example, so make sure to understand in which directions the x and y coordinates increase. Below are the contents of an input file that specifies the example pipe system illustrated above. The order of the rows within the file is arbitrary, so the rows could be given in any order. The
coordinates will always correspond to the same corner of the grid as in this example, so make sure to understand in which directions the and coordinates increase.
Specifications
Your function must be written in Python preferred or JavaScript.
The function should take in a single argument, which is a string containing the file path for the input text file.
The function should return not print your answer as a string of uppercase letters, in alphabetical order with no other characters. For example, if the code determines that sinks J and
are the only sinks connected to the source, your code should return the string BJPT
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
