Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 - 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 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: B 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.
A sink may be connected to the source through another sink. For example, in the simple pipe system ; 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:
In this system, the source is connected to sinks A and but it is not connected to sink
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
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started