Back
Close

Nature of quadrilaterals

Statement

 Goal

You have to print the nature of the quadrilaterals whose vertices’ coordinates are given.
The nature can be:
* nothing, in which case you should write "quadrilateral",
* parallelogram (opposite sides are parallel to each other),
* rhombus (all four sides are equal),
* rectangle (all four angles are right) or
* square (it is a rectangle and a rhombus).
Input
Line 1: The number of quadrilaterals (n)
Next n lines: Each vertex followed by its coordinates, one quadrilateral per line. In the format:

A xA yA B xB yB C xC yC D xD yD
Output
The name of the quadrilateral followed by its nature. For example:

ABCD is a rhombus.
DEFA is a quadrilateral.

The vertices are printed in the given order. Note that ABCD, ABDC and ACBD are three distinct quadrilaterals. Just follow the order of the vertices.
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.
Example
Input
1
A -14 -3 B 5 -9 C 11 4 D -7 13
Output
ABCD is a quadrilateral.

Tags
MathematicsTrigonometryGeometryStrings

Difficulty
Easy

Test cases
Quadrilateral Test
Input
1 A -14 -3 B 5 -9 C 11 4 D -7 13
Output
ABCD is a quadrilateral.

Quadrilateral Validator
Input
2 A 1 2 B 5 2 C 5 4 D 4 4 M 9 14 N 16 11 P -10 2 Q -3 -2
Output
ABCD is a quadrilateral. MNPQ is a quadrilateral.

Parallelogram Test
Input
1 D -4 -2 E 2 0 R 4 4 P -2 2
Output
DERP is a parallelogram.

Parallelogram Validator
Input
1 G -2 5 U 4 3 L 8 -3 P 2 -1
Output
GULP is a parallelogram.

Rhombus Test
Input
1 A -2 0 B 0 1 C 2 0 D 0 -1
Output
ABCD is a rhombus.

Rhombus Validator
Input
1 H -4 -3 O 3 -4 P 8 1 E 1 2
Output
HOPE is a rhombus.

Rectangle Test
Input
1 E -2 -1 F -2 3 G 1 3 H 1 -1
Output
EFGH is a rectangle.

Rectangle Validator
Input
1 D -3 4 U 0 6 C 4 0 K 1 -2
Output
DUCK is a rectangle.

Square Test
Input
1 A 1 -2 B 5 0 C 3 4 D -1 2
Output
ABCD is a square.

Square Validator
Input
1 J 5 0 O -2 -3 K -5 4 E 2 7
Output
JOKE is a square.

Everything Test
Input
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
Output
HARD is a quadrilateral. JACK is a rhombus. ABCD is a square.

Everything Validator
Input
3 H -4 -3 O 3 -4 M 8 1 E 1 2 C -3 4 O 0 6 G 4 0 A 1 -2 A 1 2 B 5 2 C 5 4 D 4 4
Output
HOME is a rhombus. COGA is a rectangle. ABCD is a quadrilateral.

Solution language

Solution

Stub generator input