private void btn_day5_Click(object sender, RoutedEventArgs e) { Day5 d = new Day5(); int[] inputArray = { 1 }; int solution1 = d.runThermalEnvironmentSupervisionTerminal(inputArray); Console.WriteLine("Solution 1 " + solution1); Console.WriteLine(4511442 == solution1); inputArray[0] = 5; int solution2 = d.runThermalEnvironmentSupervisionTerminal(inputArray); Console.WriteLine("Solution 2 " + solution2); Console.WriteLine(12648139 == solution2); /* * Day8 d = new Day8(); * d.solveTask1(); * d.solveTask2(); */ }
public static int PartOne() { // all possible permutations var vals = new[] { 0, 1, 2, 3, 4 }; var result = Permutations(vals); int[] bestPermutation = new int[5]; int highestVal = 0; foreach (var permutation in result) { int input = 0; for (int i = 0; i < permutation.Length; i++) { input = Day5.PartTwo(permutation[i], @"..\..\..\..\..\data\7.txt", input); } if (input > highestVal) { highestVal = input; permutation.CopyTo(bestPermutation, 0); } } return(highestVal); }