https://github.com/dkershner6/automatedminesweeper
Coding challenge to explode as many mines as possible
https://github.com/dkershner6/automatedminesweeper
code-challenge
Last synced: about 1 year ago
JSON representation
Coding challenge to explode as many mines as possible
- Host: GitHub
- URL: https://github.com/dkershner6/automatedminesweeper
- Owner: dkershner6
- Created: 2019-07-11T21:09:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-12T21:28:12.000Z (almost 7 years ago)
- Last Synced: 2025-02-03T11:22:18.352Z (over 1 year ago)
- Topics: code-challenge
- Language: C#
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AutomatedMinesweeper
Coding challenge to explode as many mines as possible
EXERCISE
There are bunch of mines in a mine field, and you are tasked with
exploding as many of them as you can. The only caveat is you can
only explode one manually. The mine you manually explode will set
off a chain reaction. For any mine that explodes, all mines within
the blast radius of that mine will be triggered to explode in one
second. The mine you manually explode blows up at time 0.
Your Task: Write a program which will read in a mines array and
output the maximum number of mines you can explode. Also output
which mine you need to manually set off to explode this maximum
number. Since there may be multiple mines that blow up a maximal
number of mines you should output all the mines that do that.
We'll provide you with:
Mines API Call (Json) with values:
[{x: x, y: y, r: r}] - where x is x coordinate, y is y coordinate and r is blast radius
Example:
[{x: 1, y: 2, r: 53},
{x: -32, y: 40, r: 100},
{x: 10, y: 15, r: 25},
{x: -15, y: -15, r: 200}]
Formulas to determine if a mine explodes another mine:
```csharp
public static bool WillExplode(int x1, int y1, int r, int x2, int y2)
{
return r >= RangeNeeded(x1, y1, x2, y2);
}
private static double RangeNeeded(int x1, int y1, int x2, int y2)
{
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
```