+ 25
[CHALLENGE] Find Rectangle from coordinates
Write a program that finds rectangles from a given set of coordinates. All languages welcome! Example: P0(2,2) P1(2,4) P2(2,6) P3(4,2) P4(4,4) P5(4,6) P6(6,0) P7(6,4) P8(8,2) P9(8,4) There are 6 rectangles: P0+P1+P4+P3 P0+P2+P5+P3 P1+P2+P5+P4 P0+P1+P9+P8 P3+P4+P9+P8 P3+P7+P8+P6 Here is my try in Java: https://code.sololearn.com/cbehADWNkNjT/#java
8 Antworten
+ 10
i see 9 rectangles.p0 p5 p9 p6 not in your list...
https://code.sololearn.com/cCta1W7VT6PA/?ref=app
+ 8
+ 7
This is a mission for OnelinerMan !
+ 5
logic applied :- if slope of opposite sides is same and one of the angle is 90, It is rectangle...i found 9..thanks to @VcC for idea
https://code.sololearn.com/cJb84vl04l5Q/?ref=app
+ 4
@Adam Ross (R055A)
Yes, as I mentioned, the code is not really finished, that's right, the rectangle coordinates must exist in your inputs, the program will try until it finds the four coordinates, and also the satisfaction of having a rectangle parallel to the axes, I I'll try to fix that, thanks.
Example :
8
-5 3
6 5
5 3
8 4
-5 -7
0 4
5 -7
0 0
The coordinates :
(-5,3)
(5,3)
(-5,-7)
(5,-7)
+ 4
Yes ! the square angle, the code must have some changes, thanks. Nice code.
+ 2
@med look at my code. a rectangle has sides which are parallel and of same length and a square angle.
i added comments to my code
+ 2
Got it:
https://code.sololearn.com/ckX3xIu9vBMd/#py
In my code, basically, I take advantage of the fact that rectangles, have two pairs of parallel sides. That's It!
*Edit:
Also made one in c++, just for the hardcore coders that want to understand it in their favourite languaje!
https://code.sololearn.com/csrOHBHvtnq4/#cpp
-Have a great day!