public void FirstTestPassportShouldBeFilledAndValid() { using (AOC aoc = new AOC("batchfile_1.txt")) { Assert.True(aoc.passports[0].isFullyPopulated()); Assert.False(aoc.passports[5].isFullyPopulated()); } }
public void ShouldCalculateVoltage(string filename, int expect) { List <string> input = ParseInput(filename); using (AOC aoc = new AOC()) { Assert.Equal(expect, aoc.CalculateBuiltInVoltage(input)); } }
public void ShouldReturnCorrectAmmountOfValidBagsForFullDataset() { using (AOC aoc = new AOC(input_2)) { int result = aoc.LetsTryThis(); //Console.WriteLine(result); Assert.Equal(248, result); } }
public void ShouldCalculateCorrectDiffs(string filename, int expect) { List <string> input = ParseInput(filename); using (AOC aoc = new AOC()) { Assert.Equal(expect, aoc.CaculateDiffs(input)); } }
public void ShouldValidateDataCorrectly(string datafile, bool result) { List <string> input = ParseInput(datafile); using (AOC aoc = new AOC()) { var data = aoc.ProcessData(input); Assert.Equal(result, aoc.ValidateInstructions(data)); } }
public void ShouldReturnCorrectAccumulator(string datafile, int result) { List <string> input = ParseInput(datafile); using (AOC aoc = new AOC()) { var data = aoc.ProcessData(input); int accumulator = aoc.ExecuteInstructions(data); Assert.Equal(result, accumulator); } }
public void ShouldTwoFindSummable2020() { AOC aoc = new AOC(); int[] set1values = aoc.GetSummableValues(testset1, targetSum); //Console.WriteLine(set1values); Assert.Equal(targetSum, set1values[0] + set1values[1]); int[] set2values = aoc.GetSummableValues(testset2, targetSum); //Console.WriteLine(set2values); Assert.Equal(targetSum, set2values[0] + set2values[1]); }
public void ShouldCountDistinctsCorrectlyForData() { using (AOC aoc = new AOC()) { List <int> expected = new List <int>() { 3, 3, 3, 1, 1 }; Assert.Equal(expected, aoc.CountDistinctAnswers(input)); } }
public void ShouldValidateNumberOfCorrectPasswordsAccordingToSecondRule() { using (AOC aoc = new AOC(testset1, shouldUseSecondRule: true)) { Assert.Equal(1, aoc.validPasswords); } using (AOC aoc = new AOC(testset2, shouldUseSecondRule: true)) { Assert.Equal(670, aoc.validPasswords); } }
public void ShouldValidateNumberOfCorrectPasswords() { using (AOC aoc = new AOC(testset1)) { Assert.Equal(2, aoc.validPasswords); } using (AOC aoc = new AOC(testset2)) { Assert.Equal(666, aoc.validPasswords); } }
public void ShouldCountValidPassports() { using (AOC aoc = new AOC("batchfile_1.txt")) { Assert.Equal(4, aoc.validPassports); } using (AOC aoc = new AOC("batchfile_2.txt")) { Assert.Equal(101, aoc.validPassports); } }
public void ShouldCountTreeCorrectly() { using (AOC aoc = new AOC()) { Assert.Equal(7, aoc.CountTrees(input_1, 1, 3)); } using (AOC aoc = new AOC()) { Assert.Equal(270, aoc.CountTrees(input_2, 1, 3)); } }
public void ShouldProcessDataCorrectly() { List <string> input = ParseInput("data.txt"); using (AOC aoc = new AOC()) { var output = aoc.ProcessData(input); Assert.Equal(9, output.Count()); Assert.Equal(output[3], new Tuple <int, string, int>(0, "acc", 3)); } }
public void ShouldFindValidInstructionSet(string datafile, int result) { List <string> input = ParseInput(datafile); using (AOC aoc = new AOC()) { var data = aoc.ProcessData(input); var validInstructions = aoc.FindValidInstructionSet(data); Assert.Equal(true, aoc.ValidateInstructions(validInstructions)); int accumulator = aoc.ExecuteInstructions(validInstructions); Assert.Equal(result, accumulator); } }
public void ShouldProcessData() { List <string> input = ParseInput("data.txt"); List <int> check = new List <int>() { 16, 10, 15, 5, 1, 11, 7, 19, 6, 12, 4 }; using (AOC aoc = new AOC()) { Assert.Equal(check, aoc.ProcessData(input)); } }
public static void Main() { var lines = File.ReadAllLines(@"..\..\inputs\15.txt"); var ingredients = new List <Ingredient>(); foreach (var line in lines) { var nums = AOC.ParseInts(line); ingredients.Add(new Ingredient(nums[0], nums[1], nums[2], nums[3], nums[4])); } Part1(ingredients); Part2(ingredients); }
public static void Main() { var lines = File.ReadAllLines(@"..\..\inputs\14.txt"); var stats = new List <ReindeerSpecs>(); foreach (var line in lines) { var nums = AOC.ParseInts(line); var speed = Convert.ToInt32(nums[0]); var length = Convert.ToInt32(nums[1]); var rest = Convert.ToInt32(nums[2]); stats.Add(new ReindeerSpecs(speed, length, rest)); } Part1(stats); Part2(stats); }
public void ShouldAddAllDuplicateValuesCorrectly() { using (AOC aoc = new AOC()) { List <int> distinctAnswers = aoc.CountDuplicateAnswers(input_2); //int ans = distinctAnswers.Aggregate(1, (x,y) => x * y); int prod = 0; foreach (int value in distinctAnswers) { if (value == 0) { continue; } prod += value; } Assert.Equal(3640, prod); } }
public void ShouldMultiplyCorrectly() { AOC aoc = new AOC(); int testvalue1 = aoc.MultiplySummableValues(testset1, targetSum); Assert.Equal(514579, testvalue1); int testvalue2 = aoc.MultiplySummableValues(testset2, targetSum); Assert.Equal(996996, testvalue2); int testvalue3 = aoc.MultiplyThreeSummableValues(testset1, targetSum); Assert.Equal(241861950, testvalue3); int testvalue4 = aoc.MultiplyThreeSummableValues(testset2, targetSum); Assert.Equal(9210402, testvalue4); }
public void ShouldCountAdditionalSlopesCorrectly() { using (AOC aoc = new AOC()) { Assert.Equal(2, aoc.CountTrees(input_1, 1, 1)); } using (AOC aoc = new AOC()) { Assert.Equal(3, aoc.CountTrees(input_1, 1, 5)); } using (AOC aoc = new AOC()) { Assert.Equal(4, aoc.CountTrees(input_1, 1, 7)); } using (AOC aoc = new AOC()) { Assert.Equal(2, aoc.CountTrees(input_1, 2, 1)); } using (AOC aoc = new AOC()) { var answer = aoc.CountTrees(input_1, 1, 1) * aoc.CountTrees(input_1, 1, 3) * aoc.CountTrees(input_1, 1, 5) * aoc.CountTrees(input_1, 1, 7) * aoc.CountTrees(input_1, 2, 1); Assert.Equal(336, answer); } using (AOC aoc = new AOC()) { var answer = aoc.CountTrees(input_2, 1, 1) * aoc.CountTrees(input_2, 1, 3) * aoc.CountTrees(input_2, 1, 5) * aoc.CountTrees(input_2, 1, 7) * aoc.CountTrees(input_2, 2, 1); Assert.Equal(2122848000, answer); } }
public void ShouldCalculateHighestSeatID() { AOC aoc = new AOC(); foreach (string s in input) { seatids.Add(aoc.Decode(s)[2]); } Assert.Equal(926, seatids.Max()); //used this txtfile to sort the missing value. // using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"./WriteLines2.txt")) // { // foreach (int line in seatids) // { // file.WriteLine(""+line); // } // } }
public void ShouldFindMissingSeatNumber() { using (AOC aoc = new AOC()) { foreach (string s in input) { seatids.Add(aoc.Decode(s)[2]); } var ascendingOrder = seatids.OrderBy(i => i); int count = 80; // 80 being the lowest id possible foreach (var value in ascendingOrder) { if (count != value) { //Console.WriteLine($"Found missing {count}"); break; } count++; } Assert.Equal(657, count); } }
public static void Part2(bool[,] lights) { var currentLights = AOC.Clone(lights); int width = currentLights.GetLength(0) - 1; int height = currentLights.GetLength(1) - 1; currentLights[0, 0] = true; currentLights[0, height] = true; currentLights[width, 0] = true; currentLights[width, height] = true; var newLights = new bool[lights.GetLength(0), lights.GetLength(1)]; for (int t = 0; t < 100; t++) { Step(currentLights, newLights); currentLights = AOC.Clone(newLights); currentLights[0, 0] = true; currentLights[0, height] = true; currentLights[width, 0] = true; currentLights[width, height] = true; } int count = 0; for (int x = 0; x < currentLights.GetLength(0); x++) { for (int y = 0; y < currentLights.GetLength(1); y++) { if (currentLights[x, y]) { count++; } } } Console.WriteLine(count); }
public static void Main() { var input = File.ReadAllText(@"..\..\inputs\21.txt"); var ints = AOC.ParseInts(input); var boss = new FighterStat { Hp = ints[0], Damage = ints[1], Armor = ints[2] }; var weapons = new List <Item> { new Item(8, 4, 0), new Item(10, 5, 0), new Item(25, 6, 0), new Item(40, 7, 0), new Item(74, 8, 0) }; var armor = new List <Item> { new Item(13, 0, 1), new Item(31, 0, 2), new Item(53, 0, 3), new Item(75, 0, 4), new Item(102, 0, 5) }; var rings = new List <Item> { new Item(25, 1, 0), new Item(50, 2, 0), new Item(100, 3, 0), new Item(20, 0, 1), new Item(40, 0, 2), new Item(80, 0, 3) }; Part1(boss, weapons, armor, rings); Part2(boss, weapons, armor, rings); }
public static void Main() { var nums = AOC.ParseInts(File.ReadAllText(@"..\..\inputs\22.txt")); // var bossStats = new FighterStats(14, 8, 0, 0); var bossStats = new FighterStats(nums[0], nums[1], 0, 0); var spells = new List <Spell> { new Spell("Magic missile", 53, 4, 0, null), // Magic missile new Spell("Drain", 73, 2, 2, null), // Drain new Spell("Shield", 113, 0, 0, new Effect { ID = 1, Duration = 6, Armor = 7 }), // Shield new Spell("Poison", 173, 0, 0, new Effect { ID = 2, Duration = 6, Damage = 3 }), // Poison new Spell("Recharge", 229, 0, 0, new Effect { ID = 3, Duration = 5, Mana = 101 }), // Recharge }; Part1(bossStats, spells); Part2(bossStats, spells); }
public UnitTest1() { AOC aoc = new AOC(); }
public static void Part1(List <int> sizes) { int combinations = AOC.Combinations <int>(sizes).Where(combo => combo.Sum() == 150).Count(); Console.WriteLine(combinations); }