示例#1
0
    public dynamic Solve(string[] lines)
    {
        var numbers = lines[0].Split(',').Select(int.Parse);
        var cards   = new List <BingoCard>();

        for (uint row = 2; row < lines.Length; row++)
        {
            var cardRows = new int[5][];
            for (uint i = 0; i < 5; i++, row++)
            {
                cardRows[i] = lines[row].Split(" ", StringSplitOptions.RemoveEmptyEntries)
                              .Select(int.Parse).ToArray();
            }
            cards.Add(new BingoCard(cardRows));
        }

        var plays = from play in PlayBingo(cards, numbers)
                    where play.Winner is not null
                    select play.Winner.Score() * play.number;

        return(plays.First(), plays.Last());
    }