Consider a two dimensional co-ordinate system with two axes; X & Y. This system is identified by positive integer co-ordinates. Meaning, every valid point in this system is represented by two values (x, y) where 0 < x,y <100.You are given an input set of lines, specified by the co-ordinates of the two end-points.Write a program to identify all closed shapes created by the specified lines.Input Format (the program should accept this simple text file called "input.txt" placed in the classpath):A1, B1; C1, D1A2, B2; C2, D2…An, Bn; Cn, DnExpected Output (based on actual values of the input lines):There are two triangles and 1 square based on the input.Triangle 1 with vertices (a1,b1; a2, b2; a3,b3)Triangle 2 with vertices (a5,b5; a6, b6; a7, b7)Square 1 with vertices (a8, b8; a9, b9; a10, b10; a11, b11)Note:The input data may be such that some shapes overlap.You don't have to find shapes formed by intersection of two shapes. For example, if a square and triangle overlap such that there is another small triangle formed at the intersection, you don't have to report that.For the sake of scope, report only the following shapes, if any - triangle, any quadrilateral, pentagon.

You could also do it by building a graph where each node contains the two endpoints and they point to other nodes that have a point in common. Then traverse the graph and count the number of edges you traveled before coming to a point you've already seen (meaning it is closed). It simply specifies triangle, quadrilateral and pentagon (not regular pentagon or specific quads like parallelogram, rectangle or square) so you don't need to worry about angles or anything.

0

Featured Post

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Okay. So what exactly is the problem here?
How often have we come across situations where we need to know if two strings are 'similar' but not necessarily the same? I have, plenty of times. Until recently, I thought any functionality like that wo…

Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…

I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.
https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt
https://filedb.experts-exchange.com/incoming/201…

In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB.
How Percona can help
Percona can help you determine if Percona Server for MongoDB is the right solution for …