← Practice problem bank

Dec 29, 2025

The Geometric Artistry Puzzle

Daily Challenge Archive · Open

mediummath

150 pts · 10000 ms · 128 MB · Practice only

Problem

Welcome to the Geometric Artistry Puzzle! Imagine you're an architect tasked with identifying the basic shapes that form the foundation of your designs. Given a set of N points on a 2D plane, your mission is to determine if these points form a triangle, a rectangle, or if they are all aligned along a single line (a line segment). If they don't fit any of these categories, you'll classify them as 'Other'. Here's how to tackle the challenge: 1. Read the coordinates of the points. 2. Analyze the distances and angles between the points to check for geometric properties that define triangles and rectangles. 3. Identify if all points lie on a single straight line to classify them as collinear. 4. Output the name of the shape or 'Other' if they don't match any specified shape. Consider examples like: four points forming a rectangle or three points lying in a straight line. Edge cases include overlapping points or sets with fewer than three points.

Hints
Consider the Pythagorean theorem for right angles in rectangles, use slope calculations to check collinearity, and remember that a hash map can help manage point data efficiently. Explore edge cases where points overlap or there are less than three points, and think about optimizing the calculation of distances and angles.

Input format

The first line contains an integer N (3 <= N <= 4), which is the number of points. The next N lines each contain two integers x and y, the coordinates of the points.

Output format

Print the name of the geometric shape: 'Triangle', 'Rectangle', 'Line' or 'Other'.

Constraints

All coordinates are integers and will not exceed 1000 in absolute value.

Sample input

4
0 0
0 2
2 2
2 0

Sample output

Rectangle

Sign in to submit solutions

Run your code against all test cases and get instant feedback.

Sign in