Hackerrank – Compute the Perimeter of a Polygon

Hackerrank – Problem Statement

A description of the problem can be found on Hackerrank.

Solution

Calculate a length of a line between each pair of following points p, defined with x and y coordinate:

  • (p0, p1), (p1, p2), ..., (pn-1, p0)

Length of a line between two points:
$$l = \sqrt{{(x_1 – x_2)}^2 + {(y_1 – y_2)}^2}$$

Make sum of the lengths.

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 *