All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Extending tic-tac-toe (Posted on 2014-10-23) Difficulty: 3 of 5
In a standard 3x3 tic-ta-toe there are 8 distinct possibilities to create “three in a row”- 3 horizontal, 3 vertical and 2 diagonal.

How many ways are there in a three-dimensional 5x5x5 tic-tac-toe?

How about 6x6x6 ?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solutions | Comment 5 of 6 |
For different sizes n x n x n:

n ways
3 49
4 224
5 603
6 1264
7 2285
8 3744
9 5719

note the 3 x 3 x 3 case matches the formula from my first comment, where I thought the number in a row matched n.

from:

DefDbl A-Z
Dim crlf$

Private Sub Form_Load()
 ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 For n = 3 To 9
    ct = 0
    For layer = 1 To n
    For x = 1 To n
    For y = 1 To n
      For vdiff = 0 To 2 Step 2
        For xdiff = -2 To 2 Step 2
          For ydiff = -2 To 2 Step 2
            If vdiff <> 0 Or xdiff <> 0 Or ydiff <> 0 Then
             If x + xdiff > 0 And x + xdiff <= n Then
             If y + ydiff > 0 And y + ydiff <= n Then
             If layer + vdiff > 0 And layer + vdiff <= n Then
              good = 1 ' Now prevent double counting (two directions):
              If vdiff = 0 And xdiff < 0 Then good = 0
              If vdiff = 0 And xdiff = 0 And ydiff < 0 Then good = 0
              If good Then
               ct = ct + 1
              End If
             End If
             End If
             End If
            End If
          Next ydiff
        Next xdiff
      Next vdiff
    Next y
    Next x
    Next layer
    Text1.Text = Text1.Text & n & Str(ct) & crlf
 Next n
 
 Text1.Text = Text1.Text & crlf & "done"
End Sub

  Posted by Charlie on 2014-10-23 10:21:55
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information