using AdventOfCode.Contracts; using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace AoC.TwentyTwenty { class Five : Day { public override int Year => 2020; public override int DayNumber => 5; public override void BigBoi(string[] input) { int grandTotal = 0; HashSet seats = new HashSet(); foreach (string s in input) { int upper = 127; int lower = 0; int left = 0; int right = 7; int row = 64; int col = 4; foreach (char c in s) { _ = c switch { 'F' => upper -= row, 'B' => lower += row, 'L' => right -= col, 'R' => left += col, _ => throw new Exception("AAAAAAAAAAA") }; if (c == 'F' || c == 'B') { row /= 2; } else { col /= 2; } } int total = (upper * 8) + left; if (total > grandTotal) { grandTotal = total; } seats.Add(total); } Print("BigBoi 1", grandTotal); for (int i = 0; i < int.MaxValue; i++) { if (!seats.Contains(i) && seats.Contains(i + 1) && seats.Contains(i - 1)) { Print("BigBoi 2", i); break; } } } public override void Part1(string[] input) { int grandTotal = 0; foreach (string s in input) { int upper = 127; int lower = 0; int left = 0; int right = 7; int row = 64; int col = 4; foreach (char c in s) { _ = c switch { 'F' => upper -= row, 'B' => lower += row, 'L' => right -= col, 'R' => left += col, _ => throw new Exception("AAAAAAAAAAA") }; if (c == 'F' || c == 'B') { row /= 2; } else { col /= 2; } } int total = (upper * 8) + left; if (total > grandTotal) { grandTotal = total; } } Print("1", grandTotal); } public override void Part2(string[] input) { HashSet seats = new HashSet(); foreach (string s in input) { int upper = 127; int lower = 0; int left = 0; int right = 7; int row = 64; int col = 4; foreach (char c in s) { _ = c switch { 'F' => upper -= row, 'B' => lower += row, 'L' => right -= col, 'R' => left += col, _ => throw new Exception("AAAAAAAAAAA") }; if (c == 'F' || c == 'B') { row /= 2; } else { col /= 2; } } seats.Add((upper * 8) + left); } for (int i = 0; i < 1028; i++) { if (!seats.Contains(i) && seats.Contains(i + 1) && seats.Contains(i - 1)) { Print("2", i); break; } } } } }