static void Main(string[] args) { // Part 1 var numList = PROBLEM_INPUT.Split('\n', StringSplitOptions.RemoveEmptyEntries).Select(e => int.Parse(e)).ToList(); for (int i = 0; i < numList.Count; i++) { for (int j = i + 1; j < numList.Count; j++) { if (numList[i] + numList[j] == 2020) { Console.WriteLine($"{numList[i] * numList[j]}"); break; } } } // Part 2 for (int i = 0; i < numList.Count; i++) { for (int j = i + 1; j < numList.Count; j++) { for (int k = j + 1; k < numList.Count; k++) { if (numList[i] + numList[j] + numList[k] == 2020) { Console.WriteLine($"{numList[i] * numList[j] * numList[k]}"); break; } } } } }
static void Main(string[] args) { Console.WriteLine(Helper(EXAMPLE_INPUT_1, false)); Console.WriteLine(Helper(EXAMPLE_INPUT_2, false)); Console.WriteLine(PROBLEM_INPUT.Split('\n', StringSplitOptions.RemoveEmptyEntries).Select(e => Helper(e, false)).Sum()); Console.WriteLine(Helper(EXAMPLE_INPUT_1, true)); Console.WriteLine(Helper(EXAMPLE_INPUT_2, true)); Console.WriteLine(PROBLEM_INPUT.Split('\n', StringSplitOptions.RemoveEmptyEntries).Select(e => Helper(e, true)).Sum()); Console.WriteLine("Hello World!"); }