예제 #1
0
        public void testCalculateChecksum_PartB()
        {
            var sut    = new DayTwo();
            var result = sut.PartB();

            Assert.Equal("282", result);
        }
예제 #2
0
        public void testCalculateLineEvenDivision(string line, long expected)
        {
            var sut    = new DayTwo();
            var result = sut.CalculateLineEvenDivision(line);

            Assert.Equal(expected, result);
        }
        protected async Task ShowResults()
        {
            if (ValidateTextbox())
            {
                invalid = false;
                DayTwo _challengeSolver = new DayTwo();

                _partOne = 0;
                _partTwo = 0;

                await RefreshReport();

                if (_passwords.Count > 0)
                {
                    _partOne = _challengeSolver.PartOne(_passwords);
                    _partTwo = _challengeSolver.PartTwo(_passwords);
                }

                if (_partOne != 0 && _partTwo != 0)
                {
                    childOne.Show();
                    childTwo.Show();
                }
                else
                {
                    invalid = true;
                }
            }
            else
            {
                invalid = true;
            }
        }
예제 #4
0
        public void PartB_Actual()
        {
            var sut    = new DayTwo();
            var result = sut.PartB();

            Assert.Equal("649", result);
        }
예제 #5
0
        public void testCalculateLineDifference(string line, long expected)
        {
            var sut    = new DayTwo();
            var result = sut.CalculateLineDifference(line);

            Assert.Equal(expected, result);
        }
예제 #6
0
        public void PartB_Actual()
        {
            var sut    = new DayTwo();
            var result = sut.PartB();

            Assert.Equal("mbruvapghxlzycbhmfqjonsie", result);
        }
예제 #7
0
        public void ContainsNumberOfDuplicateLetters(string input, int duplicatesRequired, bool expected)
        {
            var sut    = new DayTwo();
            var result = sut.ContainsNumberOfDuplicateLetters(input, duplicatesRequired);

            Assert.Equal(expected, result);
        }
예제 #8
0
        public void CalculateCheckSum(string input, int expected)
        {
            var sut    = new DayTwo();
            var result = sut.CalculateCheckSum(input);

            Assert.Equal(expected, result);
        }
예제 #9
0
        public void testDetermineBathroomCodeSimple(string expected, string input)
        {
            var sot    = new DayTwo();
            var result = sot.DetermineBathroomCode(input, 1, 1, DayTwo.KEY_PAD);

            Assert.Equal(expected, result);
        }
예제 #10
0
        public void testWithActualPartB()
        {
            var sot    = new DayTwo();
            var result = sot.DetermineBathroomCode(DayTwo.PUZZLE_INPUT, 1, 1, DayTwo.KEY_PAD_TWO);

            Assert.Equal("46C91", result);
        }
예제 #11
0
        public void PartA_Actual()
        {
            var sut    = new DayTwo();
            var result = sut.PartA();

            Assert.Equal("454", result);
        }
예제 #12
0
        static void Main(string[] args)
        {
            var inputFilesFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var content          = File.ReadAllText(Path.Combine(inputFilesFolder, "input2.txt"));
            var result           = new DayTwo().Solve(content, true);

            Console.WriteLine("Result is: " + result);
        }
예제 #13
0
        public void CalculateCheckSumLines()
        {
            var filePath = @"Two\DayTwoTestInputB.txt";
            var sut      = new DayTwo();
            var result   = sut.FindCommonLetters(filePath);

            Assert.Equal("fgij", result);
        }
예제 #14
0
        public void Solution()
        {
            const string Expected = "ivjhcadokeltwgsfsmqwrbnuy";

            var input  = Resources.InputD2P1.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries).ToArray();
            var actual = DayTwo.CommonLetters(input);

            Assert.Equal(Expected, actual);
        }
예제 #15
0
        public void Test1()
        {
            var input = new[] { "abcde", "fghij", "klmno", "pqrst", "fguij", "axcye", "wvxyz" };

            const string Expected = "fgij";
            var          actual   = DayTwo.CommonLetters(input);

            Assert.Equal(Expected, actual);
        }
예제 #16
0
        public void CallengeOne_TestSituation1()
        {
            string input = "abcdef";

            var(Twice, ThreeTimes) = DayTwo.CountTwiceAndThreeTimes(input);

            Assert.AreEqual(false, Twice);
            Assert.AreEqual(false, ThreeTimes);
        }
예제 #17
0
        public void CallengeOne_TestSituation2()
        {
            string input = "bababc";

            var(Twice, ThreeTimes) = DayTwo.CountTwiceAndThreeTimes(input);

            Assert.AreEqual(true, Twice);
            Assert.AreEqual(true, ThreeTimes);
        }
예제 #18
0
        public void Solution()
        {
            const int Expected = 7657;

            var input  = Resources.InputD2P1.Split(Environment.NewLine).ToArray();
            var actual = DayTwo.Checksum(input);

            Assert.Equal(Expected, actual);
        }
예제 #19
0
        public void Test1()
        {
            var input = new[] { "abcdef", "bababc", "abbcde", "abcccd", "aabcdd", "abcdee", "ababab" };

            const int Expected = 12;
            var       actual   = DayTwo.Checksum(input);

            Assert.Equal(Expected, actual);
        }
예제 #20
0
        public void BasicCasesPass()
        {
            var dayTwo = new DayTwo();

            Assert.AreEqual(3500, dayTwo.Solve("1,9,10,3,2,3,11,0,99,30,40,50"));
            Assert.AreEqual(30, dayTwo.Solve("1,1,1,4,99,5,6,0,99"));
            Assert.AreEqual(2, dayTwo.Solve("1,0,0,0,99"));
            Assert.AreEqual(2, dayTwo.Solve("2,3,0,3,99"));
        }
예제 #21
0
        public void testDetermineBathroomCode()
        {
            string input  = @"ULL
RRDDD
LURDL
UUUUD";
            var    sot    = new DayTwo();
            var    result = sot.DetermineBathroomCode(input, 1, 1, DayTwo.KEY_PAD);

            Assert.Equal("1985", result);
        }
예제 #22
0
        public void ChallengeOne_TestSituationComplete()
        {
            string input = @"
abcdef
bababc
abbcde
abcccd
aabcdd
abcdee
ababab";

            int result = DayTwo.ComputeChallengeOneResult(input);

            Assert.AreEqual(12, result);
        }
예제 #23
0
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            var dayTwoOutput = DayTwo.ValidPasswordCountProblemOne(Properties.Resources.Exercise_02.Split(Environment.NewLine));

            stopwatch.Stop();
            Console.WriteLine($"Day Two Output: {dayTwoOutput} completed in {stopwatch.Elapsed.TotalMilliseconds} milliseconds");
            stopwatch.Reset();
            stopwatch.Start();
            var dayTwoOutputProblem02 = DayTwo.ValidPasswordCountProblemTwo(Properties.Resources.Exercise_02.Split(Environment.NewLine));

            stopwatch.Stop();
            Console.WriteLine($"Day Two Output: {dayTwoOutputProblem02} completed in {stopwatch.Elapsed.TotalMilliseconds} milliseconds");
        }
예제 #24
0
        static void Main()
        {
            DayOne.TaskOne();
            DayOne.TaskTwo();

            DayTwo.TaskOne();
            DayTwo.TaskTwo();

            DayThree.TaskOne();
            DayThree.TaskTwo();

            DayFour.TaskOne();
            DayFour.TaskTwo();

            DaySix.TaskOne();
            DaySix.TaskTwo();

            Console.Read();
        }
예제 #25
0
        public void Day2_P2Test()
        {
            var input = File.ReadAllText("./Files/Day_2/Day2_Test.input").Split("\r\n");

            Assert.AreEqual(1, DayTwo.Day2_P2(input));
        }
예제 #26
0
        public void PartOne()
        {
            var dayTwo = new DayTwo();

            var output = dayTwo.PartOne(FilePath);
        }
예제 #27
0
파일: main.cs 프로젝트: abercr0mby/aoc-2019
        static void Main(string[] args)
        {
            /*  try{
             *  var dayOne = new DayOne();
             *  Console.WriteLine(dayOne.RunTestsAndGetResultPartOne());
             *  Console.WriteLine(dayOne.RunTestsAndGetResultPartTwo());
             * }
             * catch(Exception ex){
             *  Console.WriteLine(ex.Message);
             * }
             */

            try{
                var dayTwo = new DayTwo();
                Console.WriteLine(dayTwo.RunTestsAndGetResultPartOne());
                // Console.WriteLine(dayTwo.GetResultPartTwo());
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }


            /*
             * try{
             * var dayThree = new DayThree();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(dayThree.RunTestsAndGetResultPartOne());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             *
             * try{
             * var dayThree = new DayThree();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(dayThree.RunTestsAndGetResultPartTwo());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             */

            /*
             * try{
             * var dayFour = new DayFour();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(dayFour.RunTestsAndGetResultPartOne());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             */



            try{
                var dayFive = new DayFive();
                var watch   = System.Diagnostics.Stopwatch.StartNew();
                dayFive.RunTestsAndShowResultPartOne();
                watch.Stop();
                Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            try{
                var dayFive = new DayFive();
                var watch   = System.Diagnostics.Stopwatch.StartNew();
                dayFive.RunTestsAndShowResultPartTwo();
                watch.Stop();
                Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }


            /*
             * try{
             * var daySix = new DaySix();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(daySix.RunTestsAndGetResultPartOne());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             *
             * try{
             * var daySix = new DaySix();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(daySix.RunTestsAndGetResultPartTwo());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             */


            try{
                var daySeven = new DaySeven();
                var watch    = System.Diagnostics.Stopwatch.StartNew();
                Console.WriteLine(daySeven.RunTestsAndGetResultPartOne());
                watch.Stop();
                Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            try{
                var daySeven = new DaySeven();
                var watch    = System.Diagnostics.Stopwatch.StartNew();
                Console.WriteLine(daySeven.RunTestsAndGetResultPartTwo());
                watch.Stop();
                Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }


            /*
             * try{
             * var dayEight = new DayEight();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(dayEight.RunTestsAndGetResultPartOne());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             *
             * try{
             * var dayEight = new DayEight();
             * var watch = System.Diagnostics.Stopwatch.StartNew();
             * Console.WriteLine(dayEight.RunTestsAndGetResultPartTwo());
             * watch.Stop();
             * Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
             * }
             * catch(Exception ex){
             * Console.WriteLine(ex.Message);
             * }
             */


            try{
                var dayNine = new DayNine();
                var watch   = System.Diagnostics.Stopwatch.StartNew();
                Console.WriteLine(dayNine.RunTestsAndGetResultPartOne());
                watch.Stop();
                Console.WriteLine("Time:" + watch.ElapsedMilliseconds);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
예제 #28
0
        public void DayTwoPartTwoReturnsCorrectly(string input, int expected)
        {
            var result = DayTwo.PartTwo(input);

            Assert.AreEqual(expected, result);
        }
예제 #29
0
        public void PartTwo()
        {
            var dayTwo = new DayTwo();

            var output = new string(dayTwo.PartTwo(FilePath).ToArray());
        }
예제 #30
0
 public int[] ProblemOne_ValidInput_ReturnsCorrectResult(int[] inp)
 => DayTwo.ProblemOne(inp);