I think that there is an incorrect test case for this community puzzle (it’s currently the puzzle of the week).
The last test case is:
06 Everything
3
H -4 3 A 2 5 R 4 2 D 10 4
J -2 0 A 0 1 C 2 0 K 0 -1
A 1 -2 B 5 0 C 3 4 D -1 2
HARD is a quadrilateral.
JACK is a rhombus.
ABCD is a square.
I drew the first first quadrilateral (HARD) and I think it should be expecting a parallelogram, not just quadrilateral, because it has two pairs of equal sides that are parallel with each to other.
I submitted my solution and got 100% score, even though it did not passed on this test case. If you already solved, I think you can have a look at my solution here.
I also checked some public solutions, could not find one that don’t successfully pass on the last test case as mine.
I had a look at the problem setter’s code. When I rearrange the points to HADR (as you drew them), the code calls it a parallelogram. On first thought that seems correct to me, I will have a closer look later.
My mistake in the representation there, I see the the swapped points.
I assumed the quadrilateral is convex when reading that “You won’t have to test if a quadrilateral is degenerate or convex.”.
Searching for quadrilateral definions, this lead to my wrong implementation:
“Quadrilaterals are simple (not self-intersecting) or complex (self-intersecting), also called crossed. Simple quadrilaterals are either convex or concave.”
There is a mistake in the test case. They say “You won’t have to test if a quadrilateral is degenerate or convex.” but this quadrilateral is not convex. Just check the vertex order.
No, they do not cross! It’s just another prove that HARD is not convex. Its against the description of this puzzle, repeat again: “You won’t have to test if a quadrilateral is degenerate or convex.”
But all the programs managed this case, so the solutions are more general, and as we see, “convex” is not a demand to do right calculations.
Constraints
The coordinates are integers between -20 and 20, you have no more than 3 quadrilaterals.
You won’t have to test if a quadrilateral is degenerate or convex.
I mean HARD do not satisfy the constrains. I consider this as a mistake.
Most programs are lenient, they don’t need this constraint anyway, as we see.
And you are absolutely right: It’s not a parallelogram.
No need to use a hard theorem to test if it is convex or not, testing the middles of diagonals condition is enough to tell if it is a parallelogram or not.
Pour ce puzzle, j’ai réussi tous les tests dans l’IDE mais 2 (Rhombus et everything) ne passent à la soumission.
Pour résoudre ce puzzle, j’ai choisi l’option Vecteur (avec 2 classes une Point et une autre vecteur)
La classe vecteur me permet de vérifier si deux vecteurs ont la même norme (longueur), s’ils sont colinéaires (parallèles) ou s’ils sont orthonormés (perpendiculaires).
J’avoue ne pas voir d’où peut venir le problème surtout que je n’ai aucun message d’explication sur la non validation…
Si quelqu’un a déjà rencontré le problème, je ne suis pas contre un coup de pouce…