public static TicketInfo Parse(string line)
        {
            if (!regex.IsMatch(line))
            {
                return(null);
            }

            var groups = regex.Match(line).Groups;

            var ticketInfo = new TicketInfo
            {
                Label  = groups[1].Value,
                Ranges = new List <NumberRange>()
            };

            ticketInfo.Ranges.Add(new NumberRange(int.Parse(groups[2].Value), int.Parse(groups[3].Value)));
            ticketInfo.Ranges.Add(new NumberRange(int.Parse(groups[4].Value), int.Parse(groups[5].Value)));

            return(ticketInfo);
        }
        public static TicketSheet Parse(List <string> lines)
        {
            var sheet = new TicketSheet();

            var parsingTickets = false;

            for (int i = 0; i < lines.Count; i++)
            {
                if (i > 0 && lines[i - 1].Contains("your ticket:"))
                {
                    sheet.SantasTicket = GetTicketNumbers(lines[i]);
                    continue;
                }

                if (i > 0 && lines[i - 1].Contains("nearby tickets:") || parsingTickets)
                {
                    sheet.Tickets.Add(GetTicketNumbers(lines[i]));

                    if (!parsingTickets)
                    {
                        parsingTickets = true;
                    }

                    continue;
                }

                var info = TicketInfo.Parse(lines[i]);

                if (info != null)
                {
                    sheet.TicketInfos.Add(info);
                }
            }

            return(sheet);
        }