![]() |
|
#1
|
|||
|
|||
Sudoku - Lite versionHey first post on the board. Also one of my first programs.
I don't include code, and i have read the "read this before posting" Anyhow, i was wondering if any of you have done a lite version or like it before or know of one. And yes i have been goggling a lot, also did a search of this board. Got a recommendation from a friend. I have made a fixed solution from the start, but from here on, i don't know what to do. int sudoku[][]={8,5,4,9,6,4,7,2,1},{6,2,9,7,5,1,3,8,4},{7,3,1,2, 8,4,6,9,5},{4,7,5,6,1,9,8,3,2},{3,9,8,5,2,7,4,1,6} ,{1,6,2,4,3,8,5,7,9},{9,8,6,3,4,2,1,5,7},{5,1,7,8, 9,6,2,4,3},{2,4,3,1,7,5,9,6,8} Its a exam project and would welcome any help from you guys, but sure i also understand if you don't want to help me |
|
#2
|
|||
|
|||
Re: Sudoku - Lite versionQuote:
I don't know what you are supposed to do. Assuming that the quantities inside the braces represent the rows, you have not posted a valid solution sudoku. Here is a representation in ascii. Note that the digit 4 appears twice on the first row. Code:
Or, are the things in braces supposed to represent the numbers in the "little squares"? (Still not valid, since the number 4 appears twice in the first group.) Or what? What is your program supposed to do? Is the program supposed to print puzzles, generate puzzles, solve puzzles or validate proposed solutions? Or what? Have you ever solved sudoku puzzles? (By "hand", I mean.) Regards, Dave Last edited by davekw7x : 28-Feb-2007 at 10:17.
|
|
#3
|
|||
|
|||
Re: Sudoku - Lite versionThanks for your replay.
Quote[ What is your program supposed to do? Is the program supposed to print puzzles, generate puzzles, solve puzzles or validate proposed solutions? Or what? ] Its supposed to give a player a game of sort, trying to solve this puzzled. And no never played sudoku before, just got the assignment. Quote[ For example, if I swap the first two digits on the first row, is the program supposed to test whether it still valid? (To me, it obviously is not.) Or what? ] I don't know how to do this but as its a fixed set of numbers, given by myself, don't think it has to. But sure would be nice to put in, given time. ---- Jesper |
|
#4
|
|||
|
|||
Re: Sudoku - Lite versionFirst of all, notice that my first response was posted too hastily. I edited it to show that the puzzle that I printed out is not valid. I'm sorry that I got it wrong at first.
Quote:
Then I respectfully suggest that you learn the rules of the "game" and try to solve a few "by hand" before even thinking about how to write a program to do whatever it is that you are supposed to do. Regards, Dave |
|
#5
|
|||
|
|||
Re: Sudoku - Lite versionQuote:
Done a few now and a thing that worry me are that you write down a number that it could be, that you cant do on the computer, it wants to know the "true" answer. Therefore it can be kind of hard doing it on a computer, but also easyere, you can just type and hope for the correct answer. And about what i am supposed to do. I have to make this "game" so that my player can play one game, a fixed one. And then i need to understand whats going on in my source code. Thats about all. I have been told that grafik i shouldn't care about. Jesper |
|
#6
|
||||
|
||||
Re: Sudoku - Lite versionYou need some kind of input to set up the initial board. You could type in something like 000030000 to load a row with a 3 in the center of the center box. Accept 8 more rows to load the starting position.
Then accept a value and a location 4,2,7 (put a 4 in 2nd row, 7th col) then using the rules the program verifies that the number and location are valid. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#7
|
|||
|
|||
Re: Sudoku - Lite versionWhat I think WaltP is trying to say is that you need a C++ design that encapsulates the data representation of a Sudoku puzzle and provides appropriate interfaces to that data.
Here is a rough approximation of a class that may possibly provide some of the features that you might expect to see in such an implementation: Sudoku.h CPP / C++ / C Code:
Sudoku.cpp CPP / C++ / C Code:
main.cpp CPP / C++ / C Code:
/tmp/sodoku.txt file contents: Code:
Output: Code:
Note that due to time constraints in preparing this limited example, I did not test several elements of the code, so your mileage may vary. I also didn't format the output as sexy as Dave's output, but hopefully it will give you some ideas for your own effort. Obviously, one would need to implement some kind of puzzle validation routine and provide for user input beyond the basic interfaces provided by the extremely basic Sudoku class provided in this example. :davis: |
Recent GIDBlog
I?m Home by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| versions | onauc | C++ Forum | 13 | 21-Nov-2004 00:24 |
| Apache perl version mismatch - can I fix it? | chinagirl | Apache Web Server Forum | 1 | 25-May-2004 02:13 |
| How do I detect flash version on my computer system? | rhino1616 | Graphics Forum | 2 | 23-Oct-2003 10:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The