public Int64 SolvePart1(Int64[] ints, int preambleCount) { for (int index = preambleCount; index < ints.Length; index++) { var valueToTest = ints[index]; var arrayToTest = ints.Skip(index - preambleCount).Take(preambleCount).ToArray(); var result = FindNumbersWithSum.Find(arrayToTest, 2, valueToTest); if (result == 0) { return(valueToTest); } } Console.Error.WriteLine("All numbers conform to the rule."); return(-1); }
public Int64 SolvePart2() { // Get the three numbers that add up to 2020 return(FindNumbersWithSum.Find(values, 3, 2020)); }
public Int64 SolvePart1() { // Get the two numbers that add up to 2020 return(FindNumbersWithSum.Find(values, 2, 2020)); }