Hackerrank – Compute the Area of a Polygon

Hackerrank – Problem Statement

A description of the problem can be found on Hackerrank.

Solution

Create matrices of point pairs as follows

Calculate the determinat of each matrix:
x1 * y2 - x2 * y1
And sum the determinants. In the end divide the sum with 2.

Solution based on this.

I created solution in:

All solutions are also available on my GitHub.

Scala

Leave a Reply

Your email address will not be published. Required fields are marked *