6
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!)
4Would an output like
[True, False]
instead of10
be acceptable? – Stephen – 2017-09-03T14:04:09.233@Stephen Yes.
10
,[1, 0]
,[True, False]
andTrueFalse
are all examples of acceptable output. – 0WJYxW9FMN – 2017-09-03T17:21:09.737If I am correct, the points given by the last test-case are
(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? – Jonathan Allan – 2017-09-03T19:58:58.833@JonathanAllan Yargh! I made that one up on the spot by taking a rhombus made of two equilateral triangles and putting a dot in the middle. Fixed! – 0WJYxW9FMN – 2017-09-03T20:41:23.947
I guess you want a
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)? – Jonathan Allan – 2017-09-03T20:54:28.653Also for the second test-case I see no
C
for the pairA=(0,2)
andB=(1,√3)
so I don't think it is balanced. (I think only 30 of the 66A,B
pairs have aC
in that case) – Jonathan Allan – 2017-09-03T21:24:14.193@JonathanAllan Sorry about all the wrong test cases; I got muddled up. Thanks for the
10
test case! – 0WJYxW9FMN – 2017-09-03T21:56:30.857No downvotes so far! :-) :-) :-) I guess this was a bit more well-received than my last challenge... – 0WJYxW9FMN – 2017-09-08T22:07:40.440