static Object PartB() { var input = ReadIndata.Ints(inputPath); input.Add(0); input.Add(input.Max() + 3); input.Sort(); long ans = 1; int i = 0; int z = input.Count; var combs = new int[] { 0, 1, 1, 2, 4, 7 }; while (i < z - 1) { int n = 1; while ((i + n < z) && (input[i + n] - input[i + n - 1] == 1)) { n++; } ans *= combs[n]; i += n; } Console.WriteLine("Part B: Result is {0}", ans); return(ans); }
static Object PartB() { var input = ReadIndata.Ints(inputPath); int ans = MemoryGame(input, 30000000); Console.WriteLine("Part B: Result is {0}", ans); return(ans); }
static Object PartA() { var input = ReadIndata.Ints(inputPath); int ans = 0; Console.WriteLine("Part A: Result is {0}", ans); return(ans); }
static Object PartA() { var input = ReadIndata.Ints(inputPath); input.Add(0); input.Add(input.Max() + 3); input.Sort(); var d = new int[] { 0, 0, 0, 0 }; for (int i = 1; i < input.Count; i++) { d[input[i] - input[i - 1]]++; } int ans = d[1] * d[3]; Console.WriteLine("Part A: Result is {0}", ans); return(ans); }
static Object PartA() { List <int> input = ReadIndata.Ints(inputPath); input.Sort(); int ans = 0; foreach (int a in input) { int b = 2020 - a; if (input.Contains(b)) { ans = a * b; break; } } Console.WriteLine("Part A: Result is {0}", ans); return(ans); }