Day05: Statement and failing tests
This commit is contained in:
@@ -61,6 +61,7 @@
|
|||||||
<Compile Include="Day02_Tests.cs" />
|
<Compile Include="Day02_Tests.cs" />
|
||||||
<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="GuardEvent_Tests.cs" />
|
<Compile Include="GuardEvent_Tests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
18
AdventOfCode2018.Tests/Day05_Tests.cs
Normal file
18
AdventOfCode2018.Tests/Day05_Tests.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace AdventOfCode2018.Tests
|
||||||
|
{
|
||||||
|
[TestClass()]
|
||||||
|
public class Day05_Tests
|
||||||
|
{
|
||||||
|
[TestMethod()]
|
||||||
|
public void ResolvePart1__Test()
|
||||||
|
{
|
||||||
|
Day05 day05 = new Day05();
|
||||||
|
|
||||||
|
string result = day05.ResolvePart1("dabAcCaCBAcCcaDA");
|
||||||
|
|
||||||
|
Assert.AreEqual("10", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
<Compile Include="Day02.cs" />
|
<Compile Include="Day02.cs" />
|
||||||
<Compile Include="Day03.cs" />
|
<Compile Include="Day03.cs" />
|
||||||
<Compile Include="Day04.cs" />
|
<Compile Include="Day04.cs" />
|
||||||
|
<Compile Include="Day05.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -63,6 +64,9 @@
|
|||||||
<Content Include="inputs\Day04.txt">
|
<Content Include="inputs\Day04.txt">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="inputs\Day05.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
44
AdventOfCode2018/Day05.cs
Normal file
44
AdventOfCode2018/Day05.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
namespace AdventOfCode2018
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
--- Day 5: Alchemical Reduction ---
|
||||||
|
|
||||||
|
You've managed to sneak in to the prototype suit manufacturing lab. The Elves are making decent progress, but are still struggling with the suit's size reduction capabilities.
|
||||||
|
|
||||||
|
While the very latest in 1518 alchemical technology might have solved their problem eventually, you can do better. You scan the chemical composition of the suit's material and discover that it is formed by extremely long polymers (one of which is available as your puzzle input).
|
||||||
|
|
||||||
|
The polymer is formed by smaller units which, when triggered, react with each other such that two adjacent units of the same type and opposite polarity are destroyed. Units' types are represented by letters; units' polarity is represented by capitalization. For instance, r and R are units with the same type but opposite polarity, whereas r and s are entirely different types and do not react.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
In aA, a and A react, leaving nothing behind.
|
||||||
|
In abBA, bB destroys itself, leaving aA. As above, this then destroys itself, leaving nothing.
|
||||||
|
In abAB, no two adjacent units are of the same type, and so nothing happens.
|
||||||
|
In aabAAB, even though aa and AA are of the same type, their polarities match, and so nothing happens.
|
||||||
|
|
||||||
|
Now, consider a larger example, dabAcCaCBAcCcaDA:
|
||||||
|
|
||||||
|
dabAcCaCBAcCcaDA The first 'cC' is removed.
|
||||||
|
dabAaCBAcCcaDA This creates 'Aa', which is removed.
|
||||||
|
dabCBAcCcaDA Either 'cC' or 'Cc' are removed (the result is the same).
|
||||||
|
dabCBAcaDA No further actions can be taken.
|
||||||
|
|
||||||
|
After all possible reactions, the resulting polymer contains 10 units.
|
||||||
|
|
||||||
|
How many units remain after fully reacting the polymer you scanned? (Note: in this puzzle and others, the input is large; if you copy/paste your input, make sure you get the whole thing.)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Day05
|
||||||
|
{
|
||||||
|
public string ResolvePart1(string input)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ResolvePart2(string input)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace AdventOfCode2018
|
|||||||
{
|
{
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
int currentDay = 4;
|
int currentDay = 5;
|
||||||
|
|
||||||
if (currentDay == 1)
|
if (currentDay == 1)
|
||||||
{
|
{
|
||||||
@@ -53,6 +53,17 @@ namespace AdventOfCode2018
|
|||||||
Console.WriteLine("Day04 Result Part2: {0}", resultPart2);
|
Console.WriteLine("Day04 Result Part2: {0}", resultPart2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentDay == 5)
|
||||||
|
{
|
||||||
|
// Resolve Day05
|
||||||
|
Day05 day05 = new Day05();
|
||||||
|
string dataDay05 = File.ReadAllText("inputs/Day05.txt");
|
||||||
|
string resultPart1 = day05.ResolvePart1(dataDay05);
|
||||||
|
Console.WriteLine("Day04 Result Part1: {0}", resultPart1);
|
||||||
|
string resultPart2 = day05.ResolvePart2(dataDay05);
|
||||||
|
Console.WriteLine("Day04 Result Part2: {0}", resultPart2);
|
||||||
|
}
|
||||||
|
|
||||||
Console.Read();
|
Console.Read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
AdventOfCode2018/inputs/Day05.txt
Normal file
1
AdventOfCode2018/inputs/Day05.txt
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user