public static int Problem1()
        {
            List <string>   data      = File.ReadAllLines("Data/Day16.txt").ToList();
            TicketValidator validator = new TicketValidator();

            validator.ParseData(data);
            int result = validator.ValidateAllNumbers();

            Console.WriteLine(result);
            return(result);
        }
        public static long Problem2()
        {
            List <string>   data      = File.ReadAllLines("Data/Day16.txt").ToList();
            TicketValidator validator = new TicketValidator();

            validator.ParseData(data);
            validator.DecodeColumns();

            List <Rule> departureRules = validator.Rules.Where(r => r.Name.StartsWith("departure")).ToList();

            long result = 1;

            foreach (Rule rule in departureRules)
            {
                result *= validator.MyTicket._values.ElementAt(rule.Column);
            }


            Console.WriteLine(result);
            return(result);
        }
Exemple #3
0
 public IEnumerable <int> GetInvalidValues(TicketValidator ticketValidator)
 {
     return(Values.Where(v => !ticketValidator.ValidValue(v)));
 }