Day01_Part2: Add failing tests.

This commit is contained in:
2018-12-03 14:16:15 +01:00
parent a56f250b82
commit 346aa4d049
2 changed files with 92 additions and 1 deletions

View File

@@ -5,6 +5,8 @@ namespace AdventOfCode2018.Tests
[TestClass()] [TestClass()]
public class Day01_Tests public class Day01_Tests
{ {
#region ResolveDay01
[TestMethod()] [TestMethod()]
public void ResolveDay01__Test1() public void ResolveDay01__Test1()
{ {
@@ -44,5 +46,61 @@ namespace AdventOfCode2018.Tests
Assert.AreEqual("-6", result); Assert.AreEqual("-6", result);
} }
#endregion ResolveDay01
#region ResolveDay01_Part2
[TestMethod()]
public void ResolveDay01_Part2__Test1()
{
Day01 day01 = new Day01();
string result = day01.ResolveDay01_Part2(new string[] { "+1", "-2", "+3", "+1", });
Assert.AreEqual("2", result);
}
[TestMethod()]
public void ResolveDay01_Part2__Test2()
{
Day01 day01 = new Day01();
string result = day01.ResolveDay01_Part2(new string[] { "+1", "-1", });
Assert.AreEqual("0", result);
}
[TestMethod()]
public void ResolveDay01_Part2__Test3()
{
Day01 day01 = new Day01();
string result = day01.ResolveDay01_Part2(new string[] { "+3", "+3", "+4", "-2", "-4", });
Assert.AreEqual("10", result);
}
[TestMethod()]
public void ResolveDay01_Part2__Test4()
{
Day01 day01 = new Day01();
string result = day01.ResolveDay01_Part2(new string[] { "-6", "+3", "+8", "+5", "-6", });
Assert.AreEqual("5", result);
}
[TestMethod()]
public void ResolveDay01_Part2__Test5()
{
Day01 day01 = new Day01();
string result = day01.ResolveDay01_Part2(new string[] { "+7", "+7", "-2", "-7", "-4", });
Assert.AreEqual("14", result);
}
#endregion ResolveDay01_Part2
} }
} }

View File

@@ -1,4 +1,6 @@
namespace AdventOfCode2018 using System;
namespace AdventOfCode2018
{ {
/* /*
--- Day 1: Chronal Calibration --- --- Day 1: Chronal Calibration ---
@@ -29,6 +31,32 @@
-1, -2, -3 results in -6 -1, -2, -3 results in -6
Starting with a frequency of zero, what is the resulting frequency after all of the changes in frequency have been applied? Starting with a frequency of zero, what is the resulting frequency after all of the changes in frequency have been applied?
--- Part Two ---
You notice that the device repeats the same frequency change list over and over. To calibrate the device, you need to find the first frequency it reaches twice.
For example, using the same list of changes above, the device would loop as follows:
Current frequency 0, change of +1; resulting frequency 1.
Current frequency 1, change of -2; resulting frequency -1.
Current frequency -1, change of +3; resulting frequency 2.
Current frequency 2, change of +1; resulting frequency 3.
(At this point, the device continues from the start of the list.)
Current frequency 3, change of +1; resulting frequency 4.
Current frequency 4, change of -2; resulting frequency 2, which has already been seen.
In this example, the first frequency reached twice is 2. Note that your device might need to repeat its list of frequency changes many times before a duplicate frequency is found, and that duplicates might be found while in the middle of processing the list.
Here are other examples:
+1, -1 first reaches 0 twice.
+3, +3, +4, -2, -4 first reaches 10 twice.
-6, +3, +8, +5, -6 first reaches 5 twice.
+7, +7, -2, -7, -4 first reaches 14 twice.
What is the first frequency your device reaches twice?
*/ */
public class Day01 public class Day01
@@ -54,5 +82,10 @@
return accumulator.ToString(); return accumulator.ToString();
} }
public string ResolveDay01_Part2(string[] inputs)
{
throw new NotImplementedException();
}
} }
} }