Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#β€’3y agoβ€’
96 replies
David

❔ Finding the right algorithm for this task πŸ€”

Hello πŸ‘‹

I'm quite new to C# and still don't know which algorithm is used when, what it does, how is it implemented, etc.

I found some programming tasks on the internet and I'd like to learn the algorithms that way.

The first task is:

- You receive input in this form:
2 3
1 0 DVI
2 0 SATA
0 1 HDMI
2 2 HDMI
1 3 USB
2 3
1 0 DVI
2 0 SATA
0 1 HDMI
2 2 HDMI
1 3 USB


The context:
There is a room with cables on the ground everywhere. You need to have 2 cables of the same connector type to connect them together. For example:
You can connect USB-C with USB-C but you can't connect USB-C with HDMI.

Where:
2 3
2 3
defines the size of the room (a rectangle).
2
2
is the length of the rectangle
and
3
3
is the width

For each line in this format:
x y connector type
x y connector type

E.g.
1 0 DVI
1 0 DVI


1
1
is a point on the coordinate of the rectangle's length
and
0
0
is a point on the width

Note:
- All points (connectors) from the input will be on the edges of the rectangle never inside of it.

The goal:
The aim of this program is to find out whether all the cables can be connected together without being crossed.

So just imagine the points on the rectangle coordinates. Then connect every TWO points with the same connector with line. Check if the lines don't intersect.

If yes, write "It's not possible to connect the cables."
If no, write "It's possible to connect the cables."

- I just want to help with what type of algorithm should I use for this task. Just the name is enough, I want to study the algorithm after and then try to code it on my own.

Thanks for any help 🫢❀️
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Next page

Similar Threads

Is this the right directory for JwtHandler.cs?
C#CC# / help
4y ago
❔ Tasked with making a scheduling algorithm at summer internship
C#CC# / help
3y ago