How can I solve this question in a more clear way?

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 2D 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.).

Pipes: There are 10 different shapes of pipes, represented by the following characters: ‘═’, ‘║’, ‘╔’, ‘╗’, ‘╚’, ‘╝’, ‘╠’, ‘╣’, ‘╦’, ‘╩’.

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.

For example, the two cells ‘╩ ╦’ are connected to each other through their shared edge. The two cells ‘╩ ╔’ are not connected to each other through their shared edge, but they could 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 ‘A ╦’ are connected through their shared edge, but the two cells ‘B ╔’ 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 Y ═ 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:

  • ╣ ╔ ═ A
    ╠ ═ ╝
    C ╚ ═ B
    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.

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 (0, 0) 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.

  • 0 2
    C 1 0
    ╠ 1 1
    ╣ 1 2
    ═ 2 1
    ╚ 3 0
    ╝ 3 1
    ╔ 3 2
    ═ 4 0
    ═ 4 2
    B 5 0
    A 5 2
    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 ‘P’, ‘B’, ‘J’, and ‘T’ are the only sinks connected to the source, your code should return the string ‘BJPT’.

Please submit the complete code for your function:

I am having challenges in generating the code

New contributor

Gideon Kipkorir Gideon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật