P33 · 1 second · 256 MB

Point Location Test

You are given three points `a`, `b`, `c`, each `[x, y]`. Looking along the directed line `a → b`, is `c` to the left, to the right, or on the line? Return `1` for left (counter-clockwise), `-1` for right (clockwise), `0` for collinear.

function orientation(a, b, c) → number

CONSTRAINTS

  • a, b, c are length-2 number arrays
  • -10⁴ ≤ x, y ≤ 10⁴
  • a and b may be the same point — treat that as collinear (return 0)
Input: a = [0, 0], b = [2, 0], c = [1, 1]
Output: 1
Input: a = [0, 0], b = [2, 0], c = [1, -1]
Output: -1
Input: a = [0, 0], b = [2, 0], c = [3, 0]
Output: 0
1
2
3
4
5
6
7
8

Arena judges JavaScript in a Web Worker (1s wall-clock, then TLE). Samples are public; submit runs hidden tests too. C++/Python is a later swarm package.