Taking in Input
Define a function f
as follows:
IF x < 0:
f(x) = -√|x|
ELSE:
f(x) = √x
In your programs/functions, each point (x, y)
given as input will correspond to the point (f(x), f(y))
. For example, if the points (4, -2)
and (-1, 5)
are given as input, your program will be dealing with the points (2, -√2)
and (-1, √5)
. From now on, we will be referring to points in this format, rather than points in the format given in the input.
You will take in a set/list of points as input which will then be converted to Cartesian points with the function f
.
Balanced Sets of Points
Denote by PQ
the Euclidean distance from point P
to point Q
.
A set of points S
is balanced if, and only if, for all pairs of distinct points A
and B
in S
, there exists a point C
in S
such that AC = BC
. For example, the set of points {(0, 2), (-√3, -1), (√3, -1)}
is balanced because the points in this set are the vertices of an equilateral triangle. Note that this set of points would be taken as input by the program/function as {(0, 4), (-3, -1), (3, -1)}
.
Centre-Free Sets of Points
Again, denote by PQ
the Euclidean distance from point P
to point Q
.
A set of points S
is centre-free if, and only if, for all triples of distinct points A
, B
and C
in S
, there does not exist a point P
in S
such that AP = BP = CP
. For example, the set of points {(0, 2), (-√3, -1), (√3, -1)}
is centre-free, but if you add the point (0, 0)
to this set, it is no longer centre-free.
Formatting the Output
The output will be in the form of a two-digit binary number. Suppose we are given the set of points S
. After having applied the function f
to each point (see section "Taking in Input"), the first digit of this binary number will indicate whether this set of points is balanced and the second digit of this binary number will indicate whether this set of points is centre-free. For example, 10
will indicate that the given set of points is balanced, but not centre-free.
Also note that the digits 1
and 0
may be replaced with any truthy and falsy values. As opposed to strings, arrays and ordered pairs are also acceptable.
Test Cases
> {(0, 4), (-3, -1), (3, -1)}
11
> {(0, 4), (3, 1), (3, -1), (0, -4), (-3, -1), (-3, 1)}
01
> {(0, 4), (-3, -1), (3, -1), (0, 0)}
00
> {(0, 4), (-3, -1), (3, -1), (0, -4), (0, 0)}
00
> {(0, 16), (-3, 1),(-12, -4), (0, -4), (12, -4), (3, 1)}
10
Winning Criterion
Make your code as short as possible.
Credits
This was inspired by Problem 1 from IMO 2015. (Great problem, by the way!)
[True, False]
instead of10
be acceptable? \$\endgroup\$10
,[1, 0]
,[True, False]
andTrueFalse
are all examples of acceptable output. \$\endgroup\$(0,2),(-√3,-1),(√3,-1),(0,-2),(0,0)
. Furthermore the distance between(0,2)
and each of(-√3,-1),(√3,-1),(0,2)
are√12,√12,4
while the distance between(0,0)
and each of(-√3,-1),(√3,-1),(0,2)
are2,2,2
, but none of the pairs(√12,2),(√12,2),(4,2)
contain equal elements. Does this not imply it is not a balanced set? \$\endgroup\$10
test-case - would{(0,4),(-¾,¼),(-3,-1),(0,-1),(3,-1),(¾,¼)}
work (making, I think, an equilateral triangle along with the midpoints of each of its edges)? \$\endgroup\$