Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

A problem about 3*3 puzzle

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku
View previous topic :: View next topic  
Author Message
shaill

Joined: 15 Nov 2005
Posts: 1
:

Items
PostPosted: Tue Nov 15, 2005 7:08 pm    Post subject: A problem about 3*3 puzzle Reply with quote

Hello, because my teacher give me a programming homework,
like
8 7 4
1 5 6
2 3 S S means space (like this game http://www.permadi.com/java/puzzle8/)
write a program to figure out the standard form
standard form
1 2 3
4 5 6
7 8 S
We has to print the steps between the process.

I use the recursive to let PC run itself.
But I spend lots of time.And didn't figure out sometimes.
I didn't use any algorithm.
for example,(position 0 1 2
3 4 5
6 7 8 )
if space is now at position 0
I just the following recursive

newNode=swap(&present,3); //change to position 3
startPuzzle(newNode,depth);
newNode=swap(&present,1);
startPuzzle(newNode,depth);

space position 3
newNode=swap(&present,1); //change to position 1
startPuzzle(newNode,depth);
newNode=swap(&present,4);
startPuzzle(newNode,depth);
newNode=swap(&present,6);
startPuzzle(newNode,depth);

LOOK!! from position 0 -> 1 ->0 ->1 ....
it CIRCLE....

startPuzzle is my recursive functions

It is really inefficient.
And sometimes it will be stuck or circle by the other space position's recursive.

SO,PLEASE tell me the algoritm or recursive sequence...
I am so tired...Please help..thank u...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron