Esempio n. 1
0
        public void ProblemTwo()
        {
            var       cards      = ParseInput(Input, out List <int> drawNumbers);
            BingoCard lastWinner = null;
            var       lastWinnerLastDrawnNumber = 0;

            for (int i = 0; i < drawNumbers.Count; i++)
            {
                var number = drawNumbers[i];

                List <BingoCard> winners = new List <BingoCard>();
                foreach (var card in cards)
                {
                    if (card.DrawNumber(number))
                    {
                        winners.Add(card);
                        //Asume only 1 end winner
                        lastWinner = card;
                        lastWinnerLastDrawnNumber = number;
                    }
                }
                winners.ForEach(i => cards.Remove(i));
            }

            //19000 too high
            var score = lastWinner.CalculateScore(lastWinnerLastDrawnNumber);

            Console.WriteLine(score);
        }