Example #1
0
    private int CalculateScore(ParsedBoard board, int number)
    {
        var unmarkedPositions = new List <int>();

        for (var i = 0; i < board.Board.GetLength(0); i++)
        {
            for (var j = 0; j < board.Board.GetLength(1); j++)
            {
                if (!board.Marks[i, j])
                {
                    unmarkedPositions.Add(board.Board[i, j]);
                }
            }
        }

        return(unmarkedPositions.Sum() * number);
    }
Example #2
0
    private static bool HasWon(ParsedBoard parsedBoard)
    {
        for (var i = 0; i < 5; i++)
        {
            var column = Day03.GetColumn(parsedBoard.Marks, i);
            if (column.All(b => b))
            {
                return(true);
            }
        }

        for (var i = 0; i < 5; i++)
        {
            var row = Day03.GetRow(parsedBoard.Marks, i);
            if (row.All(b => b))
            {
                return(true);
            }
        }

        return(false);
    }