Ejemplo n.º 1
0
        public void Execute(int target = 2020, string fileName = ".\\Puzzles\\Day1\\Expenses.txt")
        {
            var expenses = _dataReader.ReadData <int>(fileName);
            var result   = _engine.Execute(target, expenses.Cast <int>().ToArray());

            Console.WriteLine($"Target was: {target} answer is: {result}");
        }
Ejemplo n.º 2
0
        public void Execute(string fileName = ".\\Puzzles\\Day2\\Passwords.txt")
        {
            var passwordInfoList = _fileReader.ReadData <string>(fileName);
            int validPasswordCountEx1, validPasswordCountEx2;

            _engine.Execute(passwordInfoList, out validPasswordCountEx1, out validPasswordCountEx2);
            Console.WriteLine($"There were {validPasswordCountEx1} valid passwords for policy 1 and {validPasswordCountEx2}  for policy 2.");
        }
Ejemplo n.º 3
0
        public void Execute(string fileName = ".\\Puzzles\\Day13\\arrivalnotes.txt")
        {
            var arrivalNotes = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(arrivalNotes.ToArray());

            Console.WriteLine($"   Part 1 - Bus code: {result}");
        }
Ejemplo n.º 4
0
        public void Execute(string fileName = ".\\Puzzles\\Day4\\passports.txt")
        {
            var passportData = _fileReader.ReadData <string>(fileName);
            var results      = _engine.Execute(passportData);

            Console.WriteLine($"Total passports: {results.totalPassportsValidated}");
            Console.WriteLine($"   Total passports with mandatory: {results.countMandatory}, of which also had optional {results.countMandatoryAndOptional}");
            Console.WriteLine($"   Total passports valid: {results.countValid}, total invalid {results.countInValid}");
        }
Ejemplo n.º 5
0
        public void Execute(string fileName = ".\\Puzzles\\Day16\\ticketNotes.txt")
        {
            var ticketNotes = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(ticketNotes);

            Console.WriteLine($"   Part 1 - Scanning error rate: {result}");
        }
Ejemplo n.º 6
0
        public void Execute(string fileName = ".\\Puzzles\\Day14\\initprogram.txt")
        {
            var arrivalNotes = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(arrivalNotes.ToList());

            Console.WriteLine($"   Part 1 - Sum of memory addresses: {result}");
        }
Ejemplo n.º 7
0
        public void Execute(string fileName = ".\\Puzzles\\Day15\\startingNumbers.txt")
        {
            var startingNumbersAsString = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(2020, startingNumbersAsString.ToArray()[0]);

            Console.WriteLine($"   Part 1 - Last number: {result}");
        }
Ejemplo n.º 8
0
        public void Execute(string fileName = ".\\Puzzles\\Day12\\directions.txt")
        {
            var directions = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(directions);

            Console.WriteLine($"   Part 1 - Manhattan Distance: {result.ManhattanDistance} - Final Pos: {result.ToString()}");
        }
Ejemplo n.º 9
0
        public void Execute(string fileName = ".\\Puzzles\\Day5\\boardingcards.txt")
        {
            var boardCardBarCodes = _fileReader.ReadData <string>(fileName);

            var result = _engine.Execute(boardCardBarCodes);

            Console.WriteLine($"   Part 1 - Max Seat ID is: {result}");

            var result2 = _engine.Execute2(boardCardBarCodes);

            Console.WriteLine($"   Part 2 - Your seat is: {result2}");
        }
Ejemplo n.º 10
0
        public void Execute(string fileName = ".\\Puzzles\\Day6\\postivecustomsqs.txt")
        {
            var customsAnswers = _fileReader.ReadData <string>(fileName);

            var result = _engine.Execute(customsAnswers);

            Console.WriteLine($"   Part 1 - Total distinct positive answers from ANY party member: {result}");

            var result2 = _engine.Execute2(customsAnswers);

            Console.WriteLine($"   Part 2 - Total distinct positive answers for ALL party members: {result2}");
        }
Ejemplo n.º 11
0
        public void Execute(string fileName = ".\\Puzzles\\Day11\\seatingplan.txt")
        {
            var seats = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(seats);

            Console.WriteLine($"   Part 1 - Occupied seats: {result}");

            //Console.WriteLine("Staring part 2");
            //var result2 = _engine.Execute2(adapters);
            //Console.WriteLine($"   Part 2 - Adapter combinations: {result2}");
        }
Ejemplo n.º 12
0
        public void Execute(string fileName = ".\\Puzzles\\Day7\\bagrules.txt")
        {
            var bagRulesAsText = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(bagRulesAsText, "shiny gold");

            Console.WriteLine($"   Part 1 - Total containers for shiny gold bag is: {result}");

            Console.WriteLine("Staring part 2");
            var result2 = _engine.Execute2(bagRulesAsText, "shiny gold");

            Console.WriteLine($"   Part 2 - Total bags within a shiny gold bag is: {result2}");
        }
Ejemplo n.º 13
0
        public void Execute(string fileName = ".\\Puzzles\\Day10\\adapters.txt")
        {
            var adapters = _fileReader.ReadData <int>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(adapters);

            Console.WriteLine($"   Part 1 - Adapters check code: {result}");

            Console.WriteLine("Staring part 2");
            var result2 = _engine.Execute2(adapters);

            Console.WriteLine($"   Part 2 - Adapter combinations: {result2}");
        }
Ejemplo n.º 14
0
        public void Execute(string fileName = ".\\Puzzles\\Day8\\instructions.txt")
        {
            var instructionsAsText = _fileReader.ReadData <string>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(instructionsAsText);

            Console.WriteLine($"   Part 1 - Accumulator value: {result}");

            Console.WriteLine("Staring part 2");
            var result2 = _engine.Execute2(instructionsAsText);

            Console.WriteLine($"   Part 2 - Accumulator value and program end: {result2}");
        }
Ejemplo n.º 15
0
        public void Execute(string fileName = ".\\Puzzles\\Day9\\XMASData.txt")
        {
            var xmasData = _fileReader.ReadData <long>(fileName);

            Console.WriteLine("Staring part 1");
            var result = _engine.Execute(25, xmasData);

            Console.WriteLine($"   Part 1 - first invalid value: {result}");

            Console.WriteLine("Staring part 2");
            var result2 = _engine.Execute2(result, xmasData);

            Console.WriteLine($"   Part 2 - Encryption Weakness Number: {result2}");
        }
Ejemplo n.º 16
0
        public void Execute(string fileName = ".\\Puzzles\\Day3\\SkiSlope.txt")
        {
            var skiSlopePattern = _fileReader.ReadData <string>(fileName);
            var trees_1_1       = _engine.Execute(skiSlopePattern, 1, 1);

            Console.WriteLine($"There were {trees_1_1} trees on the slope");
            var trees_3_1 = _engine.Execute(skiSlopePattern, 3, 1);

            Console.WriteLine($"There were {trees_3_1} trees on the slope");
            var trees_5_1 = _engine.Execute(skiSlopePattern, 5, 1);

            Console.WriteLine($"There were {trees_5_1} trees on the slope");
            var trees_7_1 = _engine.Execute(skiSlopePattern, 7, 1);

            Console.WriteLine($"There were {trees_7_1} trees on the slope");
            var trees_1_2 = _engine.Execute(skiSlopePattern, 1, 2);

            Console.WriteLine($"There were {trees_1_2} trees on the slope");

            Console.WriteLine($"Multiplied total trees: {trees_1_1 * trees_3_1 * trees_5_1 * trees_7_1 * trees_1_2} trees on the slope");
        }