コード例 #1
0
        public void InverseCaptchaPartTwo_PairsOfRepeatingDigits()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptchaPartTwo("1212");

            // assert
            Assert.AreEqual(6, result);
        }
コード例 #2
0
        public void InverseCaptcha_AllRepeatingDigits()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptcha("1111");

            // assert
            Assert.AreEqual(4, result);
        }
コード例 #3
0
        public void InverseCaptchaPartTwo_TrioOfRepeatingDigits()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptchaPartTwo("123123");

            // assert
            Assert.AreEqual(12, result);
        }
コード例 #4
0
        public void InverseCaptchaPartTwo_SingleRepeatingSet()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptchaPartTwo("123425");

            // assert
            Assert.AreEqual(4, result);
        }
コード例 #5
0
        public void InverseCaptcha_PairsOfRepeatingDigits()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptcha("1122");

            // assert
            Assert.AreEqual(3, result);
        }
コード例 #6
0
        public void InverseCaptchaPartTwo_OneDigitRepeatedFourTimes()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptchaPartTwo("12131415");

            // assert
            Assert.AreEqual(4, result);
        }
コード例 #7
0
        public void ShouldReturnCorrectValuesForSolve1(string input, int expected)
        {
            var reader = new StringReader(input);

            var sum = new InverseCaptcha().Solve1(reader);

            Assert.Equal(expected, sum);
        }
コード例 #8
0
        public void InverseCaptchaPartTwo_NoRepeatingDigits()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptchaPartTwo("1221");

            // assert
            Assert.AreEqual(0, result);
        }
コード例 #9
0
        public void InverseCaptcha_RepeatingDigitAtEnd()
        {
            // act
            var result = InverseCaptcha.CalculateInverseCaptcha("91212129");

            // assert
            Assert.AreEqual(9, result);
        }
コード例 #10
0
        public void ExecutePart2_Always_ReturnsCorrectResult(string inputString, int expectedResult)
        {
            var inputEnumerable =
                from a in inputString.ToCharArray()
                select int.Parse(a.ToString());

            var inputArray = inputEnumerable.ToArray();

            var sut    = new InverseCaptcha();
            var result = sut.EvaluatePart2(inputArray);

            result.ShouldBe(expectedResult);
        }
コード例 #11
0
        static void Main(string[] args)
        {
            Console.WriteLine($"Day1 Answer: {InverseCaptcha.CalcSum()}");
            Console.WriteLine($"Day1 Part2 Answer: {InverseCaptcha.CalcSumPart2()}");

            var day2InputPuzzle = System.IO.File.ReadAllText("Day2\\InputPuzzleDay2.txt");

            Console.WriteLine($"Day2 Answer: {CorruptionChecksum.CalculateCheckSum(day2InputPuzzle)}");
            Console.WriteLine($"Day1 Part2 Answer: {CorruptionChecksum.CalculateCheckSum_Part2(day2InputPuzzle)}");

            Console.WriteLine($"Day3 Answer: {SpiralMemory.CalculateSteps(289326)}");


            if (Debugger.IsAttached)
            {
                Console.ReadKey();
            }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: kevbite/AdventOfCode2017
        static void Main(string[] args)
        {
            var inverseCaptcha = new InverseCaptcha();
            var day1resultA    = inverseCaptcha.Solve1(new StringReader(Day1Input));

            Console.WriteLine($"Day 1A result: {day1resultA}");
            var day1resultB = inverseCaptcha.Solve2(Day1Input);

            Console.WriteLine($"Day 1B result: {day1resultB}");

            var corruptionChecksumCalculator = new CorruptionChecksumCalculator();
            var day2Aresult = corruptionChecksumCalculator.Calculate(Day2Input);

            Console.WriteLine($"Day 2 result: {day2Aresult}");

            var day2Bresult = corruptionChecksumCalculator.GetSumOfEvenlyDivisibleValues(Day2Input);

            Console.WriteLine($"Day 2 result: {day2Bresult}");
        }
コード例 #13
0
        public override void Run()
        {
            Console.WriteLine("Day 1");
            var input = GetInput();

            Console.WriteLine("Part 1");
            var captcha = new InverseCaptcha(new NextDigit());
            var result  = captcha.Calculate(input);

            Console.WriteLine($"Result: {result}");


            Console.WriteLine("Part 2");
            captcha = new InverseCaptcha(new HalfwayAroundDigit());
            result  = captcha.Calculate(input);

            Console.WriteLine($"Result: {result}");
            Console.WriteLine();
        }
コード例 #14
0
 public void Setup()
 {
     ClassUnderTest = new InverseCaptcha();
 }
コード例 #15
0
 public void ExamplesPart2(string input, long expected)
 {
     InverseCaptcha.CalcSumPart2(input).Should().Be(expected);
 }
コード例 #16
0
        static void Main(string[] args)
        {
            var day = new InverseCaptcha();

            Console.WriteLine(day.Run());
        }
コード例 #17
0
 public void PartTwo(int expected, string value)
 {
     Assert.Equal(expected, InverseCaptcha.
                  findSumOfDigitsMatchHalfDigit(value));
 }
コード例 #18
0
 public void PuzzlePartA()
 {
     Assert.Equal(1171, InverseCaptcha.
                  findSumOfDigitsMatchNextDigit(input));
 }
コード例 #19
0
 public void PuzzlePartB()
 {
     Assert.Equal(1024, InverseCaptcha.
                  findSumOfDigitsMatchHalfDigit(input));
 }
コード例 #20
0
        // ReSharper disable once InconsistentNaming
        public void With_Input_X_Answer_Is_Y(string input, int expectedAnswer)
        {
            var actualAnswer = InverseCaptcha.CalculateAnswer(input);

            Assert.Equal(actualAnswer, expectedAnswer);
        }
コード例 #21
0
 public void SetupBase()
 {
     Subject = new InverseCaptcha(DigitFinder);
 }