public static void Main(string[] args) { const int edge = 5; const int numQueens = 5; var boardrange = Enumerable.Range(0, edge * edge); int maxSafes = 0; foreach (var queens in GetKCombs(boardrange, numQueens)) { var board = new QueenBoard(5, queens); var numSafes = board.CalculateSafes(); if (numSafes > maxSafes) { maxSafes = numSafes; Console.WriteLine($"Found a better board state with {numSafes} safe positions!"); board.CalculateSafes(true); } } }
public void Test5() { var board = new QueenBoard(5, new int[] { 0, 1, 2, 3, 4 }); Assert.Equal(0, board.CalculateSafes()); }
public void Test_0() { var board = new QueenBoard(5, new int[] { }); Assert.Equal(25, board.CalculateSafes()); }
public void Test_1_in_6() { var board = new QueenBoard(5, new int[] { 6 }); Assert.Equal(10, board.CalculateSafes()); }