Problem 44850. X O X O
On a noughts and crosses board, how many possible unique combinations are there given a square grid of length n?
Assumptions/constraints:
- All squares are populated.
- Number of naughts and number of crosses can only differ by a maximum of 1. I.E. The game was played until the board was full
- Minimum Grid size (n) = 1x1
This is a discrete maths question, which can be simplified by focussing on one of the options. If we look at the options for locating just the crosses on the grid, we know that the remaining locations must contain naughts and so similarly for the opposite condition. The maths is relatively simple, and is the solution to "choose k from n".
19-Feb-19 - Test suite updated to take into account solutions where the opposing player goes first.
Solution Stats
Problem Comments
-
4 Comments
Rayner, by N do you include odds and even lengths ? what's the minimal length too? Cant imagine a game being fun with just one square )
By 'n' I mean any length of square grid. You solution should still be valid for a 1x1 grid. (I've now added an extra test script for this case). Though in reality I agree such a game wouldnt be much fun!
https://www.mathworks.com/matlabcentral/cody/problems/44851 adds the dynamic of stopping play when someone wins, though Ciaran's test suite needs fixing before you can attempt this one
Lovely little problem Rayner, look forward to trying Ciaran's
Problem needs more test cases
Solution Comments
Show commentsProblem Recent Solvers39
Suggested Problems
-
6830 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
605 Solvers
-
Flip the vector from right to left
8990 Solvers
-
Find the next Fibonacci number
565 Solvers
-
A Simple Tide Gauge with MATLAB
378 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!