Tic-Tac-Toe to the Nth Dimension

In a normal 3 × 3 3 \times 3 tic-tac-toe board, there are 8 winning lines.

How many winning lines are there in a 4 × 4 × 4 4\times 4\times 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 n^d tic-tac-toe hypercube, where n n is the number of cells per side and d d is the number of dimensions?


The answer is 76.

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.

5 solutions

Zach Abueg
Aug 13, 2017

Consider a 6 × 6 × 6 6 \times 6 \times 6 outer shell built around the given 4 × 4 × 4 4 \times 4 \times 4 cube. Each winning line of the 4 × 4 × 4 4 \times 4 \times 4 intersects exactly two 1 × 1 × 1 1 \times 1 \times 1 cubes in the outer shell. On the other hand, each such 1 × 1 × 1 1 \times 1 \times 1 cube located in the outer shell lies on a single winning line. The total number of the winning lines, therefore, is given by

6 3 4 3 2 = 76 \frac{6^3 - 4^3}{2} = \boxed{76}

Clever approach!

Uros Stojkovic - 3 years, 10 months ago

Log in to reply

Thank you, Uros :)

Zach Abueg - 3 years, 10 months ago

This is amazing, does this hold for any dimensions?

Agnishom Chattopadhyay - 3 years, 9 months ago

Log in to reply

Yes! You can verify this approach on the common 3 × 3 3 \times 3 board:

5 2 3 2 2 = 8 \frac{5^2 - 3^2}{2} = 8

@Arjen Vreugdenhil 's solution generalizes this approach to all dimensions.

Zach Abueg - 3 years, 9 months ago

Wow brilliant bijection here! I solved this by casework but this strategy is much better!

Alexander Koran - 3 years, 9 months ago

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!

Peter Macgregor - 3 years, 10 months ago

Log in to reply

Check out Arjen's response down below. Two beautiful proofs.

Kelly Brower - 3 years, 9 months ago

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?

Donald Zacherl - 3 years, 9 months ago

Interesting, Zach. I did the very same calculation, ( 6 3 4 3 ) / 2 (6^3-4^3)/2 but without that interpretation.

Peter Byers - 3 years, 9 months ago
Andy Hayes
Aug 8, 2017

The tic-tac-toe board is a 4 × 4 × 4 4\times 4\times 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 = 16 4\times 4=16 winning lines. Therefore, there are 16 × 3 = 48 16\times 3=48 winning lines of this type.

Now consider diagonals:

For each orientation, there are 2 × 4 = 8 2 \times 4=8 winning lines. Therefore, there are 8 × 3 = 24 8\times 3=24 winning lines of this type.

Now consider diagonals from opposite vertices of the cube:

There are exactly 4 4 winning lines of this type.

In total, there are 48 + 24 + 4 = 76 48+24+4=\boxed{76} winning lines.

Moderator note:

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 \times 3, 3 × 3 × 3 , 3 \times 3 \times 3, 3 × 3 × 3 × 3 , 3 \times 3 \times 3 \times 3, etc. There is no known formula and values past a 3 6 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

Mikey Fleming - 3 years, 10 months ago

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"

P M - 3 years, 9 months ago

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.

Andy Hayes - 3 years, 9 months ago

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!

P M - 3 years, 9 months ago

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.

Frank Aiello - 3 years, 10 months ago

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.

Frank Aiello - 3 years, 10 months ago

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.

L E - 3 years, 10 months ago

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.

Frank Aiello - 3 years, 10 months ago

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.

L E - 3 years, 10 months ago

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?

Llethraim . - 3 years, 10 months ago

Log in to reply

Nvm, I've just seen what the answer means. The picture is very misleading.

Llethraim . - 3 years, 10 months ago

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)?

Lindon Morris - 3 years, 10 months ago

Log in to reply

Sorry typo, that was supposed to be 2(n+1) not n*2

Lindon Morris - 3 years, 10 months ago

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.

Lindon Morris - 3 years, 9 months ago

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

Frank Aiello - 3 years, 9 months ago

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!

A Former Brilliant Member - 3 years, 9 months ago

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.

Michael Janes - 3 years, 9 months ago

This is horribly explained.

Kris Cui - 3 years, 9 months ago
Arjen Vreugdenhil
Aug 13, 2017

For an n d n^d cube, the solution is L ( n , d ) = ( n + 2 ) d n d 2 . L(n,d) = \frac{(n+2)^d - n^d}2. Here, L ( 4 , 3 ) = 6 3 4 3 2 = 216 64 2 = 76 . L(4,3) = \frac{6^3 - 4^3}2 = \frac{216 - 64}2 = \boxed{76}.


Rationale

For each of the d d dimensions, choose

  • either one of the n 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 (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 n^d possibilities.

Each of the remaining ( n + 2 ) d n d (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 d choices for the "diagonality" of the row, i.e. the number of dimensions that varies: Δ = 1 \Delta = 1 for horizontal/vertical, Δ = 2 \Delta = 2 for plane diagonals, Δ = 3 \Delta = 3 for body diagonal.

  • For each diagonality Δ \Delta , there are ( d Δ ) \binom d \Delta ways to pick the varying dimensions.

  • For each of these choices, there are 2 Δ 1 2^{\Delta-1} different directions for the row.

  • For each of these directions, there are n d Δ n^{d - \Delta} rows (based on the dimensions that do not vary).

Thus,

L ( n , d ) = Δ = 1 d ( d Δ ) 2 Δ 1 n d Δ = 1 2 ( Δ = 0 d ( d Δ ) 2 Δ n d Δ ( d 0 ) 2 0 n d ) = 1 2 ( ( n + 2 ) d n d ) . L(n,d) = \sum_{\Delta = 1}^d \binom d \Delta 2^{\Delta - 1} n^{d - \Delta} \\ = \frac12\left(\sum_{\Delta = 0}^d \binom d \Delta 2^\Delta n^{d - \Delta} - \binom d 0 2^0 n^d \right) \\ = \frac12((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

Geoff G - 3 years, 9 months ago

Log in to reply

But why? On a 3x3 board, you don't assume that only the four outside lines are possible, either.

Arjen Vreugdenhil - 3 years, 9 months ago

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.

Cary Walker - 3 years, 10 months ago

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, 76 \boxed{76} .

Arjen Vreugdenhil - 3 years, 10 months ago

Log in to reply

See above.

Cary Walker - 3 years, 10 months ago

Nicely done! Rather happy coincidence the answer is the same. I was missing the 12 diagonals of planes that are not faces.

Cary Walker - 3 years, 10 months ago

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.

Kevin Bishop - 3 years, 10 months ago

Log in to reply

Agreed. The question asks about the board not the cube.

Angelica Bega - 3 years, 10 months ago

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.

A Former Brilliant Member - 3 years, 10 months ago

If you also consider layers the answer is 96

Bora Kzlrmk - 3 years, 9 months ago

@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.

Harry D - 3 years, 9 months ago

Log in to reply

In the case of a cube ( d = 3 ) (d = 3) ,

  • I choose either x = 1 , 2 , 3 , 4 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 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 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 x_0 = 1,2,3,4 and Δ x = 0 \Delta x = 0 ; or x 0 = 0 , Δ x = 1 x _ 0 = 0, \Delta x = 1 ; or x 0 = 5 , Δ x = 1 x_0 = 5, \Delta x = -1 ; and similar choices for y y and z z . Then the coordinates ( x 0 + k Δ x , y 0 + k Δ y , z 0 + k Δ z ) , k = 1 , 2 , 3 , 4 (x_0 + k\Delta x,\ y_0 + k\Delta y,\ z_0 + k\Delta z),\ \ \ \ \ \ k = 1, 2, 3, 4 describe a winning line in the cube.

Arjen Vreugdenhil - 3 years, 9 months ago

True for d values greater than 3? Hyper dimensionality? How about n values of 1 or less, including negative values.

Donald Zacherl - 3 years, 9 months ago

Log in to reply

It certainly works for one-dimensional situations, i.e. a line of boxes. For d = 1 d = 1 , we get ( n + 2 ) 1 n 1 2 = n + 2 n 2 = 1 , \frac{(n+2)^1 - n^1}2 = \frac{n+2-n}2 = 1, and there is indeed one winning row.

For d = 0 d = 0 , the "board" would consists of a single cube, and there would be no room for a line of boxes. Indeed, ( n + 2 ) 0 n 0 2 = 1 1 2 = 0. \frac{(n+2)^0 - n^0}2 = \frac{1 - 1}2 = 0.

Situations with n < 1 n < 1 or d < 0 d < 0 seem rather meaningless to me.

Arjen Vreugdenhil - 3 years, 9 months ago

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!

Ashutosh Kapre - 3 years, 8 months ago
Frank Aiello
Aug 16, 2017

Something else to consider: our 4 3 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.

Agnishom Chattopadhyay - 3 years, 9 months ago

That's a really interesting observation! Can you post it as a separate problem?

Calvin Lin Staff - 3 years, 9 months ago
Anon Ymous
Aug 18, 2017

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 n^2 ) winning lines, 12 edges each associated with 4 ( n 1 n^1 ) winning lines and 8 vertexes each associated with 1 ( n 0 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 1 2 ( d x ) 2 d x n x {\Large f({d,n}) = \sum_{x=0}^{d-1} \frac{1}{2} \binom{d}{x} 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 ( d x ) \Large \binom{d}{x} 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 \Large 2^{d-x} since there are 2 d \Large 2^d vertexes in a cube of dimension d but each cube of dimension x is counted 2 x \Large 2^x times. n x \Large n^x is the number of winning lines associated with each cube of dimension x and the 1 2 \Large \frac{1}{2} is to account for double counting the winning lines.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...