You are given the following information about the number of possible tic-tac-toe games:
How many distinct tic-tac-toe games are there?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Rather than O and X imagine someone completing the grid by adding consecutive numbers 1, 2, 3 ... 9. There are 9! different ways to do this. When treated as a game, the process will stop (and the grid potentially remain incomplete) if there are ever 3 odd numbers or 3 even numbers in a row.
We can analyse the 9! possibilities as follows: Some will end in a draw (D). Some will end with a full grid on the ninth move ( M 9 ). Some will end on the eighth move, but there is only one empty spot for number 9, so there are M 8 such possibilities. Some will end on the seventh move, in which case there are two possible ways to complete the grid with the final 8 and 9. Hence this represents 2 M 7 of the 9! possibilities. Similarly any game which ends on the sixth move would leave 3! ways to complete the grid with 7, 8 and 9 (hence 6 M 6 ). Finally any game ending on the fifth move corresponds to 4! different 'completed' grids (hence 2 4 M 5 ). There are no games which will end in four or less moves.
So 9! = D + M 9 + M 8 + 2 M 7 + 6 M 6 + 2 4 M 5
The total number of games = M 5 + M 6 + M 7 + M 8 + M 9 + D = 9 ! − M 7 − 5 M 6 − 2 3 M 5
9! Is wrong as many games end before the 9th move. Some games require only 5 moves, only one response has an answer that includes 5 move game, so I picked that.
This page gives all the details, with the exact values of M 5 , M 6 , M 7 , M 8 and M 9 , if you want to know them!
Problem Loading...
Note Loading...
Set Loading...
Note that two tic-tac-toe games are considered distinct even if they arrive at the same final board, provided the moves are played in different orders. If you allowed both players to keep playing after someone gets 3 in a row, there'd be 9 ! games (9 places for the first X, 8 places for the first O, 7 places for the second X, etc.).
For each N < 9 , we need to add in M N incomplete boards to our total, and subtract ( 9 − N ) ! × M N completed boards that, in fact, are not valid games (since someone already won). You can think of this as, for each of the M N games, there are 9 − N spots left on the board; there are ( 9 − N ) ! ways to fill those spots.
Number of games = 9 ! + M 5 − 4 ! M 5 + M 6 − 3 ! M 6 + M 7 − 2 ! M 7 + M 8 − 1 ! M 8 = 9 ! + M 5 − 2 4 M 5 + M 6 − 6 M 6 + M 7 − 2 M 6 + M 8 − M 8 = 9 ! − 2 3 M 5 − 5 M 6 − M 7