Day06 part1 statement and failing test
This commit is contained in:
@@ -62,6 +62,7 @@
|
|||||||
<Compile Include="Day03_Tests.cs" />
|
<Compile Include="Day03_Tests.cs" />
|
||||||
<Compile Include="Day04_Tests.cs" />
|
<Compile Include="Day04_Tests.cs" />
|
||||||
<Compile Include="Day05_Tests.cs" />
|
<Compile Include="Day05_Tests.cs" />
|
||||||
|
<Compile Include="Day06_Tests.cs" />
|
||||||
<Compile Include="GuardEvent_Tests.cs" />
|
<Compile Include="GuardEvent_Tests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
25
AdventOfCode2018.Tests/Day06_Tests.cs
Normal file
25
AdventOfCode2018.Tests/Day06_Tests.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace AdventOfCode2018.Tests
|
||||||
|
{
|
||||||
|
[TestClass()]
|
||||||
|
public class Day06_Tests
|
||||||
|
{
|
||||||
|
[TestMethod()]
|
||||||
|
public void ResolvePart1__Test()
|
||||||
|
{
|
||||||
|
Day06 day06 = new Day06();
|
||||||
|
|
||||||
|
string result = day06.ResolvePart1(new string[] {
|
||||||
|
"1, 1",
|
||||||
|
"1, 6",
|
||||||
|
"8, 3",
|
||||||
|
"3, 4",
|
||||||
|
"5, 5",
|
||||||
|
"8, 9",
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.AreEqual("17", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
<Compile Include="Day03.cs" />
|
<Compile Include="Day03.cs" />
|
||||||
<Compile Include="Day04.cs" />
|
<Compile Include="Day04.cs" />
|
||||||
<Compile Include="Day05.cs" />
|
<Compile Include="Day05.cs" />
|
||||||
|
<Compile Include="Day06.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -67,6 +68,9 @@
|
|||||||
<Content Include="inputs\Day05.txt">
|
<Content Include="inputs\Day05.txt">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="inputs\Day06.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
70
AdventOfCode2018/Day06.cs
Normal file
70
AdventOfCode2018/Day06.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
namespace AdventOfCode2018
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
--- Day 6: Chronal Coordinates ---
|
||||||
|
|
||||||
|
The device on your wrist beeps several times, and once again you feel like you're falling.
|
||||||
|
|
||||||
|
"Situation critical," the device announces. "Destination indeterminate. Chronal interference detected. Please specify new target coordinates."
|
||||||
|
|
||||||
|
The device then produces a list of coordinates (your puzzle input). Are they places it thinks are safe or dangerous? It recommends you check manual page 729. The Elves did not give you a manual.
|
||||||
|
|
||||||
|
If they're dangerous, maybe you can minimize the danger by finding the coordinate that gives the largest distance from the other points.
|
||||||
|
|
||||||
|
Using only the Manhattan distance, determine the area around each coordinate by counting the number of integer X,Y locations that are closest to that coordinate (and aren't tied in distance to any other coordinate).
|
||||||
|
|
||||||
|
Your goal is to find the size of the largest area that isn't infinite. For example, consider the following list of coordinates:
|
||||||
|
|
||||||
|
1, 1
|
||||||
|
1, 6
|
||||||
|
8, 3
|
||||||
|
3, 4
|
||||||
|
5, 5
|
||||||
|
8, 9
|
||||||
|
|
||||||
|
If we name these coordinates A through F, we can draw them on a grid, putting 0,0 at the top left:
|
||||||
|
|
||||||
|
..........
|
||||||
|
.A........
|
||||||
|
..........
|
||||||
|
........C.
|
||||||
|
...D......
|
||||||
|
.....E....
|
||||||
|
.B........
|
||||||
|
..........
|
||||||
|
..........
|
||||||
|
........F.
|
||||||
|
|
||||||
|
This view is partial - the actual grid extends infinitely in all directions. Using the Manhattan distance, each location's closest coordinate can be determined, shown here in lowercase:
|
||||||
|
|
||||||
|
aaaaa.cccc
|
||||||
|
aAaaa.cccc
|
||||||
|
aaaddecccc
|
||||||
|
aadddeccCc
|
||||||
|
..dDdeeccc
|
||||||
|
bb.deEeecc
|
||||||
|
bBb.eeee..
|
||||||
|
bbb.eeefff
|
||||||
|
bbb.eeffff
|
||||||
|
bbb.ffffFf
|
||||||
|
|
||||||
|
Locations shown as . are equally far from two or more coordinates, and so they don't count as being closest to any.
|
||||||
|
|
||||||
|
In this example, the areas of coordinates A, B, C, and F are infinite - while not shown here, their areas extend forever outside the visible grid. However, the areas of coordinates D and E are finite: D is closest to 9 locations, and E is closest to 17 (both including the coordinate's location itself). Therefore, in this example, the size of the largest area is 17.
|
||||||
|
|
||||||
|
What is the size of the largest area that isn't infinite?
|
||||||
|
|
||||||
|
*/
|
||||||
|
public class Day06
|
||||||
|
{
|
||||||
|
public string ResolvePart1(string[] inputs)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ResolvePart2(string[] inputs)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace AdventOfCode2018
|
|||||||
{
|
{
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
int currentDay = 5;
|
int currentDay = 6;
|
||||||
|
|
||||||
if (currentDay == 1)
|
if (currentDay == 1)
|
||||||
{
|
{
|
||||||
@@ -64,6 +64,17 @@ namespace AdventOfCode2018
|
|||||||
Console.WriteLine("Day04 Result Part2: {0}", resultPart2);
|
Console.WriteLine("Day04 Result Part2: {0}", resultPart2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentDay == 6)
|
||||||
|
{
|
||||||
|
// Resolve Day06
|
||||||
|
Day06 day06 = new Day06();
|
||||||
|
string[] linesDay06 = File.ReadAllLines("inputs/Day06.txt");
|
||||||
|
string resultPart1 = day06.ResolvePart1(linesDay06);
|
||||||
|
Console.WriteLine("Day06 Result Part1: {0}", resultPart1);
|
||||||
|
string resultPart2 = day06.ResolvePart2(linesDay06);
|
||||||
|
Console.WriteLine("Day06 Result Part2: {0}", resultPart2);
|
||||||
|
}
|
||||||
|
|
||||||
Console.Read();
|
Console.Read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
AdventOfCode2018/inputs/Day06.txt
Normal file
50
AdventOfCode2018/inputs/Day06.txt
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
315, 342
|
||||||
|
59, 106
|
||||||
|
44, 207
|
||||||
|
52, 81
|
||||||
|
139, 207
|
||||||
|
93, 135
|
||||||
|
152, 187
|
||||||
|
271, 47
|
||||||
|
223, 342
|
||||||
|
50, 255
|
||||||
|
332, 68
|
||||||
|
322, 64
|
||||||
|
250, 72
|
||||||
|
165, 209
|
||||||
|
129, 350
|
||||||
|
139, 118
|
||||||
|
282, 129
|
||||||
|
311, 264
|
||||||
|
216, 246
|
||||||
|
134, 42
|
||||||
|
66, 151
|
||||||
|
263, 199
|
||||||
|
222, 169
|
||||||
|
236, 212
|
||||||
|
320, 178
|
||||||
|
202, 288
|
||||||
|
273, 190
|
||||||
|
83, 153
|
||||||
|
88, 156
|
||||||
|
284, 305
|
||||||
|
131, 90
|
||||||
|
152, 88
|
||||||
|
358, 346
|
||||||
|
272, 248
|
||||||
|
317, 122
|
||||||
|
166, 179
|
||||||
|
301, 307
|
||||||
|
156, 128
|
||||||
|
261, 290
|
||||||
|
268, 312
|
||||||
|
89, 53
|
||||||
|
324, 173
|
||||||
|
353, 177
|
||||||
|
91, 69
|
||||||
|
303, 164
|
||||||
|
40, 221
|
||||||
|
146, 344
|
||||||
|
61, 314
|
||||||
|
319, 224
|
||||||
|
98, 143
|
||||||
Reference in New Issue
Block a user