In a normal 3 × 3 tic-tac-toe board, there are 8 winning lines.
How many winning lines are there in a 4 × 4 × 4 tic-tac-toe board? (In this case, a winning line consists of four boxes in a row, either on the surface or inside the cube.)
Bonus : How many winning lines are there in a n d tic-tac-toe hypercube, where n is the number of cells per side and d is the number of dimensions?
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.
Clever approach!
This is amazing, does this hold for any dimensions?
Log in to reply
Yes! You can verify this approach on the common 3 × 3 board:
2 5 2 − 3 2 = 8
@Arjen Vreugdenhil 's solution generalizes this approach to all dimensions.
Wow brilliant bijection here! I solved this by casework but this strategy is much better!
Beautiful! Can you prove (a link would do) the two assertions which make it work?
I know they seem obvious when you visualise it, but a proof would be nice!
Log in to reply
Check out Arjen's response down below. Two beautiful proofs.
It get's really interesting when n = 1 or 0, and even more interesting for n values less than zero. Further, the geometric shape of the elements is irrelevant if the element positions remain in a cubic arrangement; in other words it should work for a cubic arrangement of spheres, or even simply points. So a single point in space (n=1) has 13 diagonals?
Interesting, Zach. I did the very same calculation, ( 6 3 − 4 3 ) / 2 but without that interpretation.
The tic-tac-toe board is a 4 × 4 × 4 cube.
One must consider 3 different orientations: Up/Down, East/West, and North/South. First consider the winning lines which are composed of adjacent cubes:
For each orientation, there are 4 × 4 = 1 6 winning lines. Therefore, there are 1 6 × 3 = 4 8 winning lines of this type.
Now consider diagonals:
For each orientation, there are 2 × 4 = 8 winning lines. Therefore, there are 8 × 3 = 2 4 winning lines of this type.
Now consider diagonals from opposite vertices of the cube:
There are exactly 4 winning lines of this type.
In total, there are 4 8 + 2 4 + 4 = 7 6 winning lines.
This is related to a problem in combinatorics called the Moser's cube problem.
Remove some of the unit cubes so that none of the geometric lines (as shown in this solution) exist. What is the fewest removals needed to accomplish this?
The Online Encyclopedia of Integer Sequences entry expresses this as the number of unit cubes remaining for grids that are 3 × 3 , 3 × 3 × 3 , 3 × 3 × 3 × 3 , etc. There is no known formula and values past a 3 6 grid are unknown.
The question is slightly flawed in the way that it does not specify that the winning line length must change from the usual 3 to 4
I must be missing something since everyone is in agreement... I'm getting 124 combinations, because I'm using all non-visible cubes in the solution, just like the official solution uses for the vertice additions. Why aren't they all being counted in the official solutions?
Each "face" of 4x4 blocks has 10 winning lines, ie: 4 horizontal, 4 vertical and 2 diagonal combinations of "four boxes in a row".
Counting left to right, there are 4 groups of 4x4 blocks, ie: 40 solutions.
Counting front to back, there are 4 groups of 4x4 blocks, ie: 40 solutions.
Counting top to bottom, there are 4 groups of 4x4 blocks, ie: 40 solutions.
There are eight vertices, which give us 4 internally diagonal solutions.
Total of 124 unique combinations of "four boxes in a row"
Log in to reply
You're double-counting some lines. For example, a vertical line in the N/S orientation is the same as a vertical line in the E/W orientation.
Log in to reply
Yep, I was. in my mind, I was splitting the cube up into three groups of four faces and missing the fact I was double-counting lines. Thanks man!
More generally, on an n x ... x n = n^d hypercube, there are ((n+2)^d - n^d)/(2) winning lines. Thus we have ((4+2)^3 - 4^3)/(2) = 76 total winning lines on the 4 x 4 x 4 cube.
Agreed. The question was changed without my knowledge. The original question made this very clear. It specifically stated that the winning lines were exactly the n-in-a-lines. I really wish someone would have contacted me at the very least before changing the problem.
The problem is ill-defined. What constitutes a "tic-tac-toe board" of given dimensions?
If one assumes that the "board" is only the surface, and that a "square" does not also change dimensions to be a cube (both unspecified), then there are only 60 solutions.
Log in to reply
The original problem was not ill-defined. Much of the clarification of the original problem was removed. This is not my fault as I am not the one who changed it.
Log in to reply
I was not trying to lay blame. Just commenting that the problem as currently written is not clearly specified. For that reason, there are at least two possible solutions.
Could anyone please explain to me why there are 24 diagonals? I keep trying to count but get that there are 12 (2 per face) and that the above seems to double count. I take it that order is important here?
Log in to reply
Nvm, I've just seen what the answer means. The picture is very misleading.
I don't get it. If I break up the cube into 2 dimensional layers, I have 4 seperate boards. Each board has 10 possible winning lines (n*2). Putting it back into 3 dimensions, I have 10x4 + 10x4 (covering each possible orientation of each board) plus the 4 cross board diagonals. I keep on getting 84, no matter which way I think about it. What am I missing (apart from my morning coffee)?
Log in to reply
Sorry typo, that was supposed to be 2(n+1) not n*2
Never mind, I have figured it out. I was counting each side of the top and bottom layer twice, so subtract 8 and I get the same.
Alright. Tons of people are reporting this problem and complaining about it being poorly stated. This paper tells you everything you need to know about the problem:
http://library.msri.org/books/Book42/files/golomb.pdf
I must be missing something. I see all the logic that gets us to 76, but I find some addition lines. Consider the diagonal lines (I'll give co-ordinates to make it easier) (row, column, depth) 1,2,1: 2,2,2, 3,2,3, 4,2,4. There are a number of these per face. So I'm obviously missing something as to why these have either been already counted, or aren't valid lines of 4!
I would reword the question from saying "(In this case, a winning line consists of four boxes in a row.)" to "(In this case, a winning line consists of four cubes in a row.)". Technically speaking a box is only one side of an individual cube..Each cube has 6 sides and you could consider each visible face of an individual cube as a box. Also how do we think about the non-showing sides is not specified very well. Additionally, (probably over thinking) but you could wrap around the edges of a cube and have 4 boxes in a row.
All in all the question would have been easier to answer if the question was phrased in a more specific manner.
This is horribly explained.
For an n d cube, the solution is L ( n , d ) = 2 ( n + 2 ) d − n d . Here, L ( 4 , 3 ) = 2 6 3 − 4 3 = 2 2 1 6 − 6 4 = 7 6 .
Rationale
For each of the d dimensions, choose
either one of the n positions,
or one of the two directions to traverse that dimension (e.g. left to right or right to left).
This yields ( n + 2 ) d possible choices. If for all dimensions the first option was selected, we are dealing with a single box; this does not count, so we subtract out these n d possibilities.
Each of the remaining ( n + 2 ) d − n d possibilities describes a way to traverse the cube in some way. However, each row is now covered twice: left-to-right and right-to-left, top-to-bottom and bottom-to-top, and so on. Therefore we finally divide by two.
Alternatively ,
There are d choices for the "diagonality" of the row, i.e. the number of dimensions that varies: Δ = 1 for horizontal/vertical, Δ = 2 for plane diagonals, Δ = 3 for body diagonal.
For each diagonality Δ , there are ( Δ d ) ways to pick the varying dimensions.
For each of these choices, there are 2 Δ − 1 different directions for the row.
For each of these directions, there are n d − Δ rows (based on the dimensions that do not vary).
Thus,
L ( n , d ) = Δ = 1 ∑ d ( Δ d ) 2 Δ − 1 n d − Δ = 2 1 ( Δ = 0 ∑ d ( Δ d ) 2 Δ n d − Δ − ( 0 d ) 2 0 n d ) = 2 1 ( ( n + 2 ) d − n d ) .
This question is not well written. Need to explicitly state that internal diagonals are possible. A reasonable interpretation would be that only surface lines are valid
Log in to reply
But why? On a 3x3 board, you don't assume that only the four outside lines are possible, either.
To my way of thinking, the solutions discussed are counting the edges twice. There are 12 unique edges, though the answer appears to say there are 24. That is, 2 sides to each unique edge.
Log in to reply
In those terms, there are
12 edges
24 lines lying horizontally or vertically in the faces of the cube but not at the edge
12 horizontal and vertical lines that do not lie in a face of the cube
12 face diagonals
12 diagonals of planes that are not faces
4 body diagonals
The total is, once again, 7 6 .
Nicely done! Rather happy coincidence the answer is the same. I was missing the 12 diagonals of planes that are not faces.
Rephrase the question to say its a 4 x 4 x 4 cube.
How many winning lines are there in a 4 x 4 tic-tac-toe board? Is 10.
Log in to reply
Agreed. The question asks about the board not the cube.
You can't have a 4X4X4 board. A board is two dimensions. They also ignore the center cube pieces, as if the cube were transparent. I remember the Star Trek 3D chess game. That's how I approached this puzzle.
If you also consider layers the answer is 96
@Arjen Vreugdenhil , could you explain the first rationale more? I don't quite understand what is meant by "choose one of the n positions for each dimension", for example.
Log in to reply
In the case of a cube ( d = 3 ) ,
I choose either x = 1 , 2 , 3 , 4 ; or I choose to traverse the cube from left to right or from right to left.
I choose either y = 1 , 2 , 3 , 4 ; or I choose to traverse the cube from top to bottom or from bottom to top.
I choose either z = 1 , 2 , 3 , 4 ; or I choose to traverse the cube from front to back or back to front.
Formally, I choose x 0 = 1 , 2 , 3 , 4 and Δ x = 0 ; or x 0 = 0 , Δ x = 1 ; or x 0 = 5 , Δ x = − 1 ; and similar choices for y and z . Then the coordinates ( x 0 + k Δ x , y 0 + k Δ y , z 0 + k Δ z ) , k = 1 , 2 , 3 , 4 describe a winning line in the cube.
True for d values greater than 3? Hyper dimensionality? How about n values of 1 or less, including negative values.
Log in to reply
It certainly works for one-dimensional situations, i.e. a line of boxes. For d = 1 , we get 2 ( n + 2 ) 1 − n 1 = 2 n + 2 − n = 1 , and there is indeed one winning row.
For d = 0 , the "board" would consists of a single cube, and there would be no room for a line of boxes. Indeed, 2 ( n + 2 ) 0 − n 0 = 2 1 − 1 = 0 .
Situations with n < 1 or d < 0 seem rather meaningless to me.
Wow excellent approach. I was already doing by the alternate method (casewise) and got many terms. It looked like a binomial expansion but couldn't exactly generalize them further. I'm delighted that you worked it out!
Something else to consider: our 4 3 tic-tac-toe game is a first player win. What is the winning strategy?
That is interesting. I expected it to be a draw in optimal play.
That's a really interesting observation! Can you post it as a separate problem?
I didn't come up with the solution of considering an outer shell that others did. I considered the lines associated with the faces, edges and vertexes like Andy Hayes did. Namely that there are 6 faces each of which is associated with 16 ( n 2 ) winning lines, 12 edges each associated with 4 ( n 1 ) winning lines and 8 vertexes each associated with 1 ( n 0 ) winning lines. This double counts each winning line so add those up and divide them by 2 to get 76.
For the bonus question I found the solution:
f ( d , n ) = ∑ x = 0 d − 1 2 1 ( x d ) 2 d − x n x
This is similar to Arjen Vreugdenhil's alternative solution. The winning lines associated with vertexes are being counted when x=0, those associated with edges when x=1, faces when x=2. I find it interesting and hard to imagine how there can be winning lines associated with cubes when considering hypercubes (counted when x=3).
The ( x d ) part of the equation counts how many edges, faces, cubes or hypercubes (cubes of dimension x) are associated with each vertex of the total board, that is multiplied by 2 d − x since there are 2 d vertexes in a cube of dimension d but each cube of dimension x is counted 2 x times. n x is the number of winning lines associated with each cube of dimension x and the 2 1 is to account for double counting the winning lines.
Problem Loading...
Note Loading...
Set Loading...
Consider a 6 × 6 × 6 outer shell built around the given 4 × 4 × 4 cube. Each winning line of the 4 × 4 × 4 intersects exactly two 1 × 1 × 1 cubes in the outer shell. On the other hand, each such 1 × 1 × 1 cube located in the outer shell lies on a single winning line. The total number of the winning lines, therefore, is given by
2 6 3 − 4 3 = 7 6