Thread: Confused (soduku)

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    Unhappy Confused (soduku)

    Write a program that reads a sudoku file as input and prints out if the file is a propersolution to the Sudoku puzzle. .......okay so i have no clue what code to write because i am given a file named sudoku.zip and in that it has 3 files. so what exactly do i do?

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    First you think about the problem...

    1) Do you know how to play Sudoku?
    2) Do you know how to analyse a win?
    3) Do you know what steps your program has to take?
    4) What is in those files and how does it apply to your problem?

    You need to understand the problem you are presented.
    Nobody, not even the esteemed Mr Einstein, can solve a problem they don't understand...

    Once you understand it in minute --computer like-- detail, you can begin planning out a way to solve it.

    Once you have a plan, you can turn on your computer and start coding according to your plan.
    Work in small blocks, testing as you go... get one section working before you start on the next.

    Then once the program is complete you need to test it to make sure it behaves exactly as expected.

    Now once you get this started, if you run into trouble you can post your plan or your code and ask specific questions, we'll see what we can do to help.

    You need to develop analytical skills. Writing code is only a small part of what software developers do.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    The first thing to always do, is to get to know your environment - recon your area - note all your assets and liabilities.

    In your case, the question is, what's in that zip file, exactly?

    Sudoku puzzle grids are usually read in as a continuous stream of 81 char's. A dot or space, or zero, representing a blank square in the puzzle. Anything else would be a given value for the starting position on the puzzle grid.

    Terminology can be a problem, since to Sudoku fans, a puzzle grid that has more than one solution, is not a proper sudoku puzzle at all. To others, any grid that can produce any number of solutions, is perfectly valid.

    (There are puzzle grids which yield 30,000 plus solutions, you understand).

    So what have you got, and if you haven't read up on the One Law of Sudoku, be sure you have that well understood.

    Reading a Sudoku solving website tutorial should be your second step. You will need just two solving techniques:

    Naked Singles
    Forced Singles

    You won't have time to implement much more, and there is no need to do so, for a brute force solver program.

    You will certainly need a way to display a Sudoku board in a console (terminal) window. I'll post up an example of how it should look (in order to be readily compatible with the forum I'm going to send you to, later on).

    Quite mysterious? Exactly!

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    The larger grid is much better to show to the user, including yourself.

    Code:
    +-------+-------+-------+
    | 1 2 3 | 4 5 6 | 7 8 9 |
    | 7 8 9 | 1 2 3 | 4 5 6 |
    | 4 5 6 | 7 8 9 | 1 2 3 |
    +-------+-------+-------+
    | . . . | . . . | . . . |
    | . . . | . . . | . . . |
    | . . . | . . . | . . . |
    +-------+-------+-------+
    | . . . | . . . | . . . |
    | . . . | . . . | . . . |
    | . . . | . . . | . . . |
    +-------+-------+-------+
    
    +---+---+---+
    |123|456|789|
    |789|123|456|
    |456|789|123|
    +---+---+---+
    |...|...|...|
    |...|...|...|
    |...|...|...|
    +---+---+---+
    |...|...|...|
    |...|...|...|
    |...|...|...|
    +---+---+---+
    The smaller one is what's used on the forum of Sudoku experts. Note that all the empty spaces have a dot in them, not a zero. Files will generally have a zero to indicate an empty space on the board.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by programhelp14 View Post
    i am given a file named sudoku.zip and in that it has 3 files. so what exactly do i do?
    What to do with the files? Beats me, I can't see their names or contents. If only there were some way of communicating this information to us...
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    ^^^^< ROFL > ^^^^

    Haven't laughed so hard all week.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confused
    By (TNT) in forum C# Programming
    Replies: 1
    Last Post: 11-23-2005, 04:49 PM
  2. confused
    By mopar123 in forum C Programming
    Replies: 18
    Last Post: 09-01-2005, 04:06 PM
  3. confused...
    By Darkcoder in forum Game Programming
    Replies: 4
    Last Post: 03-09-2005, 01:07 AM
  4. Very confused
    By Aerie in forum C Programming
    Replies: 3
    Last Post: 01-23-2005, 01:08 PM