Answered step by step
Verified Expert Solution
Link Copied!

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 1- 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 JavaScript-solutions 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 20 rectangular grid of cells. There are three different types of objects located in cells in the grid, with each cell having either 0 objects or 1 object:
Source: There is 1 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',C', etc.),
Note that each pipe has openings on 2 or 3 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 ?**xY=Z; 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 C. 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 x-coordinate of the object in the grid. This has a minimum value of 0.
The y-coordinate of the object in the grid. This has a minimum value of 0.
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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Describe the job youd like to be doing five years from now.

Answered: 1 week ago

Question

So what disadvantages have you witnessed? (specific)

Answered: 1 week ago