Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public Int64 SolvePart2()
 {
     // Get the three numbers that add up to 2020
     return(FindNumbersWithSum.Find(values, 3, 2020));
 }
Ejemplo n.º 3
0
 public Int64 SolvePart1()
 {
     // Get the two numbers that add up to 2020
     return(FindNumbersWithSum.Find(values, 2, 2020));
 }