Solving the regions in sudoku code

was able to solve the repetition of the rows and columns... but i am now having trouble solving for the regions... My professor prefers we do it in a single class with multiple methods... here is what I have..
This is my main method:
public class Test extends JApplet{
    int [][] entries = new int [9][9];
    boolean filled [][] = new boolean [9][9];
    public void paint(Graphics canvas) {
        // draws the puzzle board
        SudokuPuzzel(canvas);
        //     sets the initial values
        initialValues(canvas);
        // this adds the guess
        addGuess(canvas);
    private void initialValues(Graphics canvas) {
        int puzzleLength;
        // creates the list of numbers to be used in the array
        List numberList = new ArrayList(8);
        for (int i = 1; i<10; i++)
            numberList.add(new Integer(i));
        // this will set the initial values into the entries array
        for (int x = 0; x<9;x++)
            puzzleLength = x;
            Collections.shuffle(numberList);
            for (int y = 0; y<9; y++){
                entries[x][y] = (Integer) numberList.get(y);
            // this will check for repeats in the columns
                boolean validityColumn, validityRegion;
            do{
                validityColumn = true;
                validityRegion = true;
                validityColumn = checkColumn(puzzleLength, x);
                validityRegion = checkRegion(puzzleLength);
                if (!validityColumn || !validityRegion){
                    for (x = 1; x<3; x++)
                        Collections.shuffle(numberList);
                        for (int i =0; i<9;i++)
                            entries[x] = (Integer) numberList.get(i);
System.out.println("re-determine");
}while(!validityColumn || !validityRegion);
for (int z = 0; z<9; z++)
String value;
for(int w = 0; w<9; w++){
value = Integer.toString(entries[z][w]);
printValue(canvas, value, z, w);
This is the method that checks if the numbers in the columns are duplicatedprivate boolean checkColumn(int puzzleLength, int x) {
// this method receives the puzzle length and row
// it then checks to see if any number repeats
// in the previous rows. if so, the row is
// shuffled and realigned
for (int j = 0; j<= puzzleLength; j++){
for (int i =0; i< 9; i++)
and this checks the regions..private boolean checkRegion(int puzzleLength) {
if (puzzleLength == 2)
for (int i = 0; i<3; i++)
for (int j = 0; j<3; j++)
for (int k = 0; k <3; k++)
for (int l = 0; l<3; l++)
if ((i != k && k != l) && entries[i][j] == entries[k][l])
return false;
return true;
I am getting an infinate loop and I don't understand where or why...

onorinbejasus wrote:
I am getting an infinate loop and I don't understand where or why... Debug your application by placing some System.out.println's in your code and printing out the variables. That way, you see how they change and you can then deduce why an infinite loop is occurring.
Start by debugging in your do-while statement: that is the only place (from the code you posted) where it can go in an infinite loop.
I also recommend you create some "helper methods" to make the checking of rows, columns and regions easier:
boolean[] getRow(int rowNumber) {
  // For example, if the 'rowNumber' has the numbers 1, 2, 3 and 8 filled in, return the
  // following array: [true, true, true, false, false, false, false, true, false]
  // You can also choose to return the numbers [1, 2, 3, 8] of course, that;'s for you to
  // decide (the return type should be changed to int[] of course)
boolean[] getColumn(int columnNumber) {
  // the same as in getRow(...) but then the column values are returned
boolean[] getRegion(int regionNumber) {
}Good luck.

Similar Messages

  • How do I solve the following message from Code Blocks on a OS X (10.10.2): "Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo." ?. It appears when I try to compile any code.

    Whenever I try to compile any code the following messagem appears: "greeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo."
    I'm using CodeBlocks v. 13.12. Its file (codeblocks-2.app) is inside the App folder.

    I suggest you ask whomever makes CodeBlocks.
    They would be the most knowledgeable.

  • How to delete the region code for country in T005U

    Hello,
    The region code for XX country are changed, So I have deleted all entries for that country in transaction code "OVK2" and updated the new region code which should be updated in Table T005S and T005U.
    But in table T005U there are few region code for language other then EN. Now I need to delete the entries T005U for other language.
    Now region code in OVK2 = Table T005S, but not equal to T005U
    How language can be selected to delete the region code (TABLE T005U), please advise.
    Thanks in advance.
    Praveen

    Hi Praveen,
    In order to delete the entries from the language table T005U, you will have to maintain in T005S.
    It means that, suppose in table T005U, you have a region appearing in two languages danish and german and the corresponding entry does not exist in T005S, then follow the steps below.
    1. Maintain Region XX in EN in T005S.
    2. Log on in language Danish, and in table T005U, only delete the text and log off.
    3. Log on in Language German, and in table T005U, delete the text only and log off.
    4. Now your T005U table is clear, log on in language EN and delete from table T005S.
    5. Check both tables T005S and T005U for the region XX. they both should be empty.
    Regards,
    SAPFICO

  • Calendar and Time showing in arabic but my phone's language is English. I bought my phone from DU in UAE , Dubai. Please help me solve this issue while keeping the Region to United Arab Emirates

    Calendar and Time showing in arabic but my phone's language is English. I bought my phone from DU in UAE , Dubai. Please help me solve this issue while keeping the Region to United Arab Emirates

    Valentine350z wrote:
    while keeping the Region to United Arab Emirates
    Not possible, I think.  Tell Apple how you feel about this at
    http://www.apple.com/feedback/iphone.html

  • My DVD Player hangs when trying to change the regional code the first time

    Hello,
    I am new to this forum and I couldn't find one for the DVD Player specific so I chose this one. Please direct me to a different one if my eyes were misleading me.
    I have a new Macbook. Just over three month now and I attempted to watch a movie with the DVD Player last night the first time. When inserting the DVD, the DVD player comes up with a Screen asking me to change the Regional Code from 6 to 1. I don't understand this in the first place since I purchased my Mac within the US. But anyway, When I unlock it with my password and then click the "Set Regional Code" Button (Regional Code preset to one at this time), it turns blue and then the rainbow wheel for being busy shows up. Unfortunately it never leaves and going to the activity monitor it says (Not responding). That causes bad Windows Memories .
    Tried multiple ways, let it run for 10 hours and it never returns to the world. Very frustrating, since this is the first time I tried to use this feature.
    Is there any advice on how to set this to Regional Code 1. I only have to set it once, but I think there must be an option.
    And yes, I know of VLC, but I still would prefer to use this regular DVD player. I think this should work somehow.
    Computer out of the box, nothing other then iWorks and MS Office 2008 installed.
    Any help is appreciated.
    Thanks a lot
    The Dark Lord
    Bernd

    Does the account you are using have admin rights? I found this :
    http://support.apple.com/kb/HT2397
    +In Mac OS X 10.3 Panther and later, users with administrative privileges aren't prompted to change the region the very first time a DVD-Video disc of a single region is inserted. Instead, the region of the DVD drive is automatically set to the region of the DVD disc that was inserted. Accounts that don't have administrative privileges must authenticate with an administrator account name and password, because changing the drive's region code requires administrative privileges.+
    Sounds like it might be worth a try from an admin account first.

  • Any way i can change the region code after the fifth time?

    I wasn't aware about the region code being lock after the fifth time.
    Is there any way I can change the region code instantly?

    No, the drive is permanently locked to the last code you used. If it's not on the one you would prefer, the only thing you can do it replace the drive.
    Almost all drives you can get are region free. I couldn't tell you why Apple continues to use drives that require selecting a region.

  • [SOLVED]How to add OAL driver level functionality in the AM335x BSP source code???

    Dear developers,
    Greetings!!!
    As, my platform is WinCE 7 with AM335x BSP and I would like to copy one driver and update the driver as per my requirements. The location from where I have taken the existing driver is - 
    BSP\SRC\CSP\COMMON_TI_AMXX\OAL --
    Existing diver is OALRTC and new driver is abc_I2C under the same location and I have tailored the driver according to my requirements.
    One funciton is OALIoCtlHalInitRTC and the call is made from BSP\SRC\OAL\oallib\ioctl.c and the calling funciton is BSPIoCtlHalInitRegistry
    In my case, I am calling my OAL API as OALIoCtlHalInitPHY..
    But the thing is that I am getting linking error during the time of compiling and is shown below -
    Error 6 Error(s) in directory "C:\WINCE700\platform\AM335x\SRC\OAL\OALEXE\". C:\WINCE700\build.log 2800
    Error 7 oal.lib(ioctl.obj) : error LNK2019: unresolved external symbol OALIoCtlHalInitPHY referenced in function BSPIoCtlHalInitRegistry C:\WINCE700\build.log 2801
    Error 8 fatal error LNK1120: 1 unresolved externals {log="C:\WINCE700\build.log(2802)"} C:\WINCE700\OSDesigns\Enventure\Enventure\Wince700\AM335x_ARMV7_Retail\cesysgen\platform\AM335x\target\ARMV7\retail\oal.exe
    Error 9 NMAKE : fatal error U1077: 'C:\WINCE700\sdk\bin\i386\ARM\link.EXE' : return code '0x460' C:\WINCE700\build.log 2803
    Error 10 TargetExeFiles -nologo BUILDMSG=Stop. BUILDROOT=C:\WINCE700\platform\AM335x LINKONLY=1 NOPASS0=1 failed - rc = 2. C:\WINCE700\build.log 2805
    Error 11 BLDDEMO: ERROR: There were errors building CEBASE. C:\WINCE700\build.log 2837
    As I searched but I am unable to solve the issue. 
    Any one suggest that how to solve the issue???

    Hello Friends,
    The above problem is self solved..

  • DVD Player Hasn't set the REGION code

    I just got a new MacBookPro (a replacement for one that had failed). Well, I restored all my data and am working fine... BUT...
    I think all my settings think that I've already set the Region Code of the DVD drive. But, using a tool, I was able to verify that the region code has NOT been set.
    How can I force DVD Player to set the region code of the DVD Drive? Right now, I can't play anything.
    Thanks!

    Hi Jack and welcome!
    Until I read the last sentence my answer would have been: insert a commercial DVD intended for your region code (unhelpfully you don't say where you are!), i.e. NTSC for the US or PAL for Europe, and it will ask you set the region code for that DVD.
    Remember: you can only ever do this five times, so best not to play DVDs from other regions.
    But then you spoilt it all by saying "Right now, I can't play anything"!
    What did you try to play?
    Did you repair permissions?

  • How can I over-ride the regional code?

    I buy DVD from different countries.
    In my Microsoft I could over-ride the regional code.
    Question: What can I do with my Probook to play DVDs from variious regional codes?
    Is there a software avaliable or what else can I do?
    Volker

    "Is there a software avaliable or what else can I do?"
    There is no method by which an MBP can have the regional code reset.  There are external players that do not utilize the regional coding, and allow all optical media to be used.  Google is your friend.

  • I have just bought an old ibook g3 and i need a code to change the region on the dvd drive . how can i get this ?, i have just bought an old ibook g3 and i need a code to change the region on the dvd drive . how can i get this ?

    i do not know the code to change the region on the dvd drive and it is stuck on region 1 and i need to change it to region 2. i am using an old ibook g3 , can any one help with the code

    You must have a G4 iBook as the G3 models can only install up to 10.4.11.
    Some links to read for possible help.
    https://discussions.apple.com/message/759882#759882
    https://discussions.apple.com/message/5083031#5083031
    https://discussions.apple.com/message/20461888#20461888

  • How do I set the region code for my Mac?

    I have been using my powerbook since 2004. I must have changed the region code once before for the DVD player. But since then any and all DVD's have played - unless the DVD itself had a problem. A few days back i put in a DVD which needed region change. Without thinking I changed it and now I have DVD's that used to play before, not play anymore. Please let me know how I can put the region code back to what it was - where all DVD's played.
    I don't think I have changed the region code five times - but can one really nor change the code once it has changed the fifth time???????? Please advice.

    I got a prompt when I had inserted the DVD which needed region change. But not now when I put in any other DVD. Some work, some don't. Is it not true that when changing the fourth time, the machine gives some indication that the next time will be the last? I thought so, whcih is why I am wondering, why it is not prompting or warning me.

  • An error encounter on test devise (real devise) i.e "apple mach -o linker error linker command failed with exit code 1", please any body help me to solve the problem

    Hello, I am using tesseract api in my app, which run perfectly on simulator but on test devise (real devise) it is showing an error i.e "apple mach -o linker error linker command failed with exit code 1", please any body help me to solve the problem

    if you can't compile the webutil.pll in your forms developer you need to set the forms_builder_classpath in you windows registry. You have to add the frmwebutil.jar,jacob.jar to the registry key. The configuration files you mention are for running the forms.

  • Who can solve the error code 403 on hp5522 ? help please

    who can solve the error code 403  on hp5522 ?   help please

    Hello fredovolley,
    Welcome to the HP Support Forums!
    I see that you are experiencing an error 403 with the Photosmart 5520 series. I would like to offer the steps I have given before, check them out here: Re: Trouble scanning using Photosmart 6520
    Even though it states it is for a 6520, the steps are all the same. I hope this help, cheers!
    JERENDS
    I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to the left of the reply button to say “Thanks” for helping!

  • I use an iphone 5 ..my problem is whenevr i set a picture of my contacts in their contacts info..the picture never shows up when they call me..i even added my country code to their no. but it still didnt solve the problem..so wat shud i do now?

    I use an iphone 5 ..my problem is whenevr i set a picture of my contacts in their contacts info..the picture never shows up when they call me..i even added my country code to their no. but it still didnt solve the problem..so wat shud i do now?

    Do you see your contact's number?
    What carrier are you using?

  • I bought my 5s from switzerland ım ın turkey.In 5s somethings language is different.My accounts region is turkey but i cant solve the problem.game centers declaration is german

    I bought my 5s from switzerland ım ın turkey.In 5s somethings language is different.My accounts region is turkey but i cant solve the problem.game centers declaration is german.I did everything turkey and language turkish but its not changing.

    Hi cbmmemo,
    Thanks for visiting Apple Support Communities.
    You may want to check the App Store country/region setting on your iPhone, as applications can vary by region:
    Change your iTunes Store country
    Sign in to the account for the iTunes Store region you'd like to use. TapSettings > iTunes & App Stores > Apple ID: > View Apple ID > Country/Region.
    You can find this information here:
    iOS: Changing the signed-in iTunes Store Apple ID account
    http://support.apple.com/kb/HT1311
    The information in this article may also help:
    iOS: Troubleshooting applications purchased from the App Store
    http://support.apple.com/kb/ts1702
    All the best,
    Jeremy

Maybe you are looking for