Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2006-02-28 11:23:38

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Sudoku

How about something on sudoku for the website?

I'd be willing to write up a basic introduction to group theory and how it relates to sudoku, as well as a sudoku java app game.

What do you think?


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#2 2006-02-28 11:42:36

Patrick
Real Member
Registered: 2006-02-24
Posts: 1,005

Re: Sudoku

I'd say: Go for it.. I'm pretty sure that they're willing to host it, if it's correct smile


Support MathsIsFun.com by clicking on the banners.
What music do I listen to? Clicky click

Offline

#3 2006-02-28 19:15:46

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Sudoku

I've wrote somewhere some kinda stuff.It will be cool.
I'm curious mofe for the sudoku-graph theory than the suboku.
How will this java app solve the sudoku?


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#4 2006-02-28 19:35:44

justlookingforthemoment
Moderator
Registered: 2005-05-26
Posts: 2,161

Re: Sudoku

Maybe something similar to this? But we could keep track of who solves each one first, and have a hall of fame... big_smile

Offline

#5 2006-02-28 19:53:42

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Sudoku

But there's no theory!!!


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#6 2006-02-28 20:58:36

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Let me think ...

Its Mathematical ...
Its Fun ...

... YES!


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#7 2006-03-01 17:41:25

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Sudoku

How will you make it?
Please inform us for the progress.


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#8 2006-03-01 18:07:36

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Sudoku

I have spring break coming up, an entire week off from school with absolutely no plans.  So I'll be working on it then.


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#9 2006-03-01 19:32:01

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Excellent - if you want to, we can work on it together somehow. (Maybe krassi or others want to help, too.)

I can help by putting a "front-end" on to the game. If you can get something working in java, I could then try to "translate" it to javascript and get it working in flash (flash uses a version of javascript called actionscript). (It would help if you don't get too tricky in java!).

But these are only suggestions - it is your idea and you da boss.

(My experience on collaboration is this: each person has their own project, and people get together occassionally to define  "interfaces")


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#10 2006-03-01 20:02:33

jU
Real Member
Registered: 2005-08-17
Posts: 1,923

Re: Sudoku

tell me when it comes cause I'll give it ago

Offline

#11 2006-03-01 20:08:10

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Oooh Oooh ... http://sudoku.sourceforge.net/


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#12 2006-03-01 20:57:37

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Ouch ... that one was hard to follow.

I was hoping to find some free source code to "kickstart" this project, and I have found a whole foum discussing the subject of programming Sudoku here: http://www.setbb.com/phpbb/viewforum.php?f=9&mforum=sudoku

And a wikpedia article of links (free source section near bottom): http://en.wikipedia.org/wiki/Talk:Sudoku/links_to_consider

And I found one in javascript here: http://sudoku.pjoneil.net/ (but the author doesn't want his source code altered)

(BTW: I have never done a Sudoku, is that strange?)


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#13 2006-03-02 03:46:12

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Sudoku

If you are going to rewrite it in Flash, I can just work on more of a psuedo-algorithm.  I'm guessing you can do the whole interface, it's just the solving algorithm that you need help with?

I have quite a few ideas for that, so I'll be working on that as well.

Here's basically what I was thinking:

Keep an array of numbers for every block in the board, which will hold a list of possible numbers.

If the array size is 1, then put that number in the board.

Then have a checkCol, checkRow, checkArea, which all check for certain patters such as two different boxes only having a 4 and 6, thus, those are the only places 4 and 6 can go, and then eliminating them from all other places.

That will at least narrow down the possibilities, if not solve the puzzle.  Then use a brute force branching algorithm to guess at every possible solution and arrive at contradictions or final solutions.


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#14 2006-03-02 04:15:16

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Sudoku

MathsIsFun wrote:

(BTW: I have never done a Sudoku, is that strange?)

If by 'strange' you mean 'rare', then probably. Pretty much everyone I know has tried/done/been addicted to sudoku. But if you mean 'odd' then not at all. You probably just have better things to do with your time.

I can do most sudokus fairly easily, but I tend not to because after a while they just get boring. I prefer the other one, that's similar but involves maths too. I can't remember what it's called.

Also, didn't Zach say that he wrote a sudoku code?


Why did the vector cross the road?
It wanted to be normal.

Offline

#15 2006-03-02 07:52:59

ryos
Member
Registered: 2005-08-04
Posts: 394

Re: Sudoku

I still don't know what a sudoku is.

Edit to say something valuable: Mathsy, are you talking about "magic squares"? The ones where you have to make all the rows, columns, and diagonals add up to a certain number? We did some of those in elementary school...

Last edited by ryos (2006-03-02 07:54:21)


El que pega primero pega dos veces.

Offline

#16 2006-03-02 08:13:47

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Sudoku

No, not magic squares. Hang on...

After much research (well, 2 minutes on google), the puzzle that I like is 'Kakuro'. There we go.


Why did the vector cross the road?
It wanted to be normal.

Offline

#17 2006-03-02 09:02:46

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Sudoku

ryos, you'll know soon enough wink

MathIsFun, how similar is actionscript to java script?  I know basic java script and I plan on learning Flash soon (I got a book, just haven't opened it yet, that's the next step).  If it's pretty much the same, I can write psuedo code that should be easy to put in java script, and thus (hopefully) easy to put in action script.


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#18 2006-03-02 18:07:09

justlookingforthemoment
Moderator
Registered: 2005-05-26
Posts: 2,161

Re: Sudoku

Let's have a samurai sudoku. It's the same, except it looks like this:

307.c.gif

It takes ages. smile

Offline

#19 2006-03-03 19:49:42

jU
Real Member
Registered: 2005-08-17
Posts: 1,923

Re: Sudoku

well dur

Offline

#20 2006-03-03 23:29:20

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Ricky wrote:

How similar is actionscript to java script?  I know basic java script and I plan on learning Flash soon (I got a book, just haven't opened it yet, that's the next step).  If it's pretty much the same, I can write psuedo code that should be easy to put in java script, and thus (hopefully) easy to put in action script.

Pretty similar. Both based on the same spec. See http://en.wikipedia.org/wiki/Actionscript and you will know more than I smile

I use a product called SwishMax (from SwishZone), as I find it easier to use than original Flash. I am by no means an expert on either.

Anyhoo, the good news is that I have a basic user-interface working now, and you can look at it here.

It isn't pretty, suggestions welcome!

On my side I can have these functions working:
                SetNum(row, col, num);   // sets the square at (row,col) to "num"
                IsFixedNum(row, col);     // sets the square at (row,col) to being a fixed "clue" cell

On your side something like:
                CreateSudoku(...);         // when the user presses a "New Game" button
                CheckSudoku(...);         // has the user solved it

Or something like that, we will know better as we get going!

Here is some sample code for you. This is what happens when you press the "fill badly" button:

on (press) {
    for (row=0; row<BoardSize; row++) {
        for (col=0; col<BoardSize; col++) {
            obj = eval("B_"+row+"_"+col);
            if (Math.random()>0.7) {
                obj.SetNum(col+1,false);
                obj.IsFixedNum(true);
            } else {
                obj.SetNum(" ",false);
                obj.IsFixedNum(false);
            }
        }
    }
}

That strange code "obj = eval("B_"+row+"_"+col);" is because the squares are called "B_0_0", "B_0_1" etc
And I use a random number to decide if it will be a fixed cell or not. And the number in the square is just the column number +1.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#21 2006-03-09 08:49:02

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Any comments Ricky?


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#22 2006-03-09 11:36:54

Ricky
Moderator
Registered: 2005-12-04
Posts: 3,791

Re: Sudoku

For the explanation part would you like me to write it in hmtl or just plain text?

For the programming, I was planning on representing the board by a 2d matrix of arrays.  Would that be a problem for you?

Last edited by Ricky (2006-03-09 11:37:05)


"In the real world, this would be a problem.  But in mathematics, we can just define a place where this problem doesn't exist.  So we'll go ahead and do that now..."

Offline

#23 2006-03-09 12:50:43

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Well, I would cut-and-paste it into the general site template, then re-format it as necessary to make it look the best. So you can include html if you want, but general text is fine.

Let me know ho you want your "attribution".

The array type in actionscript is A[i], but you can have arrays of arrays like A[i][j] etc.

It may be easier for me to have something like Board[row][col] (representing the numbers), and if you want to represent other properties (like cell-type) you could have another 2d array like CellType[row][col].

Alternatively you could have Board[row][col][prop] where prop is the property number (say 0=current value, 1=cell type, etc)

I could have two functions Array2Screen() and Screen2Array() to make it easy to communicate between my user interface and your engine.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#24 2006-03-29 02:33:39

Ninja 101
Member
Registered: 2006-02-20
Posts: 936

Re: Sudoku

i still haven't worked out how to do thon samurai sudoku puzzles.
mainly because i never try.
i look at one, shout 'gosh' then go to sleep. faint

Last edited by Ninja 101 (2006-03-29 02:34:15)


Chaos is found in greatest abundance wherever order is being saught. It always defeats order, because it is better organized.

Offline

#25 2006-03-29 08:40:55

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Sudoku

Ninja 101 wrote:

i look at one, shout 'gosh' then go to sleep.

LOL! That would be funny to see.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

Board footer

Powered by FluxBB