← Practice problem bank

Jan 21, 2026

The Collinear Point Enigma

Daily Challenge Archive · Open

easygreedy

100 pts · 10000 ms · 128 MB · Practice only

Problem

Imagine you are an explorer tasked with charting a precise path through uncharted territory. Your mission is to determine if three landmarks on your map lie perfectly on the same straight line, a crucial step for ensuring accurate navigation. To tackle this problem, you'll write a program that checks for collinearity among three points in a 2D plane. Here's how you can approach this: 1. Accept three points as input, each defined by a pair of coordinates (x, y). 2. Utilize the concept of the area of a triangle formed by these points. Calculate the area using the formula: Area = 0.5 * |x1(y2-y3) + x2(y3-y1) + x3(y1-y2)|. 3. If the calculated area is zero, the points are collinear; otherwise, they are not.

Examples
Consider points A(1, 2), B(3, 6), and C(5, 10). Calculating the area gives zero, indicating that these points are collinear. Edge Case: Watch out for points with the same coordinates or points that form a vertical or horizontal line.
Hints
  • Consider using the area of a triangle to determine collinearity.
  • Think about how coordinate differences can help simplify the problem.
  • Be mindful of edge cases such as overlapping points or axis-aligned points.
  • Try optimizing your approach by minimizing unnecessary calculations through early exits if possible.

Input format

Input consists of three lines, each containing two integers x and y, representing the coordinates of a point.

Output format

Output 'Yes' if the points are collinear, otherwise output 'No'.

Constraints

The coordinates x and y are integers where -1000 ≤ x, y ≤ 1000.

Sample input

1 2
2 4
3 6

Sample output

Yes

Sign in to submit solutions

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

Sign in