Problem 44658. Kurosu solver
This problem is related to Problem 44657.
The game of Kurosu is simple. A square grid contains cells that can be filled with either a 'X' or an 'O', similarly to a tic-tac-toe board. Game rules are as follows:
1. The game is played on a 6x6 board.
2. Each row and each column must contain exactly 3 'X's and 3 'O's.
3. Only 2 'X's or 'O's can be placed consecutively, either in a row or in a column.
4. Diagonals are of no importance.
In this problem, given a partially filled Kurosu board, b0, return b1, an array of the same size, representing the solved board, or an empty array if there is no valid solution. 'X's and 'O's are represented by 1s and 0s, respectively. An empty cell is represented by -1.
Example:
b0 = [-1 -1 -1 0 -1 -1 -1 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1];
b1 = [ 1 1 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 0];
Solution Stats
Problem Comments
-
6 Comments
Either your problem statement is incomplete, or your test suite is ill-formed.
For some of the problems, the solution is not unique, but your test suite fails for solutions other than your own. If there is some further requirement that would make your solutions unique, it should be stated.
For the last test, the input is a valid solved Kurosu board, but you expect us to say that there is no solution to that board. If this was intended (i.e. you meant the "partially filled" statement to be a requirement on the input), then it should have been specified.
The last test board has three consecutive zeros in a column, so it is invalid, and the others do appear to have a unique solution.
Thank you for the comments. I've updated the test suite to check for non-unique solutions, just in case.
It looks like I missed restriction 3 in the description. I retract my comments. Great problem!
Good problem !
Extraterrestrial solution from Tim. This code must be taught in school.
Great solution indeed, thanks for the comment Jean-Marie. That's why I felt compelled to rescore and eliminate your backdoor solution. Sorry, but nice catch.
Solution Comments
Show commentsProblem Recent Solvers9
Suggested Problems
-
13284 Solvers
-
573 Solvers
-
791 Solvers
-
84 Solvers
-
45 Solvers
More from this Author45
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!