Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to fill 9*9 grid, with numbers from 1-9. Each row, column should be unique.
It is same as Sudoku puzzle but in Sudoku we have some cells already filled up. But here I've to just fill a 9*9 grid which will look solved Sudoku puzzle.

How can I implement the logic for this?
Posted
Comments
Richard MacCutchan 25-Apr-12 18:24pm    
I would suggest you try some research; Google is your friend.
Sergey Alexandrovich Kryukov 25-Apr-12 19:05pm    
I answered. Considering OP's comment about available solutions, this is no more than a trivial logical mistake. Please see.
--SA
nischalinn 25-Apr-12 18:46pm    
Thank You for the suggestion. I've done that earlier and only after that posted this thread. every posts in google tries to solve a sudoku puzzle but mine is different from that. So I've posted it here.
Sergey Alexandrovich Kryukov 25-Apr-12 18:53pm    
Agree, but did you simply try to solve it by yourself?
--SA
nischalinn 25-Apr-12 18:58pm    
@ SAKryukov: ya I tried it but I can not understand how to implement the logic for this. I only want to know the logic for this not the programming part.
Thank you

First: as the result should satisfy Sudoku rules, you did not correctly formulate it. Please see: http://en.wikipedia.org/wiki/Sudoku[^].

Now, in you comment about available solution of Sudoku puzzle you failed to use very simple logic. Think about it: if you have an algorithm solving Sudoku puzzle, it also solves your problem. Isn't this obvious? Or you need a proof? :-)

—SA
 
Share this answer
 
hello..
i tried to understand your question and i think that's what you want
C#
namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args)
        {
            for (int i = 0; i <9; i++)
            {
                for (int x = 0; x < 9; x++)
                {
                    if ((x + 1 + i) > 9)
                    {
                        Console.Write("  {0}  ", (x + i + 1) % 9);
                    }
                    else
                    {
                        Console.Write("  {0}  ", (x + 1 + i));
                    }
                }
                Console.WriteLine("\n");
            }
            Console.Read();
        }
    }
}


and the output will be look like this:
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900