OZONE Asylum
Forums
Server-Side Scripting - Oh my!
Creating Sudoku 3x3x3x3
This page's ID:
33324
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
So, I was trying to get some sleep, but my brain wouldn't shut-up. There is a neat little pattern trick with latin squares of size 3. I kept running the vectors through my head for a latin cube of size 3. Turns out that the pattern trick holds true even in 3d. This pattern trick solves a problem that I had a long time ago. And it solves a problem with previous sudoku cube. And this trick is wicked easy. The sudoku cube that this code produces is pretty much mathematically identical to the previous, but it is largely 'unshuffled', and it is *so* much easier to see the patterns. The 2d nugget looks like this: [code] ny=(cy+bx)%3 nx=(cx+by)%3 [/code] The magic little 3d nugget looks like this: [code] nz=(cz+by)%3 ny=(cy+bx)%3 nx=(cx+bz)%3 [/code] Just some shifting with modulo. As a matter of fact, that is how I made c0 in the following code. If you look at the planes of c0, it should be easy to see that all I did was shift to the right and down. Which is funny because c0 is actually a latin cube with bits... it's just presented differently. [code] #!/usr/bin/env python # -*- coding: utf-8 -*- from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax = fig.gca(projection='3d') ax.set_proj_type('ortho') c0=[[[0,1,2], [3,4,5], [6,7,8]], [[8,6,7], [2,0,1], [5,3,4]], [[4,5,3], [7,8,6], [1,2,0]]] # 3x3x3 mcube=[[[0,0,0],[0,0,0],[0,0,0]], [[0,0,0],[0,0,0],[0,0,0]], [[0,0,0],[0,0,0],[0,0,0]]] # build each sub-cube and toss it in for bz in range(3): for by in range(3): for bx in range(3): # 3x3x3 tcube=[[[0,0,0],[0,0,0],[0,0,0]], [[0,0,0],[0,0,0],[0,0,0]], [[0,0,0],[0,0,0],[0,0,0]]] for cz in range(3): for cy in range(3): for cx in range(3): nz=(cz+by)%3 ny=(cy+bx)%3 nx=(cx+bz)%3 tcube[cz][cy][cx]=c0[nz][ny][nx] mcube[bz][by][bx]=tcube #ax.text(0,0,0, '0') nscale=3 buff=1 for bz in range(3): for by in range(3): for bx in range(3): for cz in range(3): for cy in range(3): for cx in range(3): nv=mcube[bz][by][bx][cz][cy][cx] #if nv==0: #nz=(bz*3+cz+buff*bz)*nscale #ny=(by*3+cy+buff*by)*nscale #nx=(bx*3+cx+buff*bx)*nscale #ax.text(nx,ny,nz, nv) if bz==0 and cz==0: nv=mcube[bz][by][bx][cz][cy][cx] nz=(bz*3+cz+buff*bz)*nscale ny=(by*3+cy+buff*by)*nscale nx=(bx*3+cx+buff*bx)*nscale ax.text(nx,ny,nz, nv) vmax=(2*3+2+buff*2)*nscale+1 ax.set_xlim(-1, vmax) ax.set_ylim(-1, vmax) ax.set_zlim(-1, vmax) ax.set_xlabel('X axis') ax.set_ylabel('Y axis') ax.set_zlabel('Z axis') plt.show() [/code]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail