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
Okay, ranting. Let's start with back-tracking to create sudoku grids. I do not take issue with back-tracking in general. It has it's uses. For example, to create mazes. It can also be a quick way to come up with valid solutions for further study. However, I do take issue with using back-tracking as the only way to create sudoku grids. It is a good starting point, but stopping at back-tracking does not suit me at all. Why? Because sudoku has rules and patterns, and that is what I am after. Insight and deeper understanding. For me, back-tracking is a starting point and not an end. And now permutations. Yes and no. But mostly no. When perming a sudoku grid, you can swap rows and columns on two levels. You can swap row/col of entire blocks. And you can swap row/col of cells within the same block. I'm going to assume that this is evident or easy enough to not show any explicit examples of this. However, let's take a look at some notes to show some of the reasons why I take issue with how some folks use row/col swaps. There are 3 blocks. Within each block, there are 3 cells. So, let's talk about shuffling 3 things. I couldn't tell you how many times I read people saying to do bunches and bunches of row/col swaps. But you are dealing with 3 things at a time and doing bunches-n-bunches of swaps is a waste of time. That is, more swaps of 3 things is not going to mix things up even more. Ugh! Simple perm of 3 things: [code] (0,1,2) (1,0,2) (2,0,1) (0,2,1) (1,2,0) (2,1,0) [/code] No matter how many times you do swaps, you are going to end up with one of those solutions. Cut to the chase and go straight to one of those solutions. It's a small set and no prob at all to hard-code. And one thing that people tend to leave out is the fact that the original starting point is a possibility in the final output. No matter how many times you do this-n-that, you can still end up right back where you started. More ugh! You have 3 things and you want to shuffle them. Rule #1: you can't have the orininal as a solution Rule #2: all values must be different [code] (0,1,2) original (1,2,0) valid (2,0,1) valid [/code] If those are your rules, then only two valid solutions. (Do those nums as a group look familiar? There is another avenue in there to be explored. Heh.) You have 3 things and you want to shuffle them. Rule #1: you can't have the original as a solution Rule #2: at least two must be different [code] ------- (1,0,2) (2,0,1) (0,2,1) (1,2,0) (2,1,0) [/code] And there they are. Same as the perms above sans original. Refine your chaos, people. Give it a hint of shape. Just a tad is all it takes. My data structure for sudoku grids is 4d. Doing those row/col swaps is ridiculously easy compared to doing the same to a 2d structure. What about re-mapping or perming the values? Trivial and cheeky. I see so many people getting caught-up in the symbols themselves. It's not the symbols that matter when it comes to the kind of math I enjoy doing the most. What matters are their properties as a group and/or their relationships. "Just change all of the values and you've got a whole new sudoku puzzle!" No. "Just do a bunch of rol/col swaps, flip it, mirror it, and you've got a whole new puzzle!" Again, no. Even with all of that, the relationships remain the same. So, why bother with row/col swaps and re-mapping values? Human perception, my friends. If you use the right kind of chaos in the right places, it will, at a glance, look like a very different puzzle. Even though all of the relationships will remain the same, how many humans will notice? I think this would make for an interesting social experiment. Let's back up a little bit to row/col swaps and talk about flipping, mirroring, and rotating. Flipping on either axis is the same as a specific set of row/col swaps. Hopefully evident without explicit examples. Yes? What about mirroring along a diagonal or rotating 90? Let's take a look. [code] 0 1 2 original 3 4 5 6 7 8 2 5 8 6 3 0 rot 90 cw/ccw 1 4 7 7 4 1 0 3 6 8 5 2 0 3 6 8 5 2 mirror either diagonal 1 4 7 7 4 1 2 5 8 6 3 0 [/code] If you look closely enough, you will see that each one of those operations is a permutation of the others. But none can be achieved using regular row/col swaps of the original. What does this mean? It means that just one of the four operations is all it takes to do something that regular row/col swaps can't do. One is all it takes. I say give it a 50/50 chance that you do one of those operations. The easiest to implement being (x,y)=(y,x). Which to do first? Rol/col swaps or (x,y)=(y,x)? It doesn't matter. Think about it for a minute. So, why didn't I include these kind of transforms in the code that I posted? No real need because of the DP transform that my code uses. And because I just plain didn't want to just yet. Just yet. Up next: The Shuffle Code That I Didn't Include
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