sudoku - arrays

This is a discussion on sudoku - arrays within the C++ Programming forums, part of the General Programming Boards category; Hi guys, im currently in the process of making a sudoku solver. At present it can solve the easier puzzles, ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    36

    sudoku - arrays

    Hi guys, im currently in the process of making a sudoku solver. At present it can solve the easier puzzles, but not the hard ones. I saw on another site the following code

    Code:
    # const uint lineElements[L][C] = {  
    #     { 0,  1,  2,  3,  4,  5,  6,  7,  8},  
    #     { 9, 10, 11, 12, 13, 14, 15, 16, 17},  
    #     {18, 19, 20, 21, 22, 23, 24, 25, 26},  
    #     {27, 28, 29, 30, 31, 32, 33, 34, 35},  
    #     {36, 37, 38, 39, 40, 41, 42, 43, 44},  
    #     {45, 46, 47, 48, 49, 50, 51, 52, 53},  
    #     {54, 55, 56, 57, 58, 59, 60, 61, 62},  
    #     {63, 64, 65, 66, 67, 68, 68, 70, 71},  
    #     {72, 73, 74, 75, 76, 77, 78, 79, 80}  
    # };  
    #   
    # const uint columnElements[C][L] = {  
    #     { 0,  9, 18, 27, 36, 45, 54, 63, 72},  
    #     { 1, 10, 19, 28, 37, 46, 55, 64, 73},  
    #     { 2, 11, 20, 29, 38, 47, 56, 65, 74},  
    #     { 3, 12, 21, 30, 39, 48, 57, 66, 75},  
    #     { 4, 13, 22, 31, 40, 49, 58, 67, 76},  
    #     { 5, 14, 23, 32, 41, 50, 59, 68, 77},  
    #     { 6, 15, 24, 33, 42, 51, 60, 69, 78},  
    #     { 7, 16, 25, 34, 43, 52, 61, 70, 79},  
    #     { 8, 17, 26, 35, 44, 53, 62, 71, 80}  
    # };  
    #
    What does this do? does it assign a number to every array entry?

    At the moment i have many for loops to get values from the array. Is this a way of simply referencing, say array[3][6] as the number 47. This would make it a lot easier as with 1 loop, I could check both the vertical and horizontal numbers.

    Am i right? if so, how would i declare this in c++

    Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by rocketman50 View Post

    Am i right? if so, how would i declare this in c++

    Thanks
    You would remove all those # signs from the left column.

    And yes, this assigns numbers to the array -- remember that the last number changes fastest, so that first row of numbers would be array[0][whatever].

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    36
    Quote Originally Posted by tabstop View Post
    You would remove all those # signs from the left column.

    And yes, this assigns numbers to the array -- remember that the last number changes fastest, so that first row of numbers would be array[0][whatever].
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc, structures, arrays and sudoku!!
    By AmbliKai in forum C Programming
    Replies: 13
    Last Post: 10-15-2008, 04:05 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21