Esempio n. 1
0
 public override object SolveOne()
 {
     return(IntRows
            .Where(x => IntRows.Contains(2020 - x))
            .Select(x => x * (2020 - x))
            .First());
 }
Esempio n. 2
0
 long CountPaths(int current)
 {
     if (current == Max)
     {
         return(1);
     }
     return(IntRows.Where(x => x > current && x <= current + 3).Sum(x =>
     {
         if (!Memo.ContainsKey(x))
         {
             Memo[x] = CountPaths(x);
         }
         return Memo[x];
     }));
 }
Esempio n. 3
0
        public override object SolveOne()
        {
            int[] hops    = new int[] { 0, 0, 0 };
            int   joltage = 0;

            while (true)
            {
                if (joltage == Max)
                {
                    return(hops[0] * (hops[2] + 1));
                }
                int next = IntRows.Where(x => x > joltage).Min();
                hops[next - joltage - 1]++;
                joltage = next;
            }
        }
Esempio n. 4
0
 public override object SolveTwo()
 {
     return(IntRows
            .Where(x => IntRows.Exists(y => IntRows.Contains(2020 - x - y)))
            .Aggregate(1, (x, y) => x * y));
 }
Esempio n. 5
0
 public Day10()
 {
     Max = IntRows.Max();
 }