Example #1
0
        public void Part2_WhenCalled_ProvidesSolution(string input, int expected)
        {
            var solve = new Day01();

            int actual = solve.Part2(input);

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void FindXThatSum_Find3FromSample_ExpectedOutput()
        {
            var input          = new [] { 1721, 979, 366, 299, 675, 1456 };
            var expectedOutput = 241861950;
            var outputWriter   = Substitute.For <TextWriter>();

            var output = new Day01(outputWriter).FindXThatSum(input, 2020, 3).Aggregate((c, n) => c * n);

            Assert.Equal(expectedOutput, output);
        }
Example #3
0
 public void Puzzle1ExampleTest()
 {
     // Example 1
     Assert.AreEqual(3, Day01.Puzzle1(InputData.ResourceManager.GetObject("D01_E1").ToString().Replace(",", Environment.NewLine)));
     // Example 2
     Assert.AreEqual(3, Day01.Puzzle1(InputData.ResourceManager.GetObject("D01_E2").ToString().Replace(",", Environment.NewLine)));
     // Example 3
     Assert.AreEqual(0, Day01.Puzzle1(InputData.ResourceManager.GetObject("D01_E3").ToString().Replace(",", Environment.NewLine)));
     // Example 4
     Assert.AreEqual(-6, Day01.Puzzle1(InputData.ResourceManager.GetObject("D01_E4").ToString().Replace(",", Environment.NewLine)));
 }
Example #4
0
 public void Puzzle2ExampleTest()
 {
     // Example 1
     Assert.AreEqual(2, Day01.Puzzle2(InputData.ResourceManager.GetObject("D01_E1").ToString().Replace(",", Environment.NewLine)));
     // Example 5
     Assert.AreEqual(0, Day01.Puzzle2(InputData.ResourceManager.GetObject("D01_E5").ToString().Replace(",", Environment.NewLine)));
     // Example 6
     Assert.AreEqual(10, Day01.Puzzle2(InputData.ResourceManager.GetObject("D01_E6").ToString().Replace(",", Environment.NewLine)));
     // Example 7
     Assert.AreEqual(5, Day01.Puzzle2(InputData.ResourceManager.GetObject("D01_E7").ToString().Replace(",", Environment.NewLine)));
     // Example 7
     Assert.AreEqual(14, Day01.Puzzle2(InputData.ResourceManager.GetObject("D01_E8").ToString().Replace(",", Environment.NewLine)));
 }
Example #5
0
        public void Puzzle2Test()
        {
            var resultingFrequency = Day01.Puzzle2(inputDay01);

            Assert.AreEqual(83445, resultingFrequency);
        }
Example #6
0
 public void Puzzle1Test()
 {
     Assert.AreEqual(590, Day01.Puzzle1(inputDay01));
 }