Closed Thread
Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: 4 by 4 sudoku without using arrays

  1. #11
    libbylibra is offline Newbie
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    I'm trying to use loop...
    But it seems a bit too complicated...

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: 4 by 4 sudoku without using arrays

    they are not that bad lol

    basically look at this:

    Code:
    while(true) {
    //do this
    }
    basically you see "while" "true" and "do this"

    while is the type of loop. 2 main loops are "for" and "while" I like while the most. Basically this while loop will continue as long as the statement in side the () are true so 1==1 is always true and true is always true so it will always be true and basically be and infinite loop

    it executes the stuff inside of the {} brackets which is just a comment so it will basically do nothing forever

    Code:
    int i = 0;
    while(i <= 10) {
    	cout << "hello" << endl;
    	i++;
    }
    This one does the same thing. It starts with "i" equaling 0, and keeps looping, every time increasing the value of i, and once i is not less than or equal to 10 it quits running the code.

    Make sense?

    Control flow - Wikipedia, the free encyclopedia

  4. #13
    libbylibra is offline Newbie
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    Yeah.
    Thanks blainsch~
    Now I'm much more clear with the whole thing.
    I need to int all the variables right? (ex: r1c2 for row1column 2)

  5. #14
    mosyemessy is offline Newbie
    Join Date
    Jun 2009
    Posts
    4
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    hey i did it!!! this is only one block of 12. only copy paste and and change the variables. and i could introduce a function.
    Code:
    for (int i=1; i<=4; ++i)
      {
       if (c1r1==i) for (int j=1; j<=4; ++j)
       {
         if (j==i) j++;
         if (j<=4 and c1r2==j) for (int k=1; k<=4; ++k)
          {
            if (k==i or k==j) k++;
            if (k==i or k==j) k++;
            if (k<=4 and c1r3==k) for (int l=1; l<=4; ++l)
             {
               if (l==i or l==j or l==k) l++;
               if (l==i or l==j or l==k) l++;
               if (l==i or l==j or l==k) l++;
               if (l<=4 and c1r4==l) point++;
             }
          }
       }
      }
    Last edited by WingedPanther; 07-04-2009 at 05:08 AM. Reason: add code tags (the # button)

  6. #15
    mosyemessy is offline Newbie
    Join Date
    Jun 2009
    Posts
    4
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    c1r1 is column 1 row 1.

  7. #16
    Ajiz Zone is offline Newbie
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    for (int i=1; i<=4; ++i)
    {
    if (c1r1==i) for (int j=1; j<=4; ++j)
    {
    if (j==i) j++;
    if (j<=4 and c1r2==j) for (int k=1; k<=4; ++k)
    {
    if (k==i or k==j) k++;
    if (k==i or k==j) k++;
    if (k<=4 and c1r3==k) for (int l=1; l<=4; ++l)
    {
    if (l==i or l==j or l==k) l++;
    if (l==i or l==j or l==k) l++;
    if (l==i or l==j or l==k) l++;
    if (l<=4 and c1r4==l) point++;
    }
    }
    }
    }

    hai.. i'm new to c++ but i quite like the code top there...
    can some one help to explain it... when i see that quite confusing..
    i hope genius around this site help to explain it.

  8. #17
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: 4 by 4 sudoku without using arrays

    It attempts to find (part of) a solution to a 4x4 sudoku through brute force. If you trace through the code by hand, you'll quickly see what it's doing.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  9. #18
    kiddies is offline Programmer
    Join Date
    May 2009
    Posts
    129
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    ohhh, if w wanna make a sudoku, we have to use a nested loop,

  10. #19
    Mathematix is offline Programmer
    Join Date
    Jun 2009
    Posts
    112
    Rep Power
    0

    Re: 4 by 4 sudoku without using arrays

    Hint: 'structures'

    These would allow you to group the data making up the Sudoku array without using arrays.

    I'll leave it for you to stew over for a bit.

Closed Thread
Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sudoku solver in python :D
    By Hot_Milo23 in forum Tutorials
    Replies: 7
    Last Post: 10-19-2009, 04:51 PM
  2. Sudoku on F acebook
    By Bierrie in forum Website Design
    Replies: 3
    Last Post: 09-02-2009, 09:36 AM
  3. homemade sudoku generator
    By mokszyk in forum C and C++
    Replies: 3
    Last Post: 06-20-2009, 03:37 AM
  4. sudoku solver !!help!!
    By vaibhav_cbeginner in forum C and C++
    Replies: 5
    Last Post: 07-22-2008, 03:45 PM
  5. Sudoku can be solved using SQL..Take a look!
    By roger in forum Database & Database Programming
    Replies: 5
    Last Post: 07-04-2006, 12:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts