public void Part1() { TicketValidationResult result = TicketValidator.ValidateNearby( TicketDataParser.Parse(StringListRetriever.Retreive("InputList15.txt").ToList())); Assert.Equal(29759, result.InvalidValues.Sum()); }
public void Part1Sample() { TicketData ticketData = TicketDataParser.Parse(GetPart1SampleData()); Assert.Equal(3, ticketData.ValidationRules.Count); Assert.Equal(5, ticketData.Tickets.Count); TicketValidationResult ticketValidationResult = TicketValidator.ValidateNearby(ticketData); Assert.Equal(71, ticketValidationResult.InvalidValues.Sum()); }
public void Part2() { TicketData ticketData = TicketDataParser.Parse(StringListRetriever.Retreive("InputList15.txt").ToList()); TicketValidationResult ticketValidationResult = TicketValidator.ValidateNearby(ticketData); FieldOrderResult fieldOrderResult = FieldOrderFinder.FindFieldOrderFor(ticketValidationResult.Tickets, ticketData.ValidationRules); Assert.Equal(1307550234719, fieldOrderResult.FieldOrder.Keys.Where(x => x.StartsWith("departure")) .Select(x => System.Convert.ToInt64(ticketData.Tickets[0].DataItems[fieldOrderResult.FieldOrder[x]])) .Aggregate <long, long>(1, (x, y) => x * y)); }
public void Part2Sample() { TicketData ticketData = TicketDataParser.Parse(GetPart2SampleData()); Assert.Equal(3, ticketData.ValidationRules.Count); Assert.Equal(4, ticketData.Tickets.Count); TicketValidationResult ticketValidationResult = TicketValidator.ValidateNearby(ticketData); Assert.Equal(3, ticketValidationResult.Tickets.Count); FieldOrderResult fieldOrderResult = FieldOrderFinder.FindFieldOrderFor(ticketValidationResult.Tickets, ticketData.ValidationRules); }