+ 3

***[Super Challenge]*** ver.3.0

Here is a task for you. Imagine that you drop some points on 2D-plane with system of 2 axes (x and y). You must drop at last 4 points on each coordinate quarter (there are 4 quarters). Now if you connect these points by order of their quarters (each dot in its own quarter) you will get a quadrangle. Task: find MAX square and print it with 4 dots coordinates. A (1; 1), B(1; -1), C(-1; -1), D(-1;1) and E(2; 2) we will get 2 quadrangles. MAX Square is 6.5 Input ends when next dot will have coordinates (0; 0)

12th May 2018, 1:37 PM
dimon2101
dimon2101 - avatar
6 Answers
+ 1
#One more example of input: 1 1 1 -1 -1 -1 2 2 -1 1 1 -2 0 0 #Output is: Maximum square is 6.5 Its Dots are: (2; 2), (1; -2), (-1; -1), (-1; 1)
12th May 2018, 1:38 PM
dimon2101
dimon2101 - avatar
12th May 2018, 1:41 PM
dimon2101
dimon2101 - avatar
+ 1
@hinanawi Maybe you can explain what n^4 time means? I made 1 square of quadrangle from 2 triangles :-)
12th May 2018, 3:17 PM
dimon2101
dimon2101 - avatar
+ 1
dimon2101 n⁴ time is because of the 4 nested loops. keep in mind that doesn't mean the code is bad, just that the problem is hard to optimize
12th May 2018, 3:18 PM
hinanawi
hinanawi - avatar
+ 1
@hinanawi I'm Agree with you. Optimization is the next step ;-)
12th May 2018, 3:23 PM
dimon2101
dimon2101 - avatar
0
yikes n⁴ time solution on optimal
12th May 2018, 3:08 PM
hinanawi
hinanawi - avatar