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   

solving sudoku with c program

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

Joined: 23 Apr 2008
Posts: 2
:

Items
PostPosted: Wed Apr 23, 2008 7:48 am    Post subject: solving sudoku with c program Reply with quote

hey i was hoping someone could help me Wink
i need to be able to solve sudoku using C language and using functions and 2d arrays oh and for loops Shocked
i have to be able to call on these functions to pick up errors, say, if user enters two of the same numbers in one row/column/3 by 3 sqaure, if user enters too many numbers or too little or enters letters

also the functions should go at the bottom of code and at the top i need to use a function prototype ... which is confussing???

the input from user woulld have to be something like this . . 3 . 5 . 4 . . (repeated nine more times)

thank you for taking the time to read this
Smile
Back to top
View user's profile Send private message
Adak

Joined: 27 Feb 2008
Posts: 87
:

Items
PostPosted: Wed Apr 23, 2008 9:05 am    Post subject: Re: solving sudoku with c program Reply with quote

Sarah009 wrote:
hey i was hoping someone could help me Wink
i need to be able to solve sudoku using C language and using functions and 2d arrays oh and for loops Shocked
i have to be able to call on these functions to pick up errors, say, if user enters two of the same numbers in one row/column/3 by 3 sqaure, if user enters too many numbers or too little or enters letters

also the functions should go at the bottom of code and at the top i need to use a function prototype ... which is confussing???

the input from user woulld have to be something like this . . 3 . 5 . 4 . . (repeated nine more times)

thank you for taking the time to read this
Smile


Does your program need to solve a puzzle, or act as a referee only, to keep the human player from making an illegal move?

Functions prototypes just tell the compiler what you'll have for functions, ahead of time - so if you have a function called test(digit), which returns an integer to indicate whether the digit being tested was OK or not, then near the top of your program, you'd have a function prototype of:

int test(int); or perhaps int test(int digit);

ez stuff.

For homework help, I'll tell you in advance - be ready to SHOW your work code, and TELL us WHAT the problem is. If you just say "It won't work and I'm pulling my hair out!", and show little or no work on your part - I'll tell you to go buy a wig. Wink

There's a big difference between helping a student, and just having them dump the assignment only, or the code they have, and then they expect others to do it for them. Shocked

When you're ready to show your work, lay it on us. Cool
Back to top
View user's profile Send private message
Sarah009

Joined: 23 Apr 2008
Posts: 2
:

Items
PostPosted: Wed Apr 23, 2008 9:45 am    Post subject: Reply with quote

hey Adak and thanx
let me rephrase i have no clue how to start!
i was hoping for more of an outline on how to approach the problem like pseudo code maybe and pointers on what to think of when codding
how to approach it

and yes my code has to be a referee for the player

also i'm just not getting how to limit input to just numbers from one to nine and the full stops ... is that in a different function? or just in an if statement
thank you again
Back to top
View user's profile Send private message
Adak

Joined: 27 Feb 2008
Posts: 87
:

Items
PostPosted: Wed Apr 23, 2008 10:56 am    Post subject: Reply with quote

Sarah009 wrote:
hey Adak and thanx
let me rephrase i have no clue how to start!
i was hoping for more of an outline on how to approach the problem like pseudo code maybe and pointers on what to think of when codding
how to approach it

and yes my code has to be a referee for the player

also i'm just not getting how to limit input to just numbers from one to nine and the full stops ... is that in a different function? or just in an if statement
thank you again


The way I learned to start, was to leave the computer OFF, and take a big pad of paper.

Now think of the program, what it has to do, and make natural choices for the functions it will need. Put each functions name and anything you know it has to do, on a separate page, ripped off the pad.

Beyond a basic good design, ignore 90% of all the details, for now.

Like int CheckRow() is a natural function for Sudoku, likewise CheckCol(), to check if a digit is OK, with it's column. CheckBox() is another. You may not know how you want to code these up, but you know you're going to need them. For now, How? can be put off.

If you don't know how to get user's input, then read up! scanf() will do for you, now.

How to test for numbers between 1 and 9, inclusive? Zero is less than one, and all letters are greater than 9. A single if statement can test this, easily.

After you have this rough outline, fill in each page with pseudo-code of what it should be doing. Try to get the overall flow of the program, smoothed out. Having the program do it's work like you would do it, is a good start for a beginner.

Say you're the referree, and I gave you a number for a cell -- what would you do as a referee? You can't code up a program to do something you don't understand, so play with it until you do. Then continue.

Now take you pages and go to the computer and start filling in the pseudo-code with real code. Compile frequently so you're never left with 80 untested lines of code, with 156 errors, and no clue where to start debugging. Sad

Now that you've got the big idea's in place "from the top", work from the "bottom up", to fill in all the details.

Have you been attending your classes and reading your text? You're a bit behind the learning curve you'll need to do this assignment, so far, imo. You'll have to really start working to make this happen.

Good luck!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming 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