private int findResult(int result) { foreach (var bingoNumber in NumberOrder) { (int, int)spot = (0, 0); var board = new List <List <(string, int)> >(); for (var b = 0; b < BingoBoards.Count(); b++) { board = BingoBoards[b]; spot = FindNumber(board, bingoNumber); if (spot.Item1 < 6) { //Console.WriteLine(spot.Item1 + " " +spot.Item2); if (CheckForBingo(board, spot.Item1, spot.Item2)) { result = CountScore(board); //PrintBoards(); //PrintBoard(board); Console.WriteLine(result + " * " + bingoNumber); return(result * Int32.Parse(bingoNumber)); } } } } return(result); }
public List <string> ReadInput() { var puzzleInput = new List <string>(); var path = Path.Combine(Directory.GetCurrentDirectory(), InputFile); var result = new List <string>(); using (var reader = File.OpenText(path)) { var line = reader.ReadLine(); if (line is not null) { NumberOrder = line.Split(',').ToList(); } line = reader.ReadLine(); var bingoBoardLine = new List <string>(); while (line != null) { for (int i = 0; i < 5; i++) { var bingoLine = reader.ReadLine(); if (bingoLine is not null) { bingoBoardLine = System.Text.RegularExpressions.Regex.Split(bingoLine.Trim(), @"\s+").ToList(); } foreach (var number in bingoBoardLine) { BingoBoardRow.Add((number, 0)); } BingoBoard.Add(BingoBoardRow.ToList()); BingoBoardRow.Clear(); } BingoBoards.Add(BingoBoard.ToList()); BingoBoard.Clear(); line = reader.ReadLine(); } } return(puzzleInput); }