## Coding Contest (5) – Fence

The problem I propose for this year is encircling a forest by tying a fence on the outermost trees, saving the wild life and the tourists as well from each other.

## The Problem

Given a forest consisting of trees with known coordinates, one should find the outermost trees, and calculate the length of the fence which would enclose the entire forest.

A C# program (I am thinking of a PowerShell wrapper, or trying to support any other programming language the competitors would like to use) should find these trees and provide the length of the fence. The minimum fence length is the main information the program has to provide. Correctness and timing matters. After the size has been calculated, the exact trees should also be specified (out of the timed logic), in the right order (clockwise or counterclockwise).

## Business Domain to Developer Domain

A potential distribution of the trees is given on the screenshot below.

Figure 1 – Forest with trees (white circles), the fence being tied to the ones marked by violet O-s

This setup is modeled in the following configuration, the last, optional line being a hint to a potentially optimal fence length:

Figure 2 – Coordinates of the trees, (row,column) format, top-down orientation (screen coordinates)

The contest’s framework parses the configuration file for you, but you could create your own maps (even propose tricky ones for the contest).

## The Solution

Comes from you. Just take https://github.com/bigstefi/MS.CodingContest containing the .Net Core solution and implement the Encircle method. Send me your code (single cs file). I will run a test-competition every Friday and share the results with you. In case you prefer implementing a solution in Java, there is a sample next to the C# framework (which will be able to call into the Java class): https://github.com/bigstefi/MS.CodingContest.Java.

Coding Contest framework and sample solution (the GIT version does not yet have the contest elements of the previous years)

## Q & A

The competition is planned for March 22, 2024 (Friday).

Yes, you are competing with Morgan Stanley developers. I hope this motivates you.

Feel free to reach out to me in case of having any questions or issues: Istvan.Nagy1@MorganStanley.com.

Looking forward to the upcoming challenges and a fruitful collaboration:)!